Package org.osgi.util.position
Class Position
- java.lang.Object
-
- org.osgi.util.position.Position
-
public class Position extends java.lang.ObjectPosition represents a geographic location, based on the WGS84 System (World Geodetic System 1984).The
org.osgi.util.measurement.Measurementclass is used to represent the values that make up a position.A given position object may lack any of it's components, i.e. the altitude may not be known. Such missing values will be represented by null.
Position does not override the implementation of either equals() or hashCode() because it is not clear how missing values should be handled. It is up to the user of a position to determine how best to compare two position objects. A
Positionobject is immutable.
-
-
Field Summary
Fields Modifier and Type Field Description private Measurementaltitudeprivate static doubleLAT_RANGEprivate Measurementlatitudeprivate static doubleLON_RANGEprivate Measurementlongitudeprivate Measurementspeedprivate Measurementtrackprivate static doubleTRACK_RANGE
-
Constructor Summary
Constructors Constructor Description Position(Measurement lat, Measurement lon, Measurement alt, Measurement speed, Measurement track)Constructs aPositionobject with the given values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MeasurementgetAltitude()Returns the altitude of this position in meters.MeasurementgetLatitude()Returns the latitude of this position in radians.MeasurementgetLongitude()Returns the longitude of this position in radians.MeasurementgetSpeed()Returns the ground speed of this position in meters per second.MeasurementgetTrack()Returns the track of this position in radians as a compass heading.private static doublenormalize(double value, double range)This function normalizes the a value according to a range.
-
-
-
Field Detail
-
altitude
private final Measurement altitude
-
longitude
private final Measurement longitude
-
latitude
private final Measurement latitude
-
speed
private final Measurement speed
-
track
private final Measurement track
-
LON_RANGE
private static final double LON_RANGE
- See Also:
- Constant Field Values
-
LAT_RANGE
private static final double LAT_RANGE
- See Also:
- Constant Field Values
-
TRACK_RANGE
private static final double TRACK_RANGE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Position
public Position(Measurement lat, Measurement lon, Measurement alt, Measurement speed, Measurement track)
Constructs aPositionobject with the given values.- Parameters:
lat- aMeasurementobject specifying the latitude in radians, or nulllon- aMeasurementobject specifying the longitude in radians, or nullalt- aMeasurementobject specifying the altitude in meters, or nullspeed- aMeasurementobject specifying the speed in meters per second, or nulltrack- aMeasurementobject specifying the track in radians, or null
-
-
Method Detail
-
getAltitude
public Measurement getAltitude()
Returns the altitude of this position in meters.- Returns:
- a
Measurementobject inUnit.mrepresenting the altitude in meters above the ellipsoidnullif the altitude is not known.
-
getLongitude
public Measurement getLongitude()
Returns the longitude of this position in radians.- Returns:
- a
Measurementobject inUnit.radrepresenting the longitude, ornullif the longitude is not known.
-
getLatitude
public Measurement getLatitude()
Returns the latitude of this position in radians.- Returns:
- a
Measurementobject inUnit.radrepresenting the latitude, ornullif the latitude is not known..
-
getSpeed
public Measurement getSpeed()
Returns the ground speed of this position in meters per second.- Returns:
- a
Measurementobject inUnit.m_srepresenting the speed, ornullif the speed is not known..
-
getTrack
public Measurement getTrack()
Returns the track of this position in radians as a compass heading. The track is the extrapolation of previous previously measured positions to a future position.- Returns:
- a
Measurementobject inUnit.radrepresenting the track, ornullif the track is not known..
-
normalize
private static double normalize(double value, double range)This function normalizes the a value according to a range. This is not simple modulo (as I thought when I started), but requires some special handling. For positive numbers we subtract 2*range from the number so that end up between -/+ range. For negative numbers we add this value. For example, if the value is 270 and the range is +/- 180. Then sign=1 so the (int) factor becomes 270+180/360 = 1. This means that 270-360=-90 is the result. (degrees are only used to make it easier to understand, this function is agnostic for radians/degrees). The result will be in [range,range> The algorithm is not very fast, but it handling the [> ranges made it very messy using integer arithmetic, and this is very readable. Note that it is highly unlikely that this method is called in normal situations. Normally input values to position are already normalized because they come from a GPS. And this is much more readable.- Parameters:
value- The value that needs adjustingrange- -range = < value < range
-
-