Revision ce60f670aac0a708d3a9af5f0cf46a752d46ba8a authored by John M Chambers on 28 October 2020, 07:59:48 UTC, committed by cran-robot on 28 October 2020, 07:59:48 UTC
1 parent 698183c
GPSTrack.R
setClassUnion("DateTime", c("POSIXt", "POSIXct", "POSIXlt"))
setClass("GPSTrack",
representation(latitude = "numeric", longitude = "numeric",
elevation = "numeric", time = "DateTime")
)
scanGPSTrack <- function(con,
fields = list(date = "", time = "",
lat = 0., lon = 0., el = 0.),
dateTimeFormat = "%Y-%m-%d %H:%M:%S") {
data <- scan(con, fields)
txt <- textConnection(paste(data$date, data$time), "r")
dateTime <- .scanDateTime(txt, dateTimeFormat)
close(txt)
new("GPSTrack", latitude = data$lat, longitude = data$lon,
elevation = data$el, time = dateTime)
}
.scanDateTime <- function(con, dateTimeFormat) {
as.POSIXct(strptime(readLines(con), dateTimeFormat))
}
Computing file changes ...