]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/SourceInfo.java
Version 19.2, December 2018
[GpsPrune.git] / tim / prune / data / SourceInfo.java
index 341bf0299410a3f767adcf9fbe9f3064d9053aef..d71280db8a5e45c28d594b0306b3b82c10797b16 100644 (file)
@@ -9,7 +9,7 @@ import java.io.File;
 public class SourceInfo
 {
        /** File type of source file */
-       public enum FILE_TYPE {TEXT, GPX, KML, NMEA, GPSBABEL, GPSIES};
+       public enum FILE_TYPE {TEXT, GPX, KML, NMEA, GPSBABEL, GPSIES, JSON};
 
        /** Source file */
        private File _sourceFile = null;
@@ -17,6 +17,8 @@ public class SourceInfo
        private String _sourceName = null;
        /** File type */
        private FILE_TYPE _fileType = null;
+       /** File title, if any */
+       private String _fileTitle = null;
 
        /** Array of datapoints */
        private DataPoint[] _points = null;
@@ -50,6 +52,14 @@ public class SourceInfo
                _fileType = inType;
        }
 
+       /**
+        * @param inTitle title of file, eg from <name> tag in gpx
+        */
+       public void setFileTitle(String inTitle)
+       {
+               _fileTitle = inTitle;
+       }
+
        /**
         * @return source file
         */
@@ -74,6 +84,14 @@ public class SourceInfo
                return _fileType;
        }
 
+       /**
+        * @return title of file
+        */
+       public String getFileTitle()
+       {
+               return _fileTitle;
+       }
+
        /**
         * @return number of points from this source
         */
@@ -122,9 +140,14 @@ public class SourceInfo
        public int getIndex(DataPoint inPoint)
        {
                int idx = -1;
-               for (int i=0; i<_points.length && (idx < 0); i++) {
-                       if (_points[i] == inPoint) {idx = i;}
+               for (int i=0; i<_points.length; i++)
+               {
+                       if (_points[i] == inPoint) {
+                               idx = i;
+                               break;
+                       }
                }
+               if (idx == -1) {return idx;}             // point not found
                if (_pointIndices == null) {return idx;} // All points loaded
                return _pointIndices[idx]; // use point index mapping
        }