public class TLcdLonLatCoord extends Object implements Serializable
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.Constructor and Description |
---|
TLcdLonLatCoord() |
Modifier and Type | Method and Description |
---|---|
static double |
differenceLonEast2West(double aLon1,
double aLon2)
Computes the difference |aLon2 - aLon1| by tracing
the sphere from East to West.
|
static double |
differenceLonWest2East(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 void |
eliminateNOnLon180SFCT(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 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.
|
static boolean |
equalLonLatPoint(ILcdPoint aPoint1,
ILcdPoint aPoint2)
Verify if two points are at the exact same location, taking into account longitude wrapping.
|
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.
|
static double |
normalizeLat(double aLat)
Normalizes a latitude ordinate.
|
static double |
normalizeLon(double aLon)
Normalizes a longitude ordinate to [-180, +180].
|
static double |
subtractLon(double aLon1,
double aLon2)
Subtracts aLon1 from aLon2 (aLon2 - aLon1),
taking into account the 180 degree meridian.
|
static String |
toDegMinSec(double aOrdinate)
Formats a longitude or latitude ordinate as a degrees/minutes/seconds String:
ddmmss.
|
static double |
toDoubleLat(String aString)
Parses a latitude
String into a latitude ordinate. |
static double |
toDoubleLon(String aString)
Parses a longitude
String into a longitude ordinate. |
static String |
toLatDegMinSec(double aOrdinate)
Formats a latitude ordinate as a degrees/minutes/seconds/hemisphere String:
ddmmss[NS].
|
static String |
toLonDegMinSec(double aOrdinate)
Formats a longitude ordinate as a degrees/minutes/seconds/length String:
dddmmss[EW].
|
public static String toDegMinSec(double aOrdinate)
aOrdinate
- the coordinate to be formatted.public static String toLatDegMinSec(double aOrdinate)
aOrdinate
- the latitude ordinate to be formatted.public static String toLonDegMinSec(double aOrdinate)
aOrdinate
- the longitude ordinate to be formatted.public static double toDoubleLat(String aString) throws ParseException
String
into a latitude ordinate.
The only format understood is <Deg><Min><Sec>[NS].
The String
must contain exactly 7 characters.
Examples:
021500N -> 2.25 521500N -> 52.25 521500S -> -52.25
aString
- the String to be parsed.ParseException
- if the String can't be parsed.public static double toDoubleLon(String aString) throws ParseException
String
into a longitude ordinate.
The only format understood is <Deg><Min><Sec>[EW].
The String
must contain exactly 8 characters.
Examples:
0081500E -> 8.25 0081500W -> -8.25
aString
- the String to be parsed.ParseException
- if the String can't be parsed.public static double normalizeLon(double aLon)
aLon
- the longitude in decimal degrees.public static double normalizeLat(double aLat)
aLat
- a latitude in decimal degrees.public static double subtractLon(double aLon1, double aLon2)
aLon1
- a longitude in decimal degrees,
-180.0 <= lon <= 180.0.aLon2
- a longitude in decimal degrees,
-180.0 <= lon <= 180.0.public static double differenceLonWest2East(double aLon1, double aLon2)
aLon1
- a longitude in degrees.aLon2
- a longitude in degrees.public static double differenceLonEast2West(double aLon1, double aLon2)
aLon1
- a longitude in degrees.aLon2
- a longitude in degrees.public static double[] eliminateOnLon180(double aLon1, double aLon2)
aLon1
- a longitude in decimal degrees,
-180.0 <= lon <= 180.0.aLon2
- a longitude in decimal degrees,
-180.0 <= lon <= 180.0.public static double[] eliminate3OnLon180(double aLon1, double aLon2, double aLon3)
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.public static void eliminateNOnLon180SFCT(double[] aLon)
public static boolean interacts2D(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2)
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 boundstrue
if they interact, false
otherwisepublic static boolean equalLonLatPoint(ILcdPoint aPoint1, ILcdPoint aPoint2)
aPoint1
- The first pointaPoint2
- The second pointtrue
if they are the same location, false
otherwisepublic static boolean equalLonLatPoint(double aLon1, double aLat1, double aZ1, double aLon2, double aLat2, double aZ2)
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 pointtrue
if they are the same location, false
otherwise