commit 088e7ae9427f26356da11f2c4c801cac2f7e4717
parent 06b1a6d31693fa73957be57d469d16d7fb9d414f
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date: Fri, 16 Sep 2016 15:37:38 -0400
Documentation for trajectory stuff, incorporated in namespace
Diffstat:
5 files changed, 87 insertions(+), 3 deletions(-)
diff --git a/NAMESPACE b/NAMESPACE
@@ -1,8 +1,11 @@
# Generated by roxygen2: do not edit by hand
export(coordsToBearing)
+export(createTrajectory)
export(distanceFromPath)
export(identifyAltitudeChanges)
export(identifyBearingChanges)
+export(interpolateTrajectory)
+export(is.flighttrajectory)
export(maxDistanceFromPath)
export(parseCoordinates)
diff --git a/man/createTrajectory.Rd b/man/createTrajectory.Rd
@@ -0,0 +1,43 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/createTrajectory.R
+\name{createTrajectory}
+\alias{createTrajectory}
+\title{Create a flighttrajectory object from the flight info.}
+\usage{
+createTrajectory(longitude, latitude, altitude = 0, timestamp = NULL,
+ bearing = NULL, groundspeed = NULL)
+}
+\arguments{
+\item{longitude}{Required; numeric vector giving aircraft longitude in
+degrees.}
+
+\item{latitude}{Required; numeric vector giving aircraft latitude in degrees.}
+
+\item{altitude}{Optional; numeric vector giving aircraft altitude (AGL) in
+feet. If missing, it will be set to 0.}
+
+\item{timestamp}{Optional; numeric vector giving the time of each observation
+in seconds. If missing, the observation period is assumed to be 1 s.}
+
+\item{bearing}{Optional; numeric vector giving the current bearing in
+degrees. If missing, it is estimated using pairs of successive lon/lat
+observations.}
+
+\item{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.}
+}
+\value{
+A flighttrajectory object encapsulating these parameters (with
+ default values substituded as necessary).
+}
+\description{
+Create a flighttrajectory object from the flight info.
+}
+\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.
+}
+
diff --git a/man/interpolateTrajectory.Rd b/man/interpolateTrajectory.Rd
@@ -0,0 +1,26 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/interpolateTrajectory.R
+\name{interpolateTrajectory}
+\alias{interpolateTrajectory}
+\title{Interpolate a trajectory (in time)}
+\usage{
+interpolateTrajectory(trajectory, timestamp)
+}
+\arguments{
+\item{trajectory}{A \code{flighttrajectory} object.}
+
+\item{timestamp}{The new timestamp along which the data should be
+interpolated.}
+}
+\value{
+A new \code{flighttrajectory} with the given \code{timestamp}
+}
+\description{
+Interpolate a trajectory (in time)
+}
+\details{
+This just performs linear interpolation for all of the values in the
+ trajectory. A better approach would make use of the bearing and velocity
+ information to smoothly interpolate the coordinates.
+}
+
diff --git a/man/is.flighttrajectory.Rd b/man/is.flighttrajectory.Rd
@@ -0,0 +1,12 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/createTrajectory.R
+\name{is.flighttrajectory}
+\alias{is.flighttrajectory}
+\title{Check if an object is a flighttrajectory}
+\usage{
+is.flighttrajectory(x)
+}
+\description{
+Check if an object is a flighttrajectory
+}
+
diff --git a/tests/testthat/test_interpolateTrajectory.R b/tests/testthat/test_interpolateTrajectory.R
@@ -1,4 +1,4 @@
-library(flightconflicts)
+library(flightpathr)
context("interpolateTrajectory")
library(geosphere)
@@ -17,7 +17,7 @@ trajectory2 <-createTrajectory(coords2[, 1], coords2[, 2], altitude = 3500,
test_that("Interpolated trajectory is close to correct", {
trajectoryInterpolated <- interpolateTrajectory(trajectory1,
trajectory2$timestamp)
-
+
for (tf in names(trajectoryInterpolated)) {
expect_equal(trajectoryInterpolated[[tf]], trajectory2[[tf]], tolerance = 1)
}
@@ -26,7 +26,7 @@ test_that("Interpolated trajectory is close to correct", {
test_that("Correctly handling times outside original range", {
trajectoryInterpolated <- interpolateTrajectory(trajectory1,
c(-100, 0, 800, 900))
-
+
for (tf in names(trajectoryInterpolated)[names(trajectoryInterpolated) != "timestamp"]) {
expect_equal(trajectoryInterpolated[[tf]][1], trajectoryInterpolated[[tf]][2])
expect_equal(trajectoryInterpolated[[tf]][3], trajectoryInterpolated[[tf]][4])