---
title: "Location Based Services Assignment 02"
author: "Erik Neller"
date: "`r Sys.Date()`"
output:
  html_document:
    df_print: paged
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


```{r geo}

# Load required packages
library(leaflet)
library(readr)
library(dplyr)

# Load RTKLIB output (.pos)
pos <- read_table("./record.pos",
                  comment = "%")     # % denotes comments, ignore those rows
# Add column names
colnames(pos) <- c("date", "time", "lat", "lon", "height", "Q", "ns", "sdn", "sde", "sdu",
                   "sdne", "sdeu", "sdun", "age", "ratio")[1:ncol(pos)]

# Inspect data
head(pos)

# Create interactive map
leaflet(pos) %>%
  addTiles() %>%
  addPolylines(lng = ~lon, lat = ~lat, color = "blue") %>%
  addMarkers(lng = ~lon[1], lat = ~lat[1], popup = "Start") %>%
  addMarkers(lng = ~lon[nrow(pos)], lat = ~lat[nrow(pos)], popup = "End")

```
