]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/DataPoint.java
Version 19, May 2018
[GpsPrune.git] / tim / prune / data / DataPoint.java
index 4de97ef219bb60f05153dc4f3a4cbbdf72a2e672..84f4800bcd2c0a0d546da8a83a87868810bf3a54 100644 (file)
@@ -81,7 +81,7 @@ public class DataPoint
                        }
                }
                if (inField == null || inField == Field.TIMESTAMP) {
-                       _timestamp = new Timestamp(getFieldValue(Field.TIMESTAMP));
+                       _timestamp = new TimestampUtc(getFieldValue(Field.TIMESTAMP));
                }
                if (inField == null || inField == Field.WAYPT_NAME) {
                        _waypointName = getFieldValue(Field.WAYPT_NAME);
@@ -118,7 +118,7 @@ public class DataPoint
                        _altitude = inAltitude;
                        _fieldValues[2] = "" + inAltitude.getValue();
                }
-               _timestamp = new Timestamp(null);
+               _timestamp = new TimestampUtc(null);
        }
 
 
@@ -138,7 +138,7 @@ public class DataPoint
         * @param inIndex index number starting at zero
         * @return field value, or null if not found
         */
-       public String getFieldValue(int inIndex)
+       private String getFieldValue(int inIndex)
        {
                if (_fieldValues == null || inIndex < 0 || inIndex >= _fieldValues.length)
                        return null;
@@ -338,6 +338,46 @@ public class DataPoint
                return (inOther._waypointName != null && inOther._waypointName.equals(_waypointName));
        }
 
+       /**
+        * Add an altitude offset to this point, and keep the point's string value in sync
+        * @param inOffset offset as double
+        * @param inUnit unit of offset, feet or metres
+        * @param inDecimals number of decimal places
+        */
+       public void addAltitudeOffset(double inOffset, Unit inUnit, int inDecimals)
+       {
+               if (hasAltitude())
+               {
+                       _altitude.addOffset(inOffset, inUnit, inDecimals);
+                       _fieldValues[_fieldList.getFieldIndex(Field.ALTITUDE)] = _altitude.getStringValue(null);
+                       setModified(false);
+               }
+       }
+
+       /**
+        * Reset the altitude to the previous value (by an undo)
+        * @param inClone altitude object cloned from earlier
+        */
+       public void resetAltitude(Altitude inClone)
+       {
+               _altitude.reset(inClone);
+               _fieldValues[_fieldList.getFieldIndex(Field.ALTITUDE)] = _altitude.getStringValue(null);
+               setModified(true);
+       }
+
+       /**
+        * Add a time offset to this point
+        * @param inOffset offset to add (-ve to subtract)
+        */
+       public void addTimeOffsetSeconds(long inOffset)
+       {
+               if (hasTimestamp())
+               {
+                       _timestamp.addOffsetSeconds(inOffset);
+                       _fieldValues[_fieldList.getFieldIndex(Field.TIMESTAMP)] = _timestamp.getText(null);
+                       setModified(false);
+               }
+       }
 
        /**
         * Set the photo for this data point