diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2012-07-01 09:15:02 +0200 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2012-07-01 09:15:02 +0200 |
commit | 2b744ff80e20203f8d4e3e4a6891f799a500e8ac (patch) | |
tree | cb1c547293d9354e26b6c59c18810921ad524ffb /main/src/cgeo | |
parent | b94db2f7f0e4d3ea5313e9e93896b3e2631b4679 (diff) | |
download | cgeo-2b744ff80e20203f8d4e3e4a6891f799a500e8ac.zip cgeo-2b744ff80e20203f8d4e3e4a6891f799a500e8ac.tar.gz cgeo-2b744ff80e20203f8d4e3e4a6891f799a500e8ac.tar.bz2 |
fix #1833: Export / Import GPX
Diffstat (limited to 'main/src/cgeo')
-rw-r--r-- | main/src/cgeo/geocaching/export/GpxExport.java | 6 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/files/GPXParser.java | 12 |
2 files changed, 12 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/export/GpxExport.java b/main/src/cgeo/geocaching/export/GpxExport.java index 0f73e29..9bc3963 100644 --- a/main/src/cgeo/geocaching/export/GpxExport.java +++ b/main/src/cgeo/geocaching/export/GpxExport.java @@ -335,10 +335,12 @@ class GpxExport extends AbstractExport { gpx.write(StringEscapeUtils.escapeXml(wp.getGeocode().substring(2))); gpx.write("</name>"); - gpx.write("<cmt />"); + gpx.write("<cmt>"); + gpx.write(StringEscapeUtils.escapeXml(wp.getNote())); + gpx.write("</cmt>"); gpx.write("<desc>"); - gpx.write(StringEscapeUtils.escapeXml(wp.getNote())); + gpx.write(StringEscapeUtils.escapeXml(wp.getName())); gpx.write("</desc>"); gpx.write("<sym>"); diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java index f8ec61c..454c494 100644 --- a/main/src/cgeo/geocaching/files/GPXParser.java +++ b/main/src/cgeo/geocaching/files/GPXParser.java @@ -255,8 +255,13 @@ public abstract class GPXParser extends FileParser { public void start(Attributes attrs) { try { if (attrs.getIndex("lat") > -1 && attrs.getIndex("lon") > -1) { - cache.setCoords(new Geopoint(Double.valueOf(attrs.getValue("lat")), - Double.valueOf(attrs.getValue("lon")))); + final String latitude = attrs.getValue("lat"); + final String longitude = attrs.getValue("lon"); + // latitude and longitude are required attributes, but we export them empty for waypoints without coordinates + if (StringUtils.isNotBlank(latitude) && StringUtils.isNotBlank(longitude)) { + cache.setCoords(new Geopoint(Double.valueOf(latitude), + Double.valueOf(longitude))); + } } } catch (Exception e) { Log.w("Failed to parse waypoint's latitude and/or longitude."); @@ -300,8 +305,7 @@ public abstract class GPXParser extends FileParser { result.put(key, cache); showProgressMessage(progressHandler, progressStream.getProgress()); } else if (StringUtils.isNotBlank(cache.getName()) - && cache.getCoords() != null - && StringUtils.contains(type, "waypoint")) { + && StringUtils.containsIgnoreCase(type, "waypoint")) { addWaypointToCache(); } |