mil.af.afit.router
Class CoreUtilities

java.lang.Object
  |
  +--mil.af.afit.router.CoreUtilities

public class CoreUtilities
extends java.lang.Object


Field Summary
static int AMPM
          Specifies the use of AM/PM (12hour) time when converting integer time to a string.
static int MILITARY
          Specifies the use of military (24hour) time when converting integer time to a string.
 
Constructor Summary
CoreUtilities()
           
 
Method Summary
static void assignROZTimesToSites(RestrictedOperatingZone roz, SiteList siteList)
          Assigns the time windows and walls contained in the restricted operating zone to the sites contained in the site list.
static java.lang.String doubleLatToString(double lat, java.lang.String format)
          Converts a latitude to a string.
static java.lang.String doubleLonToString(double lon, java.lang.String format)
          Converts a longitude to a string in the form "DDDMMSS E" where "DDD" could be two or three digits and "E" could be "E" or "W" for east or west, respectively.
static double getGreatCircleDistance(double lat1, double lon1, double lat2, double lon2)
          Calculates the great circle distance between two latitudes and longitudes (in degrees and fractions of degrees).
static double getGroundSpeed(double airSpeed, double windSpeed, double delta)
          This calculates the ground speed based on the air speed, wind speed, and difference between their headings, delta.
static int getTimeToTravel(double startLat, double startLon, double endLat, double endLon, double windBearing, double windSpeed, double airSpeed)
          Calculates the time it take to travel from a starting point to an ending point taking into consideration wind speed and direction and vehicle speed.
static double getTrueHeading(double startLat, double startLon, double endLat, double endLon, double distance)
          Calculates the true heading on the so-called great circle's spherical triangle.
static java.lang.String intTimeToString(int iTime)
          Converts an integer time to a string in military (24hour) format.
static java.lang.String intTimeToString(int iTime, int type)
          Converts an integer time to a string in Kernel.MILITARY (24hour) format or 12hour Kernel.AMPM format.
static int reverseDirection(int originalDirection)
          This takes a direction (in degrees, clockwise from North) and returns the opposite direction.
static double stringLatLonToDouble(java.lang.String coord, java.lang.String format)
          Used to convert a string representation of N/S/E/W lat/lons to a double.
static double stringLatToDouble(java.lang.String sLat, java.lang.String format)
          Converts a latitude stored as a string into a double.
static double stringLonToDouble(java.lang.String sLon, java.lang.String format)
          Converts a longitude stored as a string into a double.
static int stringTimeToInt(java.lang.String sTime)
          Converts a string time to integer time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MILITARY

public static final int MILITARY
Specifies the use of military (24hour) time when converting integer time to a string.
See Also:
intTimeToString(int)
Since:
1.0

AMPM

public static final int AMPM
Specifies the use of AM/PM (12hour) time when converting integer time to a string.
See Also:
intTimeToString(int)
Since:
1.0
Constructor Detail

CoreUtilities

public CoreUtilities()
Method Detail

getTimeToTravel

public static final int getTimeToTravel(double startLat,
                                        double startLon,
                                        double endLat,
                                        double endLon,
                                        double windBearing,
                                        double windSpeed,
                                        double airSpeed)
Calculates the time it take to travel from a starting point to an ending point taking into consideration wind speed and direction and vehicle speed.
Parameters:
startLat - starting latitude
startLon - starting longitude
endLat - ending latitude
endLon - ending longitude
windBearing - bearing of wind, clockwise from North
windSpeed - wind speed in knots
airSpeed - vehicle speed in knots
Returns:
time in minutes to travel from one point to another
Since:
1.0

getGreatCircleDistance

public static final double getGreatCircleDistance(double lat1,
                                                  double lon1,
                                                  double lat2,
                                                  double lon2)
Calculates the great circle distance between two latitudes and longitudes (in degrees and fractions of degrees). The formula is as follows:

d = 60 * arccos[ sin L1 * sin L2 + cos L1 * cos L2 * cos( l2 - l1 ) ]

where L1 and L2 are latitudes and little L's l1 and l2 are longitudes.

The code was adapted from Kevin O'Rourke's earlier code.

Parameters:
lat1 - first latitude
lon1 - first longitude
lat2 - second latitude
lon2 - second longitude

getTrueHeading

public static final double getTrueHeading(double startLat,
                                          double startLon,
                                          double endLat,
                                          double endLon,
                                          double distance)
Calculates the true heading on the so-called great circle's spherical triangle. First an intermediate heading H is calculated, and then a true heading is calculated.

                             d
               sin[L2] -(cos[--] sin[L1])
                             60
   H = arccos[----------------------------]
                                d
                    cos[L1] sin[--]
                                60
 

The true heading, then, is

                |  H,        sin( l2 - l1 ) < 0
 trueHeading =  |
                |  360 - H,  sin( l2 - l1 ) >= 0
 
Parameters:
startLat - starting latitude
startLon - starting longitude
endLat - ending latitude
endLon - ending longitude
distance - distance between the points
Returns:
true heading in degrees, clockwise from North
Since:
1.0

getGroundSpeed

public static final double getGroundSpeed(double airSpeed,
                                          double windSpeed,
                                          double delta)
This calculates the ground speed based on the air speed, wind speed, and difference between their headings, delta. The calculations are shown below, where AS = ground speed, and WS = wind speed.

     A = WS * cos( 180 - delta )
     C = WS * sin( 180 - delta )
            _________
           /  2    2
     B = \/ AS  - C
     ground speed = A + B
 
Parameters:
airSpeed - vehicle's air speed in knots
windSpeed - wind speed in knots
delta - distance in degrees between the wind and vehicle directions
Returns:
ground speed in knots
Since:
1.0

intTimeToString

public static final java.lang.String intTimeToString(int iTime)
Converts an integer time to a string in military (24hour) format. Integer time is stored as minutes after midnight starting at the first day in question.
Parameters:
iTime - integer time to convert to a string
Returns:
time as a string in military (24hour) format
Since:
1.0

intTimeToString

public static final java.lang.String intTimeToString(int iTime,
                                                     int type)
Converts an integer time to a string in Kernel.MILITARY (24hour) format or 12hour Kernel.AMPM format. Integer time is stored as minutes after midnight starting at the first day in question.
Parameters:
iTime - integer time to convert to a string
Returns:
time as a string
Since:
1.0

stringTimeToInt

public static final int stringTimeToInt(java.lang.String sTime)
Converts a string time to integer time. The string time is expected to be in the format returned by intTimeToString such as "1040h" or "1330h +1 day". It is fairly robust against alternates involving extra spaces and characters.
Parameters:
sTime - string time to convert
Returns:
integer time
Since:
1.0

doubleLatToString

public static final java.lang.String doubleLatToString(double lat,
                                                       java.lang.String format)
Converts a latitude to a string. Supported formats: dddmmss, dddmmhh, & ddd.hh (degrees, minutes, seconds; degrees, minutes, hundredths; and degrees, hundredths of degrees).
Parameters:
lat - latitude to convert
Returns:
string representation of latitude
Since:
1.0

doubleLonToString

public static final java.lang.String doubleLonToString(double lon,
                                                       java.lang.String format)
Converts a longitude to a string in the form "DDDMMSS E" where "DDD" could be two or three digits and "E" could be "E" or "W" for east or west, respectively.
Parameters:
lat - longitude to convert
Returns:
string representation of longitude
Since:
1.0

stringLatToDouble

public static final double stringLatToDouble(java.lang.String sLat,
                                             java.lang.String format)
Converts a latitude stored as a string into a double. Supported formats: dddmmss, dddmmhh, & ddd.hh (degrees, minutes, seconds; degrees, minutes, hundredths; and degrees, hundredths of degrees). Also required is a N,S,E, or W after the number.
Parameters:
sLat - latitude as string
Returns:
latitude as double
Since:
1.0

stringLonToDouble

public static final double stringLonToDouble(java.lang.String sLon,
                                             java.lang.String format)
Converts a longitude stored as a string into a double. Supported formats: dddmmss, dddmmhh, & ddd.hh (degrees, minutes, seconds; degrees, minutes, hundredths; and degrees, hundredths of degrees). Also required is a N,S,E, or W after the number.
Parameters:
sLat - longitude as string
Returns:
longitude as double
Since:
1.0

stringLatLonToDouble

public static final double stringLatLonToDouble(java.lang.String coord,
                                                java.lang.String format)
Used to convert a string representation of N/S/E/W lat/lons to a double. Supported formats: dddmmss, dddmmhh, & ddd.hh (degrees, minutes, seconds; degrees, minutes, hundredths; and degrees, hundredths of degrees). Also required is a N,S,E, or W after the number.
Parameters:
coord - string representation of a lat/lon
Returns:
lat/lon as a double
Since:
1.0

assignROZTimesToSites

public static final void assignROZTimesToSites(RestrictedOperatingZone roz,
                                               SiteList siteList)
Assigns the time windows and walls contained in the restricted operating zone to the sites contained in the site list.
Parameters:
roz - restricted operating zone from which to get time windows and walls
siteList - site list containing sites to modify based on the restricted operating zone
Since:
1.0

reverseDirection

public static final int reverseDirection(int originalDirection)
This takes a direction (in degrees, clockwise from North) and returns the opposite direction. For instance given a bearing for a wind, this would return where the wind is coming from: the standard way to report wind.
Parameters:
originalDirection - original direction
Returns:
opposite direction
Since:
1.0.2