- boolean firstTrackPoint = true;
- // Loop between start and end
- for (int i=inStart; i<=inEnd; i++) {
- DataPoint point = getPoint(i);
- // Set all segments to false apart from first track point
- if (point != null && !point.isWaypoint()) {
- point.setSegmentStart(firstTrackPoint);
- firstTrackPoint = false;
+ // sanity check
+ if (inStart < 0 || inEnd < 0 || inStart >= inEnd || inEnd >= _numPoints) {
+ return false;
+ }
+ boolean foundAlt = false;
+ // Loop over all points within range
+ for (int i=inStart; i<=inEnd; i++)
+ {
+ Altitude alt = _dataPoints[i].getAltitude();
+ if (alt != null && alt.isValid())
+ {
+ // This point has an altitude so add the offset to it
+ foundAlt = true;
+ alt.addOffset(inOffset, inFormat, inDecimals);