commit 377ca358eb1367770dada9b3d0c65a91534b8272
parent 11ce3f53c8d8ec34d320f03666def253f43575ff
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date: Thu, 19 May 2016 16:24:15 -0400
Identifying NMACs.
Diffstat:
3 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/NAMESPACE b/NAMESPACE
@@ -1,4 +1,5 @@
# Generated by roxygen2: do not edit by hand
export(createTrajectory)
+export(identifyNMAC)
export(is.flighttrajectory)
diff --git a/R/identifyNMAC.R b/R/identifyNMAC.R
@@ -0,0 +1,33 @@
+#' Determine whether an NMAC (near mid air collision) has occurred at each time
+#' point.
+#'
+#' @param trajectory1 A matrix or SpatialPoints object indicating the trajectory
+#' of the first aircraft.
+#' @param trajectory2 A matrix or SpatialPoints object indicating the trajectory
+#' of the second aircraft.
+#' @return The logical vector indicating whether NMAC criteria are met at each
+#' time point.
+#'
+#' @details NMAC is a cylinder +/- 100 ft above and below the ownship with a
+#' radius of 500 ft.
+#'
+#' @export
+identifyNMAC <- function(trajectory1, trajectory2) {
+ if (!is.flighttrajectory(trajectory1) || !is.flighttrajectory(trajectory2)) {
+ stop("Both arguments must be instances of flighttrajectory")
+ }
+ if (!isTRUE(all.equal(trajectory1$timestamp, trajectory2$timestamp))) {
+ stop("Both trajectories must have the same time stamps")
+ }
+
+ horizontalDistanceFt <- geosphere::distHaversine(cbind(trajectory1$longitude,
+ trajectory1$latitude),
+ cbind(trajectory2$longitude,
+ trajectory2$latitude),
+ r = 20925646)
+ verticalDistanceFt <- abs(trajectory1$altitude - trajectory2$altitude)
+
+ isNMAC <- (horizontalDistanceFt < 500) | (verticalDistanceFt < 100)
+
+ return(isNMAC)
+}
diff --git a/man/identifyNMAC.Rd b/man/identifyNMAC.Rd
@@ -0,0 +1,29 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/identifyNMAC.R
+\name{identifyNMAC}
+\alias{identifyNMAC}
+\title{Determine whether an NMAC (near mid air collision) has occurred at each time
+point.}
+\usage{
+identifyNMAC(trajectory1, trajectory2)
+}
+\arguments{
+\item{trajectory1}{A matrix or SpatialPoints object indicating the trajectory
+of the first aircraft.}
+
+\item{trajectory2}{A matrix or SpatialPoints object indicating the trajectory
+of the second aircraft.}
+}
+\value{
+The logical vector indicating whether NMAC criteria are met at each
+ time point.
+}
+\description{
+Determine whether an NMAC (near mid air collision) has occurred at each time
+point.
+}
+\details{
+NMAC is a cylinder +/- 100 ft above and below the ownship with a
+ radius of 500 ft.
+}
+