1 package tim.prune.data;
6 * Class to hold the source of the point data,
7 * including original file and file type, and
8 * also file offsets for source copying
10 public class SourceInfo
12 /** File type of source file */
13 public enum FILE_TYPE {TEXT, GPX, KML, NMEA, GPSBABEL, GPSIES};
16 private File _sourceFile = null;
18 private String _sourceName = null;
20 private FILE_TYPE _fileType = null;
22 /** Array of datapoints */
23 private DataPoint[] _points = null;
28 * @param inFile source file
29 * @param inType type of file
31 public SourceInfo(File inFile, FILE_TYPE inType)
34 _sourceName = inFile.getName();
40 * @param inName name of source (without file)
41 * @param inType type of file
43 public SourceInfo(String inName, FILE_TYPE inType)
61 public String getName()
67 * @return file type of source
69 public FILE_TYPE getFileType()
75 * @return number of points from this source
77 public int getNumPoints()
79 return _points.length;
83 * Take the points from the given track and store
84 * @param inTrack track object containing points
85 * @param inNumPoints number of points loaded
87 public void populatePointObjects(Track inTrack, int inNumPoints)
91 _points = new DataPoint[inNumPoints];
92 int trackLen = inTrack.getNumPoints();
93 System.arraycopy(inTrack.cloneContents(), trackLen-inNumPoints, _points, 0, inNumPoints);
94 // Note data copied twice here but still more efficient than looping
99 * Look for the given point in the array
100 * @param inPoint point to look for
101 * @return index, or -1 if not found
103 public int getIndex(DataPoint inPoint)
106 for (int i=0; i<_points.length && (idx < 0); i++) {
107 if (_points[i] == inPoint) {idx = i;}