- _altitudeRange = new AltitudeRange();
- Altitude altitude = null;
- Timestamp time = null, previousTime = null;
- DataPoint lastPoint = null, currPoint = null;
- _angMovingDistance = 0.0;
- _movingMilliseconds = 0L;
- // Loop over points in selection
- for (int i=_startIndex; i<=_endIndex; i++)
- {
- currPoint = _track.getPoint(i);
- altitude = currPoint.getAltitude();
- // Ignore waypoints in altitude calculations
- if (!currPoint.isWaypoint() && altitude.isValid())
- {
- if (currPoint.getSegmentStart()) {
- _altitudeRange.ignoreValue(altitude);
- }
- else {
- _altitudeRange.addValue(altitude);
- }
- }
- // Compare timestamps within the segments
- time = currPoint.getTimestamp();
- if (time.isValid())
- {
- // add moving time
- if (!currPoint.getSegmentStart() && previousTime != null && time.isAfter(previousTime)) {
- _movingMilliseconds += time.getMillisecondsSince(previousTime);
- }
- previousTime = time;
- }
- // Calculate distances, again ignoring waypoints
- if (!currPoint.isWaypoint())
- {
- if (lastPoint != null)
- {
- double radians = DataPoint.calculateRadiansBetween(lastPoint, currPoint);
- if (!currPoint.getSegmentStart()) {
- _angMovingDistance += radians;
- }
- }
- lastPoint = currPoint;
- }
- }