flightconflicts

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

commit 02dba5e675237d39b97c3f1697996b35615cfee1
parent 3d131a37c0cfdeec57f7d209208059c5d5ee33f3
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date:   Fri, 20 May 2016 11:47:24 -0400

First pass at flat-Earth code

Diffstat:
AR/lonlatToXY.R | 28++++++++++++++++++++++++++++
Aman/lonlatToXY.Rd | 27+++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/R/lonlatToXY.R b/R/lonlatToXY.R @@ -0,0 +1,28 @@ +#' Convert lon/lat coordinates to north/east coordinates (in feet) using a +#' flat-Earth approximation. +#' +#' @param longitude A numeric vector. +#' @param latitude A numeric vector. +#' @param originLongintude The logntidue for which x = 0 feet. +#' @param originLatitude The latitude for which x = 0 feet. +#' @return A n x 2 matrix giving the x and y distance (respectively), in feet, +#' of each longitude/latitude pair from the origin longitude/latitude. +lonlatToXY <- function(longitude, latitude, originLongitude, originLatitude) { + # This implementation is based on code from: + # http://williams.best.vwh.net/avform.htm#flat + dlon <- longitude - originLongitude + dlat <- latitude - originLatitude + + # Radius in feet and flattening based on WGS84 + a <- 20925646 + f <- 1/298.257223563 + e2 <- f*(2-f) + + R1 <- a*(1-e2)/(1-e2*(sin(originLatitude))^2)^(3/2) + R2 <- a/sqrt(1-e2*(sin(originLatitude))^2) + + xDistance <- R2 * cos(originLatitude) * dlon + yDistance <- R1 * dlat + + return(cbind(xDistance, yDistance)) +} diff --git a/man/lonlatToXY.Rd b/man/lonlatToXY.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/lonlatToXY.R +\name{lonlatToXY} +\alias{lonlatToXY} +\title{Convert lon/lat coordinates to north/east coordinates (in feet) using a +flat-Earth approximation.} +\usage{ +lonlatToXY(longitude, latitude, originLongitude, originLatitude) +} +\arguments{ +\item{longitude}{A numeric vector.} + +\item{latitude}{A numeric vector.} + +\item{originLatitude}{The latitude for which x = 0 feet.} + +\item{originLongintude}{The logntidue for which x = 0 feet.} +} +\value{ +A n x 2 matrix giving the x and y distance (respectively), in feet, + of each longitude/latitude pair from the origin longitude/latitude. +} +\description{ +Convert lon/lat coordinates to north/east coordinates (in feet) using a +flat-Earth approximation. +} +