commit 5d9eafa91a82a21ee675327c8cee688139495ab7
parent 197f48333b069f185933da4015da63adbb80a883
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date: Wed, 20 Apr 2016 10:24:22 -0400
Below-path bug.
Diffstat:
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/R/distanceFromPath.R b/R/distanceFromPath.R
@@ -43,7 +43,7 @@ distanceFromPath <- function(trajectory, path) {
deviationAbove <- trajectoryCoords[, 3] - max(pathCoords[c(legIdx, legIdx+1), 3])
deviationBelow <- trajectoryCoords[, 3] - min(pathCoords[c(legIdx, legIdx+1), 3])
vDistanceToLeg[deviationAbove > 0, legIdx] <- deviationAbove[deviationAbove > 0]
- vDistanceToLeg[deviationBelow < 0, legIdx] <- deviationBelow[deviationBelow > 0]
+ vDistanceToLeg[deviationBelow < 0, legIdx] <- deviationBelow[deviationBelow < 0]
}
# Squared euclidean distance
diff --git a/tests/testthat/test_distanceFromPath.R b/tests/testthat/test_distanceFromPath.R
@@ -51,6 +51,7 @@ test_that("simple altitude deviation is handled", {
flownPath1 <- cbind(path, alt = 3500)
flownPath2 <- cbind(path, alt = c(3500, 4500, 3500))
flownPath3 <- cbind(path, alt = c(3500, 5500, 3500))
+ flownPath4 <- cbind(path, alt = c(3500, 5500, 5500))
flownTrajectory <- cbind(fakeTrajectory(path),
alt = c(seq(3500, 5500, length.out = numPoints+2),
seq(5500, 3500,
@@ -62,6 +63,8 @@ test_that("simple altitude deviation is handled", {
distancePrecision)
expect_lt(abs(maxDistanceFromPath(flownTrajectory, flownPath3)["vertical"] - 0000),
distancePrecision)
+ expect_lt(abs(maxDistanceFromPath(flownTrajectory, flownPath4)["vertical"] - -2000),
+ distancePrecision)
})
test_that("reproducing geosphere vignette example", {