+ point = inInfo.getTrack().getPoint(i);
+ if (!exportSelection || (i>=selStart && i<=selEnd))
+ {
+ // Make a wpt element for each waypoint
+ if (point.isWaypoint() && exportWaypoints)
+ {
+ String pointSource = (inGpxCachers == null? null : getPointSource(inGpxCachers, point));
+ if (pointSource != null)
+ {
+ // If timestamp checkbox is off, strip time
+ if (!exportTimestamps) {
+ pointSource = stripTime(pointSource);
+ }
+ inWriter.write('\t');
+ inWriter.write(pointSource);
+ inWriter.write('\n');
+ }
+ else {
+ exportWaypoint(point, inWriter, exportTimestamps, exportPhotos, exportAudios);
+ }
+ numSaved++;
+ }
+ }
+ }
+ // Export both route points and then track points
+ if (exportTrackpoints || exportPhotos || exportAudios)
+ {
+ // Output all route points (if any)
+ numSaved += writeTrackPoints(inWriter, inInfo, exportSelection, exportTrackpoints, exportPhotos,
+ exportAudios, exportTimestamps, true, inGpxCachers, "<rtept", "\t<rte><number>1</number>\n",
+ null, "\t</rte>\n");
+ // Output all track points, if any
+ String trackStart = "\t<trk>\n\t\t<name>" + trackName + "</name>\n\t\t<number>1</number>\n\t\t<trkseg>\n";
+ numSaved += writeTrackPoints(inWriter, inInfo, exportSelection, exportTrackpoints, exportPhotos,
+ exportAudios, exportTimestamps, false, inGpxCachers, "<trkpt", trackStart,
+ "\t</trkseg>\n\t<trkseg>\n", "\t\t</trkseg>\n\t</trk>\n");
+ }
+
+ inWriter.write("</gpx>\n");
+ return numSaved;
+ }
+
+
+ /**
+ * Write the name and description according to the GPX version number
+ * @param inWriter writer object
+ * @param inName name, or null if none supplied
+ * @param inDesc description, or null if none supplied
+ * @param inIsVersion1_1 true if gpx version 1.1, false for version 1.0
+ */
+ private static void writeNameAndDescription(OutputStreamWriter inWriter,
+ String inName, String inDesc, boolean inIsVersion1_1) throws IOException
+ {
+ String desc = (inDesc != null && !inDesc.equals("")) ? inDesc : "Export from GpsPrune";
+ // Position of name and description fields needs to be different for GPX1.0 and GPX1.1
+ if (inIsVersion1_1)
+ {
+ // GPX 1.1 has the name and description inside a metadata tag
+ inWriter.write("\t<metadata>\n");
+ }
+ if (inName != null && !inName.equals(""))
+ {
+ if (inIsVersion1_1) {inWriter.write('\t');}