Global Positioning System Reference
In-Depth Information
ˆ
A trace of a pedestrian can reveal secret paths through a neighbor-
hood.
ˆ
Traces of one racing car on different days might imply varying con-
ditions (weather, etc.).
ˆ
Dierent traces of an athlete's work-outs might reveal his condition.
While the route is used to describe (a rough) geometry, the trace relies
on physics and motion. We create another class
GPStraceextendsRoute
to finally establish a useful set for very general purposes. The four classes
GeoPoint,GPSpoint,GPStrace
, and
Route
and two interfaces
Position
and
GPSinfo
6
are designed with OO techniques and reflect the semantics to use
GPS data.
Internally the
Route
is programmed with a
Position
type object, but in
an external environment it can hold any object implementing a
Position
. It
can mix
GPSpoint
s and
GeoPoint
s at the cost of type checking for upcasting
later. In a distributed application every local environment can work with
its own implementation. A
newGeoPoint(...)
can never be upcast to a
GPSpoint
, since it has no time stamp and therefore, the conversion would
not make sense.
Internally, the
GPStrace
makes use of the
protected List<Position> sequence;
by implementing additional bookkeeping of the element's types. Note that
this provides protected visibility for inheriting classes. Another useful im-
plication of inheritance is the distribution of responsibility. The
GPStrace
is responsible for controlling the time stamps, while relying on the
Route
's
management of the
Position
part.
It seems that a programmer can cast the object hierarchy up and down,
but there is one important catch: no matter which \perspective" you chose
to look at an object, a method call always invokes the highest overriding
method. Thus, if a
GPSpoint
is cast to
GeoPoint
,
GPSinfo
, or
Position
, the
method
getNewPosition()
will invoke the
GPSpoint
implementation while
the other implementations remain obscured.
The
GPStrace
can make use of the
Route
's method as any client does. The
total distance is managed by the
Route
and the total duration is managed
by the
GPStrace
.
4.8
JavaGPS
We now want to create a component making use of the
roaf.book.gps
package and supply space and time information whenever it is needed.
roaf.book.gps
6
See Figure 4.1 for the UML diagram.
Search WWH ::
Custom Search