flightconflicts

Tools to analyze conflicts between aircraft.
git clone https://git.eamoncaddigan.net/flightconflicts.git
Log | Files | Refs | README | LICENSE

commit 17a7f66bbae83ae6eff7b652d08cf267d78f8172
parent 57b63d06e6caccd2371e4321681997c03b9a00e3
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date:   Mon, 12 Sep 2016 13:38:40 -0400

Modularizing trajectory checking.

Diffstat:
MR/calculateSLoWC.R | 7+------
MR/calculateTCPA.R | 7+------
AR/checkTrajectories.R | 14++++++++++++++
Aman/checkTrajectories.Rd | 20++++++++++++++++++++
4 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/R/calculateSLoWC.R b/R/calculateSLoWC.R @@ -15,12 +15,7 @@ #' #' @export calculateSLoWC <- 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("Trajectories must have matching time stamps") - } + checkTrajectories(trajectory1, trajectory2) # Find the "origin" lon/lat for the encounter. Distances will be represented # in feet north/east from this point. Use the centroid of the trajectories. diff --git a/R/calculateTCPA.R b/R/calculateTCPA.R @@ -13,12 +13,7 @@ #' #' @export calculateTCPA <- 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("Trajectories must have matching time stamps") - } + checkTrajectories(trajectory1, trajectory2) # Find the "origin" lon/lat for the encounter. Distances will be represented # in feet north/east from this point. Use the centroid of the trajectories. diff --git a/R/checkTrajectories.R b/R/checkTrajectories.R @@ -0,0 +1,14 @@ +#' Check that both arguments are trajectories with the same timecourse. +#' +#' @param trajectory1 An object to test. +#' @param trajectory2 Another object to test. +#' @return TRUE if everything works. Raises an error otherwise. +checkTrajectories <- 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("Trajectories must have matching time stamps") + } + return(TRUE) +} diff --git a/man/checkTrajectories.Rd b/man/checkTrajectories.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/checkTrajectories.R +\name{checkTrajectories} +\alias{checkTrajectories} +\title{Check that both arguments are trajectories with the same timecourse.} +\usage{ +checkTrajectories(trajectory1, trajectory2) +} +\arguments{ +\item{trajectory1}{An object to test.} + +\item{trajectory2}{Another object to test.} +} +\value{ +TRUE if everything works. Raises an error otherwise. +} +\description{ +Check that both arguments are trajectories with the same timecourse. +} +