aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsudev <rasch@munin-soft.de>2013-03-16 12:00:46 -0700
committerrsudev <rasch@munin-soft.de>2013-03-16 12:00:46 -0700
commite3c6fbe83cd7edbefb9af966b7544ff6998ed370 (patch)
tree79ffe59f85401b232f47dea9ffd35c35e35cf5da
parent3c4add1feb0954600b9abb3ad7a0fee0122edcb5 (diff)
parentaf1c176c31115d1df2c268b4390fda55061a8d8b (diff)
downloadcgeo-e3c6fbe83cd7edbefb9af966b7544ff6998ed370.zip
cgeo-e3c6fbe83cd7edbefb9af966b7544ff6998ed370.tar.gz
cgeo-e3c6fbe83cd7edbefb9af966b7544ff6998ed370.tar.bz2
Merge pull request #2565 from triakcz/gpx_export_skip_invalid_wpts
GPX export ommiting waypoints without coords
-rw-r--r--main/src/cgeo/geocaching/export/GpxExport.java26
1 files changed, 14 insertions, 12 deletions
diff --git a/main/src/cgeo/geocaching/export/GpxExport.java b/main/src/cgeo/geocaching/export/GpxExport.java
index 74ee072..c4060fe 100644
--- a/main/src/cgeo/geocaching/export/GpxExport.java
+++ b/main/src/cgeo/geocaching/export/GpxExport.java
@@ -151,7 +151,7 @@ class GpxExport extends AbstractExport {
gpx.attribute("", "creator", "c:geo - http://www.cgeo.org/");
gpx.attribute(PREFIX_XSI, "schemaLocation",
PREFIX_GPX + " http://www.topografix.com/GPX/1/0/gpx.xsd " +
- PREFIX_GROUNDSPEAK + " http://www.groundspeak.com/cache/1/0/1/cache.xsd");
+ PREFIX_GROUNDSPEAK + " http://www.groundspeak.com/cache/1/0/1/cache.xsd");
for (int i = 0; i < caches.size(); i++) {
final Geocache cache = cgData.loadCache(caches.get(i).getGeocode(), LoadFlags.LOAD_ALL_DB_ONLY);
@@ -178,7 +178,6 @@ class GpxExport extends AbstractExport {
gpx.attribute("", "available", !cache.isDisabled() ? "True" : "False");
gpx.attribute("", "archives", cache.isArchived() ? "True" : "False");
-
XmlUtils.multipleTexts(gpx, PREFIX_GROUNDSPEAK,
"name", cache.getName(),
"placed_by", cache.getOwnerDisplayName(),
@@ -274,17 +273,20 @@ class GpxExport extends AbstractExport {
* @throws IOException
*/
private void writeCacheWaypoint(final XmlSerializer gpx, final Waypoint wp, final String prefix) throws IOException {
- gpx.startTag(PREFIX_GPX, "wpt");
final Geopoint coords = wp.getCoords();
- gpx.attribute("", "lat", coords != null ? Double.toString(coords.getLatitude()) : ""); // TODO: check whether is the best way to handle unknown waypoint coordinates
- gpx.attribute("", "lon", coords != null ? Double.toString(coords.getLongitude()) : "");
- XmlUtils.multipleTexts(gpx, PREFIX_GPX,
- "name", prefix + wp.getGeocode().substring(2),
- "cmt", wp.getNote(),
- "desc", wp.getName(),
- "sym", wp.getWaypointType().toString(), //TODO: Correct identifier string
- "type", "Waypoint|" + wp.getWaypointType().toString()); //TODO: Correct identifier string
- gpx.endTag(PREFIX_GPX, "wpt");
+ // TODO: create some extension to GPX to include waypoint without coords
+ if (coords != null) {
+ gpx.startTag(PREFIX_GPX, "wpt");
+ gpx.attribute("", "lat", Double.toString(coords.getLatitude()));
+ gpx.attribute("", "lon", Double.toString(coords.getLongitude()));
+ XmlUtils.multipleTexts(gpx, PREFIX_GPX,
+ "name", prefix + wp.getGeocode().substring(2),
+ "cmt", wp.getNote(),
+ "desc", wp.getName(),
+ "sym", wp.getWaypointType().toString(), //TODO: Correct identifier string
+ "type", "Waypoint|" + wp.getWaypointType().toString()); //TODO: Correct identifier string
+ gpx.endTag(PREFIX_GPX, "wpt");
+ }
}
private void writeLogs(final XmlSerializer gpx, final Geocache cache) throws IOException {