net.divbyzero.gpx
Class TrackSegment

java.lang.Object
  extended by net.divbyzero.gpx.TrackSegment
All Implemented Interfaces:
Measurable

public class TrackSegment
extends Object
implements Measurable

Track segment of a GPS track

A segment consists of an arbitrary number of way points. Segments have a length, can be queried for elevations and for the points in time when the segment was entered and left during a track recording.

Since:
0.1
Author:
Martin Jansen

Constructor Summary
TrackSegment()
           
 
Method Summary
 void addWaypoint(Waypoint waypoint)
          Adds a new way point to the segment.
 double cumulativeAscent()
          Calculates the total ascent in the segment.
 double cumulativeDescent()
          Calculates the total descent in the segment.
 Date endTime()
          Returns the point in time when the segment was left
 ArrayList<Waypoint> getWaypoints()
          Returns the way points of which the segment consists.
 double length()
          Calculates the length of the track segment
 Date startingTime()
          Returns the point in time when the segment was entered
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrackSegment

public TrackSegment()
Method Detail

addWaypoint

public void addWaypoint(Waypoint waypoint)
Adds a new way point to the segment.

This method is used for extending a track segment by another way point. The way point is added at the segment's end.

Parameters:
waypoint - the way point to be added to the segment

getWaypoints

public ArrayList<Waypoint> getWaypoints()
Returns the way points of which the segment consists.

This method returns a list of the way points that make up the segment. They are returned in the order that they were added, i.e. the way point at which the segments start is at position 0 while the way point where the segment ends is at the last position of the list.

Returns:
a list of the segment's way points

length

public double length()
Calculates the length of the track segment

Specified by:
length in interface Measurable
Returns:
the segment's length in meters

cumulativeAscent

public double cumulativeAscent()
Calculates the total ascent in the segment.

The total ascent of the segment is calculated by comparing each of the segment's way point with their predecessors. If the elevation of a way point is higher than the elevation of the predecessor, the total ascent is increased accordingly.

Specified by:
cumulativeAscent in interface Measurable
Returns:
the segment's total ascent in meters
See Also:
cumulativeDescent()

cumulativeDescent

public double cumulativeDescent()
Calculates the total descent in the segment.

The total descent of the segment is calculated by comparing each of the segment's way point with their predecessors. If the elevation of a way point is lower than the elevation of the predecessor, the total descent is increased accordingly.

Specified by:
cumulativeDescent in interface Measurable
Returns:
the segment's total descent in meters
See Also:
cumulativeAscent()

startingTime

public Date startingTime()
Returns the point in time when the segment was entered

Usually this is the time stamp of the way point that was added first to the segment.

Specified by:
startingTime in interface Measurable
Returns:
the point in time when the segment was entered
See Also:
endTime()

endTime

public Date endTime()
Returns the point in time when the segment was left

Usually this is the time stamp of the way point that was added last to the segment.

Specified by:
endTime in interface Measurable
Returns:
the point in time when the segment was left
See Also:
endTime()


Processing library MapThing by Jon Reades. (C) 2013