]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/Track.java
Version 13.4, May 2012
[GpsPrune.git] / tim / prune / data / Track.java
index fa1be1e5f4c27fa8b076d075b8b621e8926bc273..63cd01faaf488028085a6712c5648ad9ffa8ea1d 100644 (file)
@@ -46,6 +46,19 @@ public class Track
                _scaled = false;
        }
 
+       /**
+        * Constructor using fields and points from another Track
+        * @param inFieldList Field list from another Track object
+        * @param inPoints (edited) point array
+        */
+       public Track(FieldList inFieldList, DataPoint[] inPoints)
+       {
+               _masterFieldList = inFieldList;
+               _dataPoints = inPoints;
+               if (_dataPoints == null) _dataPoints = new DataPoint[0];
+               _numPoints = _dataPoints.length;
+               _scaled = false;
+       }
 
        /**
         * Load method, for initialising and reinitialising data
@@ -476,7 +489,7 @@ public class Track
        {
                // TODO: Move cut/move into separate function?
                // Check that indices make sense
-               if (inSectionStart > 0 && inSectionEnd > inSectionStart && inMoveTo >= 0
+               if (inSectionStart >= 0 && inSectionEnd > inSectionStart && inMoveTo >= 0
                        && (inMoveTo < inSectionStart || inMoveTo > (inSectionEnd+1)))
                {
                        // do the cut and move
@@ -966,6 +979,7 @@ public class Track
         */
        public DataPoint getPreviousTrackPoint(int inStartIndex)
        {
+               // end index is given as _numPoints but actually it just counts down to -1
                return getNextTrackPoint(inStartIndex, _numPoints, false);
        }
 
@@ -1178,4 +1192,18 @@ public class Track
                }
                return false;
        }
+
+       /**
+        * @param inPoint point to check
+        * @return true if this track contains the given point
+        */
+       public boolean containsPoint(DataPoint inPoint)
+       {
+               if (inPoint == null) return false;
+               for (int i=0; i < getNumPoints(); i++)
+               {
+                       if (getPoint(i) == inPoint) return true;
+               }
+               return false; // not found
+       }
 }