Package org.openstreetmap.josm.data.coor
Class LatLon
java.lang.Object
org.openstreetmap.josm.data.coor.Coordinate
org.openstreetmap.josm.data.coor.LatLon
- All Implemented Interfaces:
Serializable,ILatLon
- Direct Known Subclasses:
CachedLatLon
LatLon are unprojected latitude / longitude coordinates.
Latitude specifies the north-south position in degrees where valid values are in the [-90,90] and positive values specify positions north of the equator.
Longitude specifies the east-west position in degrees where valid values are in the [-180,180] and positive values specify positions east of the prime meridian.
This class is immutable.
Latitude specifies the north-south position in degrees where valid values are in the [-90,90] and positive values specify positions north of the equator.
Longitude specifies the east-west position in degrees where valid values are in the [-180,180] and positive values specify positions east of the prime meridian.
This class is immutable.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DecimalFormatThe normal number format for server precision coordinatesstatic final DecimalFormatThe number format used for high precision coordinatesstatic final doubleThe inverse of the server precisionstatic final doubleMinimum difference in location to not be represented as the same position.static final LatLonNorth pole.private static final longstatic final LatLonSouth pole.static final LatLonThe (0,0) coordinates.Fields inherited from class org.openstreetmap.josm.data.coor.Coordinate
x, y -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the euclidean distance from thisLatLonto a specifiedLatLon.doubledistanceSq(LatLon ll) Returns the square of the euclidean distance from thisLatLonto a specifiedLatLon.booleanGet the center between two lat/lon pointsReplies a clone of this lat LatLon, rounded to OSM precisions, i.e.inthashCode()interpolate(LatLon ll2, double proportion) Interpolate between this and a other latlon.booleanCheck if this is contained in given area or area is null.booleanisValid()Replies true if lat is in the range [-90,90] and lon is in the range [-180,180]static booleanisValidLat(double lat) Replies true if lat is in the range [-90,90]static booleanisValidLon(double lon) Replies true if lon is in the range [-180,180]booleanDetermines if this lat/lon is within the given bounding box.doublelat()Returns the latitude, i.e., the north-south position in degrees.doublelon()Returns the longitude, i.e., the east-west position in degrees.static doublenormalizeLon(double lon) Make sure longitude value is within[-180, 180]range.static doubleroundToOsmPrecision(double value) Returns the value rounded to OSM precisions, i.e.Returns this lat/lon pair in human-readable format.static doubletoIntervalLat(double value) Clamp the lat value to be inside the world.static doubletoIntervalLon(double value) Returns a valid OSM longitude [-180,+180] for the given extended longitude value.toString()Methods inherited from class org.openstreetmap.josm.data.coor.Coordinate
distance, distance, distanceSq, distanceSq, getX, getYMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.data.coor.ILatLon
bearing, distanceSq, distanceSq, equalsEpsilon, equalsEpsilon, getEastNorth, greatCircleDistance, interpolate, isLatLonKnown
-
Field Details
-
serialVersionUID
- See Also:
-
MAX_SERVER_PRECISION
Minimum difference in location to not be represented as the same position. The API returns 7 decimals.- See Also:
-
MAX_SERVER_INV_PRECISION
The inverse of the server precision- See Also:
-
ZERO
The (0,0) coordinates.- Since:
- 6178
-
NORTH_POLE
North pole. -
SOUTH_POLE
South pole. -
cDdFormatter
The normal number format for server precision coordinates -
cDdHighPrecisionFormatter
The number format used for high precision coordinates
-
-
Constructor Details
-
LatLon
Constructs a new object representing the given latitude/longitude.- Parameters:
lat- the latitude, i.e., the north-south position in degreeslon- the longitude, i.e., the east-west position in degrees
-
LatLon
Creates a new LatLon object for the given coordinate- Parameters:
coor- The coordinates to copy from.
-
-
Method Details
-
isValidLat
Replies true if lat is in the range [-90,90]- Parameters:
lat- the latitude- Returns:
- true if lat is in the range [-90,90]
-
isValidLon
Replies true if lon is in the range [-180,180]- Parameters:
lon- the longitude- Returns:
- true if lon is in the range [-180,180]
-
normalizeLon
Make sure longitude value is within[-180, 180]range.- Parameters:
lon- the longitude in degrees- Returns:
- lon plus/minus multiples of
360, as needed to get in[-180, 180]range
-
isValid
Replies true if lat is in the range [-90,90] and lon is in the range [-180,180]- Returns:
- true if lat is in the range [-90,90] and lon is in the range [-180,180]
-
toIntervalLat
Clamp the lat value to be inside the world.- Parameters:
value- The value- Returns:
- The value clamped to the world.
-
toIntervalLon
Returns a valid OSM longitude [-180,+180] for the given extended longitude value. For example, a value of -181 will return +179, a value of +181 will return -179.- Parameters:
value- A longitude value not restricted to the [-180,+180] range.- Returns:
- a valid OSM longitude [-180,+180]
-
lat
Description copied from interface:ILatLonReturns the latitude, i.e., the north-south position in degrees.- Specified by:
latin interfaceILatLon- Returns:
- the latitude or NaN if
ILatLon.isLatLonKnown()returns false
-
lon
Description copied from interface:ILatLonReturns the longitude, i.e., the east-west position in degrees.- Specified by:
lonin interfaceILatLon- Returns:
- the longitude or NaN if
ILatLon.isLatLonKnown()returns false
-
isWithin
Determines if this lat/lon is within the given bounding box.- Parameters:
b- bounding box- Returns:
trueif this is within the given bounding box.
-
isIn
Check if this is contained in given area or area is null.- Parameters:
a- Area- Returns:
trueif this is contained in given area or area is null.
-
toDisplayString
Returns this lat/lon pair in human-readable format.- Returns:
- String in the format "lat=1.23456 deg, lon=2.34567 deg"
-
interpolate
Interpolate between this and a other latlon. If you don't care about the return type, useILatLon.interpolate(ILatLon, double)instead.- Parameters:
ll2- The other lat/lon objectproportion- The proportion to interpolate- Returns:
- a new latlon at this position if proportion is 0, at the other position it proportion is 1 and linearly interpolated otherwise.
-
getCenter
Get the center between two lat/lon points- Parameters:
ll2- The otherLatLon- Returns:
- The center at the average coordinates of the two points. Does not take the 180° meridian into account.
-
distance
Returns the euclidean distance from thisLatLonto a specifiedLatLon.- Parameters:
ll- the specified coordinate to be measured against thisLatLon- Returns:
- the euclidean distance from this
LatLonto a specifiedLatLon - Since:
- 6166
-
distanceSq
Returns the square of the euclidean distance from thisLatLonto a specifiedLatLon.- Parameters:
ll- the specified coordinate to be measured against thisLatLon- Returns:
- the square of the euclidean distance from this
LatLonto a specifiedLatLon - Since:
- 6166
-
toString
-
roundToOsmPrecision
Returns the value rounded to OSM precisions, i.e. toMAX_SERVER_PRECISION.- Parameters:
value- lat/lon value- Returns:
- rounded value
-
getRoundedToOsmPrecision
Replies a clone of this lat LatLon, rounded to OSM precisions, i.e. toMAX_SERVER_PRECISION- Returns:
- a clone of this lat LatLon
-
hashCode
- Overrides:
hashCodein classCoordinate
-
equals
- Overrides:
equalsin classCoordinate
-