]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/Track.java
Version 19, May 2018
[GpsPrune.git] / tim / prune / data / Track.java
index c56f9f5bcc08cba3c65096fca6299c3aafb1f103..f45854a0e3d47a1fd5fc0ee6924732b3294decc0 100644 (file)
@@ -178,21 +178,30 @@ public class Track
 
        /**
         * Delete the points marked for deletion
+        * @param inSplitSegments true to split segments at deleted points
         * @return number of points deleted
         */
-       public int deleteMarkedPoints()
+       public int deleteMarkedPoints(boolean inSplitSegments)
        {
                int numCopied = 0;
-               // Copy selected points
+               // Copy selected points into a new point array
                DataPoint[] newPointArray = new DataPoint[_numPoints];
+               boolean prevPointDeleted = false;
                for (int i=0; i<_numPoints; i++)
                {
                        DataPoint point = _dataPoints[i];
                        // Don't delete photo points
                        if (point.hasMedia() || !point.getDeleteFlag())
                        {
+                               if (prevPointDeleted && inSplitSegments) {
+                                       point.setSegmentStart(true);
+                               }
                                newPointArray[numCopied] = point;
                                numCopied++;
+                               prevPointDeleted = false;
+                       }
+                       else {
+                               prevPointDeleted = true;
                        }
                }
 
@@ -311,7 +320,7 @@ public class Track
         * @param inUndo true for undo operation
         * @return true on success
         */
-       public boolean addTimeOffset(int inStart, int inEnd, long inOffset, boolean inUndo)
+       public boolean addTimeOffsetSeconds(int inStart, int inEnd, long inOffset, boolean inUndo)
        {
                // sanity check
                if (inStart < 0 || inEnd < 0 || inStart >= inEnd || inEnd >= _numPoints) {
@@ -326,7 +335,7 @@ public class Track
                        {
                                // This point has a timestamp so add the offset to it
                                foundTimestamp = true;
-                               p.addTimeOffset(inOffset);
+                               p.addTimeOffsetSeconds(inOffset);
                                p.setModified(inUndo);
                        }
                }
@@ -552,8 +561,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);
@@ -901,7 +910,7 @@ public class Track
         */
        private static final double getMinXDist(double inX)
        {
-               // TODO: Can use some kind of floor here?
+               // TODO: Should be abs(mod(inX-0.5,1)-0.5) - means two adds, one mod, one abs instead of two adds, 3 abss and two compares
                return Math.min(Math.min(Math.abs(inX), Math.abs(inX-1.0)), Math.abs(inX+1.0));
        }