X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FTrack.java;h=fc65959bd3c6f2c25442d4e3bd15a78d98842f60;hb=649c5da6ee1bbc590699e11a92316ece2ea8512d;hp=9b88ade102519207d2bb730a44edc9b477386157;hpb=140e9d165f85c3d4f0435a311e091209313faa2a;p=GpsPrune.git diff --git a/tim/prune/data/Track.java b/tim/prune/data/Track.java index 9b88ade..fc65959 100644 --- a/tim/prune/data/Track.java +++ b/tim/prune/data/Track.java @@ -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 @@ -173,7 +186,7 @@ public class Track { DataPoint point = _dataPoints[i]; // Don't delete photo points - if (point.getPhoto() != null || !point.getDeleteFlag()) + if (point.hasMedia() || !point.getDeleteFlag()) { newPointArray[numCopied] = point; numCopied++; @@ -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 + } }