X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FTrack.java;h=9c65437b60abc86df5bd803c3f045d946e89a2f5;hb=ca9bdb3916f9c39adbbf95d06ac95c21dafbb4e6;hp=e73fa736eb6731d1d7c86ee5d48dffc6bf35b0eb;hpb=d3679d647d57c2ee7376ddbf6def2d5b23c04307;p=GpsPrune.git diff --git a/tim/prune/data/Track.java b/tim/prune/data/Track.java index e73fa73..9c65437 100644 --- a/tim/prune/data/Track.java +++ b/tim/prune/data/Track.java @@ -13,8 +13,6 @@ import tim.prune.edit.FieldEditList; */ public class Track { - // Broker object - UpdateMessageBroker _broker = null; // Data points private DataPoint[] _dataPoints = null; // Scaled x, y values @@ -32,13 +30,10 @@ public class Track /** - * Constructor giving arrays of Fields and Objects - * @param inFieldArray field array - * @param inPointArray 2d array of field values + * Constructor for empty track */ - public Track(UpdateMessageBroker inBroker) + public Track() { - _broker = inBroker; // create field list _masterFieldList = new FieldList(null); // make empty DataPoint array @@ -57,6 +52,11 @@ public class Track */ public void load(Field[] inFieldArray, Object[][] inPointArray, int inAltFormat) { + if (inFieldArray == null || inPointArray == null) + { + _numPoints = 0; + return; + } // copy field list _masterFieldList = new FieldList(inFieldArray); // make DataPoint object from each point in inPointList @@ -75,6 +75,11 @@ public class Track } } _numPoints = pointIndex; + // Set first track point to be start of segment + DataPoint firstTrackPoint = getNextTrackPoint(0); + if (firstTrackPoint != null) { + firstTrackPoint.setSegmentStart(true); + } // needs to be scaled _scaled = false; } @@ -85,7 +90,7 @@ public class Track /** * Combine this Track with new data - * @param inOtherTrack + * @param inOtherTrack other track to combine */ public void combine(Track inOtherTrack) { @@ -102,7 +107,7 @@ public class Track // needs to be scaled again _scaled = false; // inform listeners - _broker.informSubscribers(); + UpdateMessageBroker.informSubscribers(); } @@ -117,7 +122,7 @@ public class Track _numPoints = inNewSize; // needs to be scaled again _scaled = false; - _broker.informSubscribers(); + UpdateMessageBroker.informSubscribers(); } } @@ -142,13 +147,17 @@ public class Track if (yscale > wholeScale) wholeScale = yscale; double minDist = wholeScale / inResolution; + // Keep track of segment start flags of the deleted points + boolean setSegment = false; // Copy selected points DataPoint[] newPointArray = new DataPoint[_numPoints]; int[] pointIndices = new int[_numPoints]; for (int i=0; i<_numPoints; i++) { + DataPoint point = _dataPoints[i]; boolean keepPoint = true; - if (!_dataPoints[i].isWaypoint()) + // Don't delete waypoints or photo points + if (!point.isWaypoint() && point.getPhoto() == null) { // go through newPointArray to check for range for (int j=0; j 0) { + // remember if coordinates have changed + boolean coordsChanged = false; // go through edits one by one int numEdits = inEditList.getNumEdits(); for (int i=0; i