flightpathr

Tools to analyze aircraft and flight path data.
git clone https://git.eamoncaddigan.net/flightpathr.git
Log | Files | Refs | README | LICENSE

commit 6dca78ae4d781a8a05ebe1fa486bb5870695461d
parent d11aebdb6b1aa186d7e4e5c5c275389d788815c3
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date:   Mon, 18 Apr 2016 14:21:15 -0400

More tests.

Diffstat:
Mtests/testthat/test_distanceFromPath.R | 16++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tests/testthat/test_distanceFromPath.R b/tests/testthat/test_distanceFromPath.R @@ -9,9 +9,21 @@ path <- matrix(c(-75.0268, 39.7065, nrow = 3, byrow = TRUE, dimnames = list(c("17N", "N81", "KACY"), c("lon", "lat"))) -trajectory <- rbind(geosphere::gcIntermediate(path[1, ], path[2, ], 5), - geosphere::gcIntermediate(path[2, ], path[3, ], 6)) + +fakeTrajectory <- function(waypoints) { + trajectoryList <- vector("list", 2*nrow(waypoints)-1) + trajectoryList[[1]] <- waypoints[1, ] + for (i in seq(2, nrow(waypoints))) { + trajectoryList[[(i-1)*2]] <- geosphere::gcIntermediate(path[i-1, ], path[i, ], 5) + trajectoryList[[(i-1)*2+1]] <- waypoints[i, ] + } + return(do.call(rbind, trajectoryList)) +} + +trajectory <- fakeTrajectory(path) test_that("non-deviating paths have small distances", { expect_true(all(distanceFromPath(trajectory, path) < 1)) + expect_true(all(distanceFromPath(sp::SpatialPoints(trajectory), sp::SpatialPoints(path)) < 1)) + expect_true(all(distanceFromPath(as.data.frame(trajectory), as.data.frame(path)) < 1)) })