commit 025b2ab47b115956e45bfb003fd9202999d194bd
parent 088e7ae9427f26356da11f2c4c801cac2f7e4717
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date: Tue, 20 Sep 2016 10:17:56 -0400
Don't need to reference the package anymore
Diffstat:
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/R/createTrajectory.R b/R/createTrajectory.R
@@ -1,28 +1,28 @@
#' Create a flighttrajectory object from the flight info.
-#'
-#' @param longitude Required; numeric vector giving aircraft longitude in
+#'
+#' @param longitude Required; numeric vector giving aircraft longitude in
#' degrees.
#' @param latitude Required; numeric vector giving aircraft latitude in degrees.
-#' @param altitude Optional; numeric vector giving aircraft altitude (AGL) in
+#' @param altitude Optional; numeric vector giving aircraft altitude (AGL) in
#' feet. If missing, it will be set to 0.
#' @param timestamp Optional; numeric vector giving the time of each observation
#' in seconds. If missing, the observation period is assumed to be 1 s.
-#' @param bearing Optional; numeric vector giving the current bearing in
-#' degrees. If missing, it is estimated using pairs of successive lon/lat
+#' @param bearing Optional; numeric vector giving the current bearing in
+#' degrees. If missing, it is estimated using pairs of successive lon/lat
#' observations.
-#' @param groundspeed Optional; numeric vector giving the current ground speed
-#' of the aircraft in knots. If missing, it is estimated using pairs of
+#' @param groundspeed Optional; numeric vector giving the current ground speed
+#' of the aircraft in knots. If missing, it is estimated using pairs of
#' successive lon/lat observations.
#' @return A flighttrajectory object encapsulating these parameters (with
#' default values substituded as necessary).
-#'
-#' @details \code{longitude} and \code{latitude} must be the same length.
-#' \code{timestamp}, \code{bearing}, and \code{groundspeed}, if present, must
-#' also match this length. \code{altitude} must also have a length equal to
+#'
+#' @details \code{longitude} and \code{latitude} must be the same length.
+#' \code{timestamp}, \code{bearing}, and \code{groundspeed}, if present, must
+#' also match this length. \code{altitude} must also have a length equal to
#' these parameters or be scalar.
-#'
+#'
#' @export
-createTrajectory <- function(longitude, latitude, altitude = 0, timestamp = NULL,
+createTrajectory <- function(longitude, latitude, altitude = 0, timestamp = NULL,
bearing = NULL, groundspeed = NULL) {
if (!is.numeric(longitude)) stop("\"longitude\" must be a numeric vector")
nCoord <- length(longitude)
@@ -32,7 +32,7 @@ createTrajectory <- function(longitude, latitude, altitude = 0, timestamp = NULL
if (!is.numeric(x)) {
stop("\"", deparse(substitute(x)), "\" must be a numeric vector")
} else if (length(x) != nCoord) {
- stop("Vector \"", deparse(substitute(x)), "\" has length = ", length(x),
+ stop("Vector \"", deparse(substitute(x)), "\" has length = ", length(x),
", expected length = ", nCoord)
}
return(TRUE)
@@ -46,22 +46,22 @@ createTrajectory <- function(longitude, latitude, altitude = 0, timestamp = NULL
} else {
checkLength(altitude)
}
-
+
if (is.null(timestamp)) {
timestamp <- seq(1, nCoord)
} else {
checkLength(timestamp)
}
-
- # Use flightpathr to calculate bearing between successive points if not
+
+ # Use flightpathr to calculate bearing between successive points if not
# specified.
if (is.null(bearing)) {
- bearing <- flightpathr::coordsToBearing(cbind(coords, altitude))
+ bearing <- coordsToBearing(cbind(coords, altitude))
bearing[nCoord] <- bearing[nCoord-1]
} else {
checkLength(bearing)
}
-
+
# Use geosphere to find the distance between points and use the timestamps to
# calculate groundspeed if not specified.
if (is.null(groundspeed)) {
@@ -73,7 +73,7 @@ createTrajectory <- function(longitude, latitude, altitude = 0, timestamp = NULL
} else{
checkLength(groundspeed)
}
-
+
flighttrajectory <- list(longitude = longitude,
latitude = latitude,
altitude = altitude,
@@ -81,7 +81,7 @@ createTrajectory <- function(longitude, latitude, altitude = 0, timestamp = NULL
bearing = bearing,
groundspeed = groundspeed)
class(flighttrajectory) <- "flighttrajectory"
-
+
return(flighttrajectory)
}