+ /**
+ * Add a Set of Photos
+ * @param inSet Set containing Photo objects
+ * @return array containing number of photos and number of points added
+ */
+ public int[] addPhotos(Set inSet)
+ {
+ // Firstly count number of points and photos to add
+ int numPhotosToAdd = 0;
+ int numPointsToAdd = 0;
+ Iterator iterator = null;
+ if (inSet != null && !inSet.isEmpty())
+ {
+ iterator = inSet.iterator();
+ while (iterator.hasNext())
+ {
+ try
+ {
+ Photo photo = (Photo) iterator.next();
+ 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
+ iterator = inSet.iterator();
+ while (iterator.hasNext())
+ {
+ try
+ {
+ Photo photo = (Photo) iterator.next();
+ 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;
+ }
+
+