public class LatLon extends Coordinate
Modifier and Type | Field and Description |
---|---|
static DecimalFormat |
cDdFormatter |
static DecimalFormat |
cDdHighPecisionFormatter |
private static String |
cDm00 |
private static String |
cDm60 |
private static DecimalFormat |
cDmMinuteFormatter |
private static String |
cDms00 |
private static String |
cDms60 |
private static DecimalFormat |
cDmsMinuteFormatter |
private static DecimalFormat |
cDmsSecondFormatter |
static String |
EAST |
static int |
MAX_SERVER_DIGITS |
static double |
MAX_SERVER_INV_PRECISION |
static double |
MAX_SERVER_PRECISION
Minimum difference in location to not be represented as the same position.
|
static String |
NORTH |
private static long |
serialVersionUID |
static String |
SOUTH |
static String |
WEST |
static LatLon |
ZERO
The (0,0) coordinates.
|
x, y
Modifier | Constructor and Description |
---|---|
|
LatLon(double lat,
double lon)
Constructs a new
LatLon |
|
LatLon(ICoordinate coor) |
protected |
LatLon(LatLon coor) |
Modifier and Type | Method and Description |
---|---|
double |
distance(LatLon ll)
Returns the euclidean distance from this
LatLon to a specified LatLon . |
double |
distanceSq(LatLon ll)
Returns the square of the euclidean distance from this
LatLon to a specified LatLon . |
static String |
dm(double pCoordinate)
Replies the coordinate in degrees/minutes format
|
static String |
dms(double pCoordinate)
Replies the coordinate in degrees/minutes/seconds format
|
boolean |
equals(Object obj) |
boolean |
equalsEpsilon(LatLon other) |
LatLon |
getCenter(LatLon ll2) |
LatLon |
getRoundedToOsmPrecision()
Replies a clone of this lat LatLon, rounded to OSM precisions, i.e.
|
LatLon |
getRoundedToOsmPrecisionStrict()
Replies a clone of this lat LatLon, rounded to OSM precisions, i.e.
|
double |
greatCircleDistance(LatLon other)
Computes the distance between this lat/lon and another point on the earth.
|
int |
hashCode() |
double |
heading(LatLon other)
Returns the heading, in radians, that you have to use to get from this lat/lon to another.
|
LatLon |
interpolate(LatLon ll2,
double proportion) |
boolean |
isIn(Area a)
Check if this is contained in given area or area is null.
|
boolean |
isOutSideWorld()
Determines if this lat/lon is outside of the world
|
boolean |
isValid()
Replies true if lat is in the range [-90,90] and lon is in the range [-180,180]
|
static boolean |
isValidLat(double lat)
Replies true if lat is in the range [-90,90]
|
static boolean |
isValidLon(double lon)
Replies true if lon is in the range [-180,180]
|
boolean |
isWithin(Bounds b)
Determines if this lat/lon is within the given bounding box.
|
double |
lat()
Returns the latitude, i.e., the north-south position in degrees.
|
String |
latToString(CoordinateFormat d) |
double |
lon()
Returns the longitude, i.e., the east-west position in degrees.
|
String |
lonToString(CoordinateFormat d) |
static double |
roundToOsmPrecision(double value)
Returns the value rounded to OSM precisions, i.e.
|
static double |
roundToOsmPrecisionStrict(double value)
Returns the value rounded to OSM precision.
|
ICoordinate |
toCoordinate() |
String |
toDisplayString()
Returns this lat/lon pair in human-readable format.
|
static double |
toIntervalLat(double value) |
static double |
toIntervalLon(double value)
Returns a valid OSM longitude [-180,+180] for the given extended longitude value.
|
String |
toString() |
String |
toStringCSV(String separator)
Returns this lat/lon pair in human-readable format separated by
separator . |
computeHashCode, distance, distance, distanceSq, distanceSq, getX, getY, toBBox, toBBox
private static final long serialVersionUID
public static final double MAX_SERVER_PRECISION
public static final double MAX_SERVER_INV_PRECISION
public static final int MAX_SERVER_DIGITS
private static DecimalFormat cDmsMinuteFormatter
private static DecimalFormat cDmsSecondFormatter
private static DecimalFormat cDmMinuteFormatter
public static final DecimalFormat cDdFormatter
public static final DecimalFormat cDdHighPecisionFormatter
public LatLon(double lat, double lon)
LatLon
lat
- the latitude, i.e., the north-south position in degreeslon
- the longitude, i.e., the east-west position in degreespublic LatLon(ICoordinate coor)
public static boolean isValidLat(double lat)
lat
- the latitudepublic static boolean isValidLon(double lon)
lon
- the longitudepublic boolean isValid()
public static double toIntervalLat(double value)
public static double toIntervalLon(double value)
value
- A longitude value not restricted to the [-180,+180] range.public static String dms(double pCoordinate)
pCoordinate
- The coordinate to convertpublic static String dm(double pCoordinate)
pCoordinate
- The coordinate to convertpublic double lat()
public String latToString(CoordinateFormat d)
public double lon()
public String lonToString(CoordinateFormat d)
public boolean equalsEpsilon(LatLon other)
other
- other lat/lontrue
if the other point has almost the same lat/lon
values, only differing by no more than 1 / MAX_SERVER_PRECISION
.public boolean isOutSideWorld()
true
, if the coordinate is outside the world, compared by using lat/lon.public boolean isWithin(Bounds b)
b
- bounding boxtrue
if this is within the given bounding box.public boolean isIn(Area a)
a
- Areatrue
if this is contained in given area or area is null.public double greatCircleDistance(LatLon other)
other
- the other point.public double heading(LatLon other)
other
- the "destination" positionpublic String toDisplayString()
public String toStringCSV(String separator)
separator
.separator
- values separator"1.23456[separator]2.34567"
public LatLon interpolate(LatLon ll2, double proportion)
public double distance(LatLon ll)
LatLon
to a specified LatLon
.ll
- the specified coordinate to be measured against this LatLon
LatLon
to a specified LatLon
public double distanceSq(LatLon ll)
LatLon
to a specified LatLon
.ll
- the specified coordinate to be measured against this LatLon
LatLon
to a specified LatLon
public static double roundToOsmPrecision(double value)
MAX_SERVER_PRECISION
.value
- lat/lon valuepublic static double roundToOsmPrecisionStrict(double value)
roundToOsmPrecision(double)
, since the rounding error has been fixed.value
- lat/lon valuepublic LatLon getRoundedToOsmPrecision()
public LatLon getRoundedToOsmPrecisionStrict()
public int hashCode()
hashCode
in class Coordinate
public boolean equals(Object obj)
equals
in class Coordinate
public ICoordinate toCoordinate()