Class GeoUtils
java.lang.Object
org.deltava.util.GeoUtils
A utility class for performing geocoding operations.
- Since:
- 1.0
- Version:
- 11.6
- Author:
- Luke
-
Method Summary
Modifier and TypeMethodDescriptionstatic GeoLocation
bearingPointS
(GeoLocation p1, double distance, double angle) Determines the coordinates of a second point on a particular heading from the first, assuming a spherical globe.static double
course
(GeoLocation l1, GeoLocation l2) Calculates the course between two points.static boolean
crossesMeridian
(GeoLocation l1, GeoLocation l2, double lng) Returns whether a direct Great Circle route crosses a meridian.static double
delta
(double hdg1, double hdg2) Calculates the delta between two headings.static String
format2D
(GeoLocation loc) Formats a geographic location as "longitude,latitude".static String
format3D
(GeoLocation loc, int altitude) Formats a geospatial location as "longitude,latitude,altitude".static String
format3D
(GeospaceLocation loc) Formats a geospatial location as "longitude,latitude,altitude".static String
formatFS9
(GeoLocation loc) Formats a location into a format suitable for inclusion in a Microsoft Flight Simulator 2004 flight plan.static String
formatFSElevation
(int elevation) Formats an elevation for Flight Simulator flight plansstatic String
formatFSX
(GeoLocation loc) Formats a location into a format suitable for inclusion in a Microsoft Flight Simulator X or Lockheed-Martin Prepar3D flight plan.static GeoLocation
fromCoordinate
(com.vividsolutions.jts.geom.Coordinate c) Converts a JTS Coordinate to a GeoLocation.static Collection
<GeoLocation> fromGeometry
(com.vividsolutions.jts.geom.Geometry geo) Parses a Geometry object and converts it into a Collection of GeoLocations.static Collection
<Collection<GeoLocation>> fromMultiPolygon
(com.vividsolutions.jts.geom.MultiPolygon mp) Parses a MultiPolygon object and converts each of its Geometries into a Collection of GeoLocations.static Tuple
<GeoLocation, GeoLocation> getBoundingBox
(Collection<? extends GeoLocation> locs) Returns a bounding box that contains all of the specified locations.static List
<GeoLocation> greatCircle
(GeoLocation start, GeoLocation end, int granularity) Creates a Great Circle route between two points.static boolean
isValid
(GeoLocation loc) Returns whether a location is valid (ie.static double
meridianLatitude
(GeoLocation l1, GeoLocation l2, double lng) Returns the latitude at which point a Greate Cirlce route intersects a meridian.static List
<GeoLocation> neighbors
(GeoLocation gl, Collection<? extends GeoLocation> points, int distance) Returns all the neighbors of a location within a certain distance.static double
normalize
(double degrees) "Normalizes" an angle by ensuring it is between 0 and 360.static GeoLocation
normalize
(double lat, double lng) "Normalizes" a geographic location by ensuring that the latitude is between -90 and 90 degrees, and the longitude is between -180 and 180 degrees.static GeoLocation
parseXACARS
(String pos) Parses XACARS-format geolocations.static GeoLocation
round
(GeoLocation loc, double precision) Rounds a GeoLocation down to a specific number of decimal places.static <T extends GeoLocation>
List<T> stripDetours
(Collection<T> entries, int minDetour) Strips out spurious waypoints from a route, that are at least a certain number of miles off the most direct route.static com.vividsolutions.jts.geom.Coordinate
toCoordinate
(GeoLocation loc) Converts a GeoLocation to a JTS Coordinate.static com.vividsolutions.jts.geom.Geometry
toGeometry
(Collection<GeoLocation> pts) Converts a Collection of GeoLocations into a Geometry object.static com.vividsolutions.jts.geom.MultiPolygon
Converts a Collection of GeoLocations into a Geometry object.static com.vividsolutions.jts.geom.LinearRing
toRing
(Collection<GeoLocation> pts) Converts a Collection of GeoLocations into a LinearRing object.
-
Method Details
-
greatCircle
Creates a Great Circle route between two points.- Parameters:
start
- the start locationend
- the end locationgranularity
- the maxmimum distance between points- Returns:
- a List of GeoPositions describing the Great Circle route
-
format2D
Formats a geographic location as "longitude,latitude".- Parameters:
loc
- the location- Returns:
- the formatted location string
-
format3D
Formats a geospatial location as "longitude,latitude,altitude". The altitude will be converted from feet to meters for Google Earth.- Parameters:
loc
- the locationaltitude
- the altitude in feet- Returns:
- the formatted location string
-
format3D
Formats a geospatial location as "longitude,latitude,altitude". The altitude will be converted from feet to meters for Google Earth.- Parameters:
loc
- the location- Returns:
- the formatted location string
-
formatFS9
Formats a location into a format suitable for inclusion in a Microsoft Flight Simulator 2004 flight plan.- Parameters:
loc
- the location- Returns:
- a formatted location
-
formatFSX
Formats a location into a format suitable for inclusion in a Microsoft Flight Simulator X or Lockheed-Martin Prepar3D flight plan.- Parameters:
loc
- the location- Returns:
- a formatted location
-
formatFSElevation
Formats an elevation for Flight Simulator flight plans- Parameters:
elevation
- the elevation in feet- Returns:
- the formatted elevation
-
normalize
public static double normalize(double degrees) "Normalizes" an angle by ensuring it is between 0 and 360.- Parameters:
degrees
- the angle in degrees- Returns:
- the normalized angle
-
delta
public static double delta(double hdg1, double hdg2) Calculates the delta between two headings.- Parameters:
hdg1
- the first heading in degreeshdg2
- the second heading in degrees- Returns:
- the delta in degrees
-
getBoundingBox
public static Tuple<GeoLocation, GeoLocation> getBoundingBox(Collection<? extends GeoLocation> locs) Returns a bounding box that contains all of the specified locations.- Parameters:
locs
- a Collection of GeoLocations- Returns:
- a Tuple with the northeast and southwest limits of the box
-
normalize
"Normalizes" a geographic location by ensuring that the latitude is between -90 and 90 degrees, and the longitude is between -180 and 180 degrees.- Parameters:
lat
- the latitudelng
- the longitude- Returns:
- the normalized location
-
bearingPointS
Determines the coordinates of a second point on a particular heading from the first, assuming a spherical globe.- Parameters:
p1
- the original pointdistance
- the distance in milesangle
- the angle in degrees- Returns:
- a GeoLocation
-
neighbors
public static List<GeoLocation> neighbors(GeoLocation gl, Collection<? extends GeoLocation> points, int distance) Returns all the neighbors of a location within a certain distance.- Parameters:
gl
- the pointpoints
- the locations to checkdistance
- the distance in miles- Returns:
- a Collection of GeoLocations
-
course
Calculates the course between two points.- Parameters:
l1
- the first GeoLocationl2
- the second GeoLocation- Returns:
- the initial course in degrees
-
meridianLatitude
Returns the latitude at which point a Greate Cirlce route intersects a meridian.- Parameters:
l1
- the first GeoLocationl2
- the second GeoLocationlng
- the longitude in degrees- Returns:
- the latitude in degrees
-
crossesMeridian
Returns whether a direct Great Circle route crosses a meridian.- Parameters:
l1
- the first GeoLocationl2
- the second GeoLocationlng
- the longitude in degrees- Returns:
- TRUE if the meridian is crossed on the most direct route, otherwise FALSE
-
stripDetours
Strips out spurious waypoints from a route, that are at least a certain number of miles off the most direct route.- Parameters:
entries
- a Collection of GeoLocation objectsminDetour
- the minimum- Returns:
- the stripped list of GeoLocations
-
parseXACARS
Parses XACARS-format geolocations.- Parameters:
pos
- an XACARS format geolocation- Returns:
- a GeoLocation
-
isValid
Returns whether a location is valid (ie. not 0/0/0)- Parameters:
loc
- a GeoLocation- Returns:
- TRUE if valid, otherwise FALSE
-
toRing
Converts a Collection of GeoLocations into a LinearRing object.- Parameters:
pts
- a Collection of GeoLocations- Returns:
- a LinearRing object
-
toGeometry
Converts a Collection of GeoLocations into a Geometry object.- Parameters:
pts
- a Collection of GeoLocations- Returns:
- a Geometry object
-
toMultiPolygon
public static com.vividsolutions.jts.geom.MultiPolygon toMultiPolygon(Collection<Collection<GeoLocation>> pts) Converts a Collection of GeoLocations into a Geometry object.- Parameters:
pts
- a Collection of GeoLocations- Returns:
- a Geometry object
-
fromGeometry
Parses a Geometry object and converts it into a Collection of GeoLocations.- Parameters:
geo
- a Geometry- Returns:
- a Collection of GeoLocations
-
fromMultiPolygon
public static Collection<Collection<GeoLocation>> fromMultiPolygon(com.vividsolutions.jts.geom.MultiPolygon mp) Parses a MultiPolygon object and converts each of its Geometries into a Collection of GeoLocations.- Parameters:
mp
- a MultiPolygon- Returns:
- a Collection of Collections of GeoLocations
-
round
Rounds a GeoLocation down to a specific number of decimal places.- Parameters:
loc
- a GeoLocationprecision
- the preicison amount- Returns:
- a GeoLocation
-
toCoordinate
Converts a GeoLocation to a JTS Coordinate.- Parameters:
loc
- a GeoLocation- Returns:
- a JTS Coordinate
-
fromCoordinate
Converts a JTS Coordinate to a GeoLocation.- Parameters:
c
- a Coordinate- Returns:
- a GeoLocation
-