Global Positioning System Reference
In-Depth Information
aspects. A car driving up hill behaves different than a car rolling downhill
due to shifted gravity forces relative to the car. The majority of the globe's
surface is at sea level, so the elevation should default to 0 (plane), if not
supplied and is better than using a null value.
Please execute the method roaf.book.gps.GeoPoint.main .
The class roaf.util.GeoPoint is created from scratch similar to the stan-
dard Java classes Point2D and Point with the methods get/set ,
longitude/latitude , distance , and move . The default constructor (no argu-
ments) can not be used in order to enforce concrete values for a position at
construction time. Decimal values are used to avoid working with degrees,
minutes, and seconds. The methods latitude and longitude have private
visibility and can only be accessed by getters and setters to be validated
internally to ensure that the values fit into the geographical grid:
latitude: [90 ; 90 ];
longitude: [180 ; 180 ]:
Implementing a distance() method turns out to be more complicated
than in a Cartesian coordinate system. 1 A spatial coordinate system on
the surface of an ellipsoid uses dimensionless angles (relative), and size and
shape are needed to calculate absolute units
For a symmetric body, two values|those for mean radius and the at-
tening of the earth|are sucient to use the Haversine (half-versed sine)
formula, a mathematical equation important in navigation, giving great-
circle distances between two points on a sphere from their longitudes and
latitudes. 2 The table below shows the values calculated using the formula
for the metric distance of one degree in the longitudinal direction:
roaf.util.GeoPoint
Euclidian distance of one degree longitude
at latitude 0.0 is 111.1864599561611 km
15.0 is 107.3983296596687 km
30.0 is 96.2918262451686 km
45.0 is 78.6231940795413 km
60.0 is 55.5958756444310 km
75.0 is 28.7788771173616 km
Note that the distance method only accepts one other point to cal-
culate the distance from this geographical point. The object-oriented
programming technique of currying transforms a two-argument function
distance(from,to) into a context sensitive function this.distance(to) .
Besides calculating how far away another object is on the globe it is
vital to find out exactly where the object will be located after moving a
1 The Cartesian distance in two dimensions is determined byd= p x 2 +y 2 :
2 You can find the formula at roaf.util.GeoPoint.distance(Position).
 
Search WWH ::




Custom Search