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()andlon()need to return a NaN value andisLatLonKnown()needs to return false.Whether the coordinates are immutable or not is implementation specific.
- Since:
- 12161
-
-
Field Summary
Fields Modifier and Type Field Description static doubleMAX_SERVER_PRECISIONMinimum difference in location to not be represented as the same position.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default doublebearing(ILatLon other)Returns 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 booleanisLatLonKnown()Determines 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 Detail
-
MAX_SERVER_PRECISION
static final double MAX_SERVER_PRECISION
Minimum difference in location to not be represented as the same position. The API returns 7 decimals.- See Also:
- Constant Field Values
-
-
Method Detail
-
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
default boolean isLatLonKnown()
Determines if this object has valid coordinates.- Returns:
trueif this object has valid coordinates
-
getEastNorth
default EastNorth getEastNorth(Projecting projecting)
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
default boolean equalsEpsilon(ILatLon other)
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
default boolean equalsEpsilon(ILatLon other, double precision)
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
default double greatCircleDistance(ILatLon other)
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
default double bearing(ILatLon other)
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
default ILatLon interpolate(ILatLon ll2, double proportion)
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
default double distanceSq(double lon, double lat)
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
default double distanceSq(ILatLon other)
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
-
-