X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FTrack.java;h=63cd01faaf488028085a6712c5648ad9ffa8ea1d;hb=f1b92378a792131ac8fb33a869405851d5b2d1f7;hp=fa1be1e5f4c27fa8b076d075b8b621e8926bc273;hpb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;p=GpsPrune.git diff --git a/tim/prune/data/Track.java b/tim/prune/data/Track.java index fa1be1e..63cd01f 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 @@ -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 + } }