X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fsave%2FGpxExporter.java;h=936361680495e30a75f528d62e465d32a72260c8;hb=6f96fb8a39cd8dadff3602eec8a26ed2a7d1fca8;hp=0f038b77ce60f473a50a64b068c68b698f5b2050;hpb=a6197ddcaac11c0b943183da7d46169742d024af;p=GpsPrune.git diff --git a/tim/prune/save/GpxExporter.java b/tim/prune/save/GpxExporter.java index 0f038b7..9363616 100644 --- a/tim/prune/save/GpxExporter.java +++ b/tim/prune/save/GpxExporter.java @@ -347,11 +347,11 @@ public class GpxExporter extends GenericFunction implements Runnable final String gpxHeader = getGpxHeaderString(inGpxCachers); final boolean isVersion1_1 = (gpxHeader.toUpperCase().indexOf("GPX/1/1") > 0); inWriter.write(gpxHeader); - // Name field - String trackName = (inName != null && !inName.equals("")) ? inName : "GpsPruneTrack"; - writeNameAndDescription(inWriter, inName, inDesc, isVersion1_1); + // name and description + String trackName = (inName != null && !inName.equals("")) ? XmlUtils.fixCdata(inName) : "GpsPruneTrack"; + String desc = (inDesc != null && !inDesc.equals("")) ? XmlUtils.fixCdata(inDesc) : "Export from GpsPrune"; + writeNameAndDescription(inWriter, trackName, desc, isVersion1_1); - int i = 0; DataPoint point = null; final boolean exportTrackpoints = inSaveFlags[0]; final boolean exportWaypoints = inSaveFlags[1]; @@ -368,7 +368,7 @@ public class GpxExporter extends GenericFunction implements Runnable // Loop over waypoints final int numPoints = inInfo.getTrack().getNumPoints(); int numSaved = 0; - for (i=0; i=selStart && i<=selEnd)) @@ -423,7 +423,6 @@ public class GpxExporter extends GenericFunction implements Runnable 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) { @@ -439,7 +438,7 @@ public class GpxExporter extends GenericFunction implements Runnable } if (inIsVersion1_1) {inWriter.write('\t');} inWriter.write("\t"); - inWriter.write(desc); + inWriter.write(inDesc); inWriter.write("\n"); if (inIsVersion1_1) { @@ -538,8 +537,12 @@ public class GpxExporter extends GenericFunction implements Runnable source = replaceGpxTags(source, "", inPoint.getTimestamp().getText(Timestamp.Format.ISO8601)); if (inPoint.isWaypoint()) { - source = replaceGpxTags(source, "", "", inPoint.getWaypointName()); - source = replaceGpxTags(source, "", "", + source = replaceGpxTags(source, "", "", XmlUtils.fixCdata(inPoint.getWaypointName())); + if (source != null) + { + source = source.replaceAll("", "").replaceAll("", ""); + } + source = replaceGpxTags(source, "", "", XmlUtils.fixCdata(inPoint.getFieldValue(Field.DESCRIPTION))); } // photo / audio links @@ -690,15 +693,15 @@ public class GpxExporter extends GenericFunction implements Runnable } // write waypoint name after elevation and time inWriter.write("\t\t"); - inWriter.write(inPoint.getWaypointName().trim()); + inWriter.write(XmlUtils.fixCdata(inPoint.getWaypointName().trim())); inWriter.write("\n"); // description, if any String desc = XmlUtils.fixCdata(inPoint.getFieldValue(Field.DESCRIPTION)); if (desc != null && !desc.equals("")) { - inWriter.write("\t\t"); + inWriter.write("\t\t"); inWriter.write(desc); - inWriter.write("\n"); + inWriter.write("\n"); } // Media links, if any if (inPhoto && inPoint.getPhoto() != null)