public class LatLon extends Coordinate
Modifier and Type | Field and Description |
---|---|
static java.text.DecimalFormat |
cDdFormatter |
static java.text.DecimalFormat |
cDdHighPecisionFormatter |
private static java.lang.String |
cDm00 |
private static java.lang.String |
cDm60 |
private static java.text.DecimalFormat |
cDmMinuteFormatter |
private static java.lang.String |
cDms00 |
private static java.lang.String |
cDms60 |
private static java.text.DecimalFormat |
cDmsMinuteFormatter |
private static java.text.DecimalFormat |
cDmsSecondFormatter |
static java.lang.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 java.lang.String |
NORTH |
static java.lang.String |
SOUTH |
static java.lang.String |
WEST |
static LatLon |
ZERO
The (0,0) coordinates.
|
x, y
Modifier | Constructor and Description |
---|---|
|
LatLon(double lat,
double lon)
Constructs a new
LatLon |
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 java.lang.String |
dm(double pCoordinate)
Replies the coordinate in degrees/minutes format
|
static java.lang.String |
dms(double pCoordinate)
Replies the coordinate in degrees/minutes/seconds format
|
boolean |
equals(java.lang.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(java.awt.geom.Area a)
Check if this is contained in given area or area is null.
|
boolean |
isOutSideWorld() |
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) |
double |
lat()
Returns the latitude, i.e., the north-south position in degrees.
|
java.lang.String |
latToString(CoordinateFormat d) |
double |
lon()
Returns the longitude, i.e., the east-west position in degrees.
|
java.lang.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.
|
java.lang.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.
|
java.lang.String |
toString() |
java.lang.String |
toStringCSV(java.lang.String separator)
Returns this lat/lon pair in human-readable format separated by
separator . |
computeHashCode, distance, distance, distanceSq, distanceSq, getX, getY, toBBox, toBBox
public static final double MAX_SERVER_PRECISION
public static final double MAX_SERVER_INV_PRECISION
public static final int MAX_SERVER_DIGITS
private static java.text.DecimalFormat cDmsMinuteFormatter
private static java.text.DecimalFormat cDmsSecondFormatter
private static java.text.DecimalFormat cDmMinuteFormatter
public static final java.text.DecimalFormat cDdFormatter
public static final java.text.DecimalFormat cDdHighPecisionFormatter
private static final java.lang.String cDms60
private static final java.lang.String cDms00
private static final java.lang.String cDm60
private static final java.lang.String cDm00
public static final java.lang.String SOUTH
public static final java.lang.String NORTH
public static final java.lang.String WEST
public static final java.lang.String EAST
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 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 java.lang.String dms(double pCoordinate)
pCoordinate
- The coordinate to convertpublic static java.lang.String dm(double pCoordinate)
pCoordinate
- The coordinate to convertpublic double lat()
public java.lang.String latToString(CoordinateFormat d)
public double lon()
public java.lang.String lonToString(CoordinateFormat d)
public boolean equalsEpsilon(LatLon other)
true
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 isIn(java.awt.geom.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 java.lang.String toDisplayString()
public java.lang.String toStringCSV(java.lang.String separator)
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 java.lang.String toString()
toString
in class java.lang.Object
public static double roundToOsmPrecision(double value)
public static double roundToOsmPrecisionStrict(double value)
roundToOsmPrecision(double)
, since the rounding error has been fixed.public LatLon getRoundedToOsmPrecision()
public LatLon getRoundedToOsmPrecisionStrict()
public int hashCode()
hashCode
in class Coordinate
public boolean equals(java.lang.Object obj)
equals
in class Coordinate