Package org.openstreetmap.josm.data.coor
Interface ILatLon
- All Known Subinterfaces:
INode
- All Known Implementing Classes:
AudioMarker,ButtonMarker,CachedLatLon,ImageMarker,LatLon,Marker,Node,NodeData,PlayHeadMarker,TileZXY,VectorNode,WayPoint,WebMarker
public interface ILatLon
This interface represents a coordinate in LatLon space.
It provides methods to get the coordinates. The coordinates may be unknown.
In this case, both lat() and lon() need to return a NaN value and isLatLonKnown() needs to return false.
Whether the coordinates are immutable or not is implementation specific.
- Since:
- 12161
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleMinimum difference in location to not be represented as the same position. -
Method Summary
Modifier and TypeMethodDescriptiondefault doubleReturns bearing from this point to another.default doubledistanceSq(double lon, double lat) Returns the square of euclidean distance from thisCoordinateto a specified coordinate.default doubledistanceSq(ILatLon other) Returns the euclidean distance from thisILatLonto a specifiedILatLon.default booleanequalsEpsilon(ILatLon other) Determines if the other point has almost the same lat/lon values.default booleanequalsEpsilon(ILatLon other, double precision) Determines if the other point has almost the same lat/lon values.default EastNorthgetEastNorth(Projecting projecting) Replies the projected east/north coordinates.default doublegreatCircleDistance(ILatLon other) Computes the distance between this lat/lon and another point on the earth.default ILatLoninterpolate(ILatLon ll2, double proportion) Does a linear interpolation between two ILatLon instances.default booleanDetermines if this object has valid coordinates.doublelat()Returns the latitude, i.e., the north-south position in degrees.doublelon()Returns the longitude, i.e., the east-west position in degrees.
-
Field Details
-
MAX_SERVER_PRECISION
Minimum difference in location to not be represented as the same position. The API returns 7 decimals.- See Also:
-
-
Method Details
-
lon
double lon()Returns the longitude, i.e., the east-west position in degrees.- Returns:
- the longitude or NaN if
isLatLonKnown()returns false
-
lat
double lat()Returns the latitude, i.e., the north-south position in degrees.- Returns:
- the latitude or NaN if
isLatLonKnown()returns false
-
isLatLonKnown
Determines if this object has valid coordinates.- Returns:
trueif this object has valid coordinates
-
getEastNorth
Replies the projected east/north coordinates.The result of the last conversion may be cached. Null is returned in case this object is invalid.
- Parameters:
projecting- The projection to use.- Returns:
- The projected east/north coordinates
- Since:
- 10827
-
equalsEpsilon
Determines if the other point has almost the same lat/lon values.- Parameters:
other- other lat/lon- Returns:
trueif the other point has almost the same lat/lon values, only differing by no more than 1 /MAX_SERVER_PRECISION.- Since:
- 18464
-
equalsEpsilon
Determines if the other point has almost the same lat/lon values.- Parameters:
other- other lat/lonprecision- The precision to use- Returns:
trueif the other point has almost the same lat/lon values, only differing by no more than 1 / precision.- Since:
- 18464
-
greatCircleDistance
Computes the distance between this lat/lon and another point on the earth. Uses Haversine formula.- Parameters:
other- the other point.- Returns:
- distance in metres.
- Since:
- 18494
-
bearing
Returns bearing from this point to another. Angle starts from north and increases clockwise, PI/2 means east. Please note that reverse bearing (from other point to this point) should NOT be calculated from return value of this method, because great circle path between the two points have different bearings at each position. To get bearing from another point to this point call other.bearing(this)- Parameters:
other- the "destination" position- Returns:
- heading in radians in the range 0 <= hd < 2*PI
- Since:
- 18494
-
interpolate
Does a linear interpolation between two ILatLon instances.- Parameters:
ll2- The other ILatLon instance.proportion- The proportion the other instance influences the result.- Returns:
- The new
ILatLonposition. - Since:
- 18589
-
distanceSq
Returns the square of euclidean distance from thisCoordinateto a specified coordinate.- Parameters:
lon- the X coordinate of the specified point to be measured against thisCoordinatelat- the Y coordinate of the specified point to be measured against thisCoordinate- Returns:
- the square of the euclidean distance from this
Coordinateto a specified coordinate - Since:
- 18589
-
distanceSq
Returns the euclidean distance from thisILatLonto a specifiedILatLon.- Parameters:
other- the specified coordinate to be measured against thisILatLon- Returns:
- the euclidean distance from this
ILatLonto a specifiedILatLon - Since:
- 18589
-