+ /**
+ * Add a List of Photos
+ * @param inList List containing Photo objects
+ * @return array containing number of photos and number of points added
+ */
+ public int[] addPhotos(List inList)
+ {
+ // TODO: Should photos be sorted at load-time, either by filename or date?
+ // Firstly count number of points and photos to add
+ int numPhotosToAdd = 0;
+ int numPointsToAdd = 0;
+ if (inList != null && !inList.isEmpty())
+ {
+ for (int i=0; i<inList.size(); i++)
+ {
+ try
+ {
+ Photo photo = (Photo) inList.get(i);
+ if (photo != null && !_photoList.contains(photo))
+ {
+ numPhotosToAdd++;
+ if (photo.getDataPoint() != null)
+ {
+ numPointsToAdd++;
+ }
+ }
+ }
+ catch (ClassCastException ce) {}
+ }
+ }
+ // If there are any photos to add, add them
+ if (numPhotosToAdd > 0)
+ {
+ DataPoint[] dataPoints = new DataPoint[numPointsToAdd];
+ int pointNum = 0;
+ boolean hasAltitude = false;
+ // Add each Photo in turn
+ for (int i=0; i<inList.size(); i++)
+ {
+ try
+ {
+ Photo photo = (Photo) inList.get(i);
+ if (photo != null && !_photoList.contains(photo))
+ {
+ // Add photo
+ _photoList.addPhoto(photo);
+ // Add point if there is one
+ if (photo.getDataPoint() != null)
+ {
+ dataPoints[pointNum] = photo.getDataPoint();
+ // Check if any points have altitudes
+ hasAltitude |= (photo.getDataPoint().getAltitude() != null);
+ pointNum++;
+ }
+ }
+ }
+ catch (ClassCastException ce) {}
+ }
+ if (numPointsToAdd > 0)
+ {
+ // add points to track
+ _track.appendPoints(dataPoints);
+ // modify track field list
+ _track.getFieldList().extendList(Field.LATITUDE);
+ _track.getFieldList().extendList(Field.LONGITUDE);
+ if (hasAltitude) {_track.getFieldList().extendList(Field.ALTITUDE);}
+ }
+ }
+ int[] result = {numPhotosToAdd, numPointsToAdd};
+ return result;
+ }
+
+