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 double
MAX_SERVER_PRECISION
Minimum 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 double
bearing(ILatLon other)
Returns bearing from this point to another.default double
distanceSq(double lon, double lat)
Returns the square of euclidean distance from thisCoordinate
to a specified coordinate.default double
distanceSq(ILatLon other)
Returns the euclidean distance from thisILatLon
to a specifiedILatLon
.default boolean
equalsEpsilon(ILatLon other)
Determines if the other point has almost the same lat/lon values.default boolean
equalsEpsilon(ILatLon other, double precision)
Determines if the other point has almost the same lat/lon values.default EastNorth
getEastNorth(Projecting projecting)
Replies the projected east/north coordinates.default double
greatCircleDistance(ILatLon other)
Computes the distance between this lat/lon and another point on the earth.default ILatLon
interpolate(ILatLon ll2, double proportion)
Does a linear interpolation between two ILatLon instances.default boolean
isLatLonKnown()
Determines if this object has valid coordinates.double
lat()
Returns the latitude, i.e., the north-south position in degrees.double
lon()
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:
true
if 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:
true
if the other point has almost the same lat/lon values, only differing by no more than 1 /MAX_SERVER_PRECISION
.- Since:
- 18464 (extracted from
LatLon
)
-
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:
true
if the other point has almost the same lat/lon values, only differing by no more than 1 / precision.- Since:
- 18464 (extracted from
LatLon
)
-
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 (extracted from
LatLon
)
-
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 (extracted from
LatLon
, added in 9796)
-
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
ILatLon
position. - Since:
- 18589
-
distanceSq
default double distanceSq(double lon, double lat)
Returns the square of euclidean distance from thisCoordinate
to a specified coordinate.- Parameters:
lon
- the X coordinate of the specified point to be measured against thisCoordinate
lat
- the Y coordinate of the specified point to be measured against thisCoordinate
- Returns:
- the square of the euclidean distance from this
Coordinate
to a specified coordinate - Since:
- 18589
-
distanceSq
default double distanceSq(ILatLon other)
Returns the euclidean distance from thisILatLon
to a specifiedILatLon
.- Parameters:
other
- the specified coordinate to be measured against thisILatLon
- Returns:
- the euclidean distance from this
ILatLon
to a specifiedILatLon
- Since:
- 18589
-
-