public class Position extends Object implements Message, Serializable
| Modifier and Type | Field and Description |
|---|---|
static MessageSerializer<Position> |
SERIALIZER |
| Modifier and Type | Method and Description |
|---|---|
static Position |
create(double latitude,
double longitude)
Creates a new position from the specified latitude and longitude.
|
boolean |
equals(Object other)
Equals method
|
boolean |
equals(Position other) |
static Position |
fromBinary(Binary b)
Returns a position from a 64 bit byte array encoded as decimal degress with 7 decimal places.
|
static Position |
fromPackedLong(long l) |
double |
geodesicDistanceTo(Position other)
Returns the great circle distance to the specified position.
|
double |
geodesicFinalBearingTo(Position other)
Calculate final bearing for great circle route to location using Thaddeus Vincenty's inverse formula.
|
double |
geodesicInitialBearingTo(Position other)
Calculate initial bearing for great circle route to location using Thaddeus Vincenty's inverse formula.
|
long |
getCell(double degress) |
int |
getCellInt(double degress) |
double |
getLatitude()
Returns the latitude part of this position.
|
String |
getLatitudeAsString() |
double |
getLongitude()
Returns the longitude part of this position.
|
String |
getLongitudeAsString() |
int |
hashCode()
Hash code for the location
|
Position |
immutable()
Returns an immutable copy of this message.
|
static boolean |
isValid(double latitude,
double longitude) |
static Position |
random()
Returns a random valid position.
|
static Position |
random(Random rnd)
Returns a random valid position.
|
double |
rhumbLineBearingTo(Position position)
Calculates the rhumb line bearing to the specified position
|
double |
rhumbLineDistanceTo(Position other) |
Binary |
toBinary()
Returns a 64 bit representation of this position.
|
String |
toJSON()
Returns a JSON representation of this message
|
long |
toPackedLong()
Packs the position into a long (losing some precision).
|
String |
toString() |
String |
toStringDegrees() |
static double |
verifyLatitude(double latitude)
Verify that latitude is within the interval [-90:90].
|
static double |
verifyLongitude(double longitude)
Verify that longitude is within the interval [-180:180].
|
Position |
withLatitude(double latitude)
Returns a new position with the same longitude as this position but with the specified latitude.
|
Position |
withLongitude(double longitude)
Returns a new position with the same latitude as this position but with the specified longitude.
|
PositionTime |
withTime(long time)
Returns a new position time with this position added with the current time.
|
public static final MessageSerializer<Position> SERIALIZER
public boolean equals(Position other)
public double geodesicDistanceTo(Position other)
other - the position to calculate the distance frompublic double geodesicFinalBearingTo(Position other)
other - the position to calculate the bearing frompublic double geodesicInitialBearingTo(Position other)
other - the position to calculate the bearing frompublic long getCell(double degress)
public int getCellInt(double degress)
public double getLatitude()
public String getLatitudeAsString()
public double getLongitude()
public String getLongitudeAsString()
public Position immutable()
public double rhumbLineBearingTo(Position position)
position - the positionpublic double rhumbLineDistanceTo(Position other)
public String toJSON()
public long toPackedLong()
fromPackedLong(long)public String toStringDegrees()
public Position withLatitude(double latitude)
latitude - the new latitude for the new positionpublic Position withLongitude(double longitude)
longitude - the new longitude for the new positionpublic PositionTime withTime(long time)
time - the time of the new position time objectpublic static Position create(double latitude, double longitude)
latitude - the latitudelongitude - the longitudeIllegalArgumentException - if thepublic static Position fromBinary(Binary b)
public Binary toBinary()
public static Position fromPackedLong(long l)
public static boolean isValid(double latitude,
double longitude)
latitude - the latitudelongitude - the longitudepublic static Position random()
public static Position random(Random rnd)
rnd - the source of randomnesspublic static double verifyLatitude(double latitude)
latitude - the latitude to verifyIllegalArgumentException - When latitude is invalidpublic static double verifyLongitude(double longitude)
longitude - the longitude to verifyIllegalArgumentException - When longitude is invalidCopyright © 2012–2015 Danish Maritime Authority. All rights reserved.