X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FTrack.java;h=31c9b4edeeaf3cbb04af8468e8f85b8b33932b8d;hb=1ea5817da5381ceebee75ea7294ea78dffff5671;hp=45810e2ef9e4b7ba1a036f423962cecc8a87d5a5;hpb=326f489e36aa7f235bc19409a57bf4955cd50f24;p=GpsPrune.git diff --git a/tim/prune/data/Track.java b/tim/prune/data/Track.java index 45810e2..31c9b4e 100644 --- a/tim/prune/data/Track.java +++ b/tim/prune/data/Track.java @@ -87,6 +87,11 @@ public class Track _dataPoints[pointIndex] = point; pointIndex++; } + else + { + // TODO: Maybe report this somehow? + // System.out.println("point is not valid!"); + } } _numPoints = pointIndex; // Set first track point to be start of segment @@ -363,61 +368,6 @@ public class Track } - /** - * Collect all waypoints to the start or end of the track - * @param inAtStart true to collect at start, false for end - * @return true if successful, false if no change - */ - public boolean collectWaypoints(boolean inAtStart) - { - // Check for mixed data, numbers of waypoints & nons - int numWaypoints = 0, numNonWaypoints = 0; - boolean wayAfterNon = false, nonAfterWay = false; - DataPoint[] waypoints = new DataPoint[_numPoints]; - DataPoint[] nonWaypoints = new DataPoint[_numPoints]; - DataPoint point = null; - for (int i=0; i<_numPoints; i++) - { - point = _dataPoints[i]; - if (point.isWaypoint()) - { - waypoints[numWaypoints] = point; - numWaypoints++; - wayAfterNon |= (numNonWaypoints > 0); - } - else - { - nonWaypoints[numNonWaypoints] = point; - numNonWaypoints++; - nonAfterWay |= (numWaypoints > 0); - } - } - // Exit if the data is already in the specified order - if (numWaypoints == 0 || numNonWaypoints == 0 - || (inAtStart && !wayAfterNon && nonAfterWay) - || (!inAtStart && wayAfterNon && !nonAfterWay)) - { - return false; - } - - // Copy the arrays back into _dataPoints in the specified order - if (inAtStart) - { - System.arraycopy(waypoints, 0, _dataPoints, 0, numWaypoints); - System.arraycopy(nonWaypoints, 0, _dataPoints, numWaypoints, numNonWaypoints); - } - else - { - System.arraycopy(nonWaypoints, 0, _dataPoints, 0, numNonWaypoints); - System.arraycopy(waypoints, 0, _dataPoints, numNonWaypoints, numWaypoints); - } - // needs to be scaled again - _scaled = false; - UpdateMessageBroker.informSubscribers(); - return true; - } - - /** * Interleave all waypoints by each nearest track point * @return true if successful, false if no change @@ -602,8 +552,8 @@ public class Track meanAltitude = new Altitude((int) (totalAltitude / numAltitudes), altUnit); } - DataPoint insertedPoint = new DataPoint(new Latitude(meanLatitude, Coordinate.FORMAT_NONE), - new Longitude(meanLongitude, Coordinate.FORMAT_NONE), meanAltitude); + DataPoint insertedPoint = new DataPoint(new Latitude(meanLatitude, Coordinate.FORMAT_DECIMAL_FORCE_POINT), + new Longitude(meanLongitude, Coordinate.FORMAT_DECIMAL_FORCE_POINT), meanAltitude); // Make into singleton insertedPoint.setSegmentStart(true); DataPoint nextPoint = getNextTrackPoint(inEndIndex+1);