Package com.luciad.util
Class TLcdLonLatCoord
java.lang.Object
com.luciad.util.TLcdLonLatCoord
- All Implemented Interfaces:
Serializable
This utility class regroups a set of methods for converting latitude/longitude
coordinates into
String objects, and inversely, for parsing
String objects into latitude/longitude coordinates.
It also has some coordinate arithmetic methods and methods for normalizing coordinates.
All coordinates are expressed in decimal degrees.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubledifferenceLonEast2West(double aLon1, double aLon2) Computes the difference |aLon2 - aLon1| by tracing the sphere from East to West.static doubledifferenceLonWest2East(double aLon1, double aLon2) Computes the difference |aLon2 - aLon1| by tracing the sphere from West to East.static double[]eliminate3OnLon180(double aLon1, double aLon2, double aLon3) Transforms aLon1, aLon2 and aLon3 into three new longitudes, taking into account the 180 degree meridian.static voideliminateNOnLon180SFCT(double[] aLon) Eliminates the 180 degree meridian on an array of longitudes.static double[]eliminateOnLon180(double aLon1, double aLon2) Transforms aLon1 and aLon2 into two new longitudes, taking into account the 180 degree meridian.static booleanequalLonLatPoint(double aLon1, double aLat1, double aZ1, double aLon2, double aLat2, double aZ2) Verify if two points are at the exact same location, taking into account longitude wrapping.static booleanequalLonLatPoint(ILcdPoint aPoint1, ILcdPoint aPoint2) Verify if two points are at the exact same location, taking into account longitude wrapping.static booleaninteracts2D(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2) Check whether two bounds interact, taking into account longitude wrapping.static doublenormalizeLat(double aLat) Normalizes a latitude ordinate.static doublenormalizeLon(double aLon) Normalizes a longitude ordinate to [-180, +180].static doublesubtractLon(double aLon1, double aLon2) Subtracts aLon1 from aLon2 (aLon2 - aLon1), taking into account the 180 degree meridian.static StringtoDegMinSec(double aOrdinate) Formats a longitude or latitude ordinate as a degrees/minutes/seconds String: ddmmss.static doubletoDoubleLat(String aString) Parses a latitudeStringinto a latitude ordinate.static doubletoDoubleLon(String aString) Parses a longitudeStringinto a longitude ordinate.static StringtoLatDegMinSec(double aOrdinate) Formats a latitude ordinate as a degrees/minutes/seconds/hemisphere String: ddmmss[NS].static StringtoLonDegMinSec(double aOrdinate) Formats a longitude ordinate as a degrees/minutes/seconds/length String: dddmmss[EW].
-
Constructor Details
-
TLcdLonLatCoord
public TLcdLonLatCoord()
-
-
Method Details
-
toDegMinSec
Formats a longitude or latitude ordinate as a degrees/minutes/seconds String: ddmmss.- Parameters:
aOrdinate- the coordinate to be formatted.- Returns:
- the formatted String.
-
toLatDegMinSec
Formats a latitude ordinate as a degrees/minutes/seconds/hemisphere String: ddmmss[NS].- Parameters:
aOrdinate- the latitude ordinate to be formatted.- Returns:
- the formatted String.
-
toLonDegMinSec
Formats a longitude ordinate as a degrees/minutes/seconds/length String: dddmmss[EW].- Parameters:
aOrdinate- the longitude ordinate to be formatted.- Returns:
- the formatted String ("NaN" for Double.NAN ).
-
toDoubleLat
Parses a latitudeStringinto a latitude ordinate. The only format understood is <Deg><Min><Sec>[NS]. TheStringmust contain exactly 7 characters. Examples:021500N -> 2.25 521500N -> 52.25 521500S -> -52.25
- Parameters:
aString- the String to be parsed.- Returns:
- the parsed latitude ordinate.
- Throws:
ParseException- if the String can't be parsed.
-
toDoubleLon
Parses a longitudeStringinto a longitude ordinate. The only format understood is <Deg><Min><Sec>[EW]. TheStringmust contain exactly 8 characters. Examples:0081500E -> 8.25 0081500W -> -8.25
- Parameters:
aString- the String to be parsed.- Returns:
- the parsed longitude ordinate.
- Throws:
ParseException- if the String can't be parsed.
-
normalizeLon
public static double normalizeLon(double aLon) Normalizes a longitude ordinate to [-180, +180].- Parameters:
aLon- the longitude in decimal degrees.- Returns:
- the longitude, normalized to lie between -180.0 and 180.0
-
normalizeLat
public static double normalizeLat(double aLat) Normalizes a latitude ordinate.- Parameters:
aLat- a latitude in decimal degrees.- Returns:
- the latitude, normalized to lie between -90.0 and 90.0 (by clipping to these bounds).
-
subtractLon
public static double subtractLon(double aLon1, double aLon2) Subtracts aLon1 from aLon2 (aLon2 - aLon1), taking into account the 180 degree meridian.- Parameters:
aLon1- a longitude in decimal degrees, -180.0 <= lon <= 180.0.aLon2- a longitude in decimal degrees, -180.0 <= lon <= 180.0.- Returns:
- the longitude difference between aLon1 and aLon2, such that its value lies between -180.0 and 180.0.
-
differenceLonWest2East
public static double differenceLonWest2East(double aLon1, double aLon2) Computes the difference |aLon2 - aLon1| by tracing the sphere from West to East. The result is a value between 0 and 360 degrees.- Parameters:
aLon1- a longitude in degrees.aLon2- a longitude in degrees.- Returns:
- the difference between aLon1 and aLon2.
-
differenceLonEast2West
public static double differenceLonEast2West(double aLon1, double aLon2) Computes the difference |aLon2 - aLon1| by tracing the sphere from East to West. The result is a value between 0 and 360 degrees.- Parameters:
aLon1- a longitude in degrees.aLon2- a longitude in degrees.- Returns:
- the difference between aLon1 and aLon2.
-
eliminateOnLon180
public static double[] eliminateOnLon180(double aLon1, double aLon2) Transforms aLon1 and aLon2 into two new longitudes, taking into account the 180 degree meridian.- Parameters:
aLon1- a longitude in decimal degrees, -180.0 <= lon <= 180.0.aLon2- a longitude in decimal degrees, -180.0 <= lon <= 180.0.- Returns:
- two longitudes lon[0] and lon[1], such that (aLon2 - aLon1) is between -180.0 and 180.0, with lon[0] corresponding to aLon1 and lon[1] corresponding to aLon2.
-
eliminate3OnLon180
public static double[] eliminate3OnLon180(double aLon1, double aLon2, double aLon3) Transforms aLon1, aLon2 and aLon3 into three new longitudes, taking into account the 180 degree meridian.- Parameters:
aLon1- a longitude in decimal degrees, -180.0 <= lon <= 180.0.aLon2- a longitude in decimal degrees, -180.0 <= lon <= 180.0.aLon3- a longitude in decimal degrees, -180.0 <= lon <= 180.0.- Returns:
- three longitudes lon[0], lon[1] and lon[2], such that (aLon2 - aLon1) lies between -180.0 and 180.0 and (aLon3 - aLon2) lies between -180.0 and 180.0, with lon[0] corresponding to aLon1, lon[1] corresponding to aLon2 and lon[2] corresponding to aLon3.
-
eliminateNOnLon180SFCT
public static void eliminateNOnLon180SFCT(double[] aLon) Eliminates the 180 degree meridian on an array of longitudes. The calculation is done by side-effect (note the suffix SFCT in the name of the method), i.e., the array aLon passed as a parameter is changed. -
interacts2D
public static boolean interacts2D(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2) Check whether two bounds interact, taking into account longitude wrapping.- Parameters:
aLon1- Longitude of the first bounds' positionaLat1- Latitude of the first bounds' positionaWidth1- Width of the first boundsaHeight1- Height of the first boundsaLon2- Longitude of the second bounds' positionaLat2- Latitude of the second bounds' positionaWidth2- Width of the second boundsaHeight2- Height of the second bounds- Returns:
trueif they interact,falseotherwise
-
equalLonLatPoint
Verify if two points are at the exact same location, taking into account longitude wrapping.- Parameters:
aPoint1- The first pointaPoint2- The second point- Returns:
trueif they are the same location,falseotherwise
-
equalLonLatPoint
public static boolean equalLonLatPoint(double aLon1, double aLat1, double aZ1, double aLon2, double aLat2, double aZ2) Verify if two points are at the exact same location, taking into account longitude wrapping.- Parameters:
aLon1- Longitude of the first pointaLat1- Latitude of the first pointaZ1- Height of the first pointaLon2- Longitude of the second pointaLat2- Latitude of the second pointaZ2- Height of the second point- Returns:
trueif they are the same location,falseotherwise
-