aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/files/GPXParser.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-07-01 09:15:02 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-07-01 09:15:02 +0200
commit2b744ff80e20203f8d4e3e4a6891f799a500e8ac (patch)
treecb1c547293d9354e26b6c59c18810921ad524ffb /main/src/cgeo/geocaching/files/GPXParser.java
parentb94db2f7f0e4d3ea5313e9e93896b3e2631b4679 (diff)
downloadcgeo-2b744ff80e20203f8d4e3e4a6891f799a500e8ac.zip
cgeo-2b744ff80e20203f8d4e3e4a6891f799a500e8ac.tar.gz
cgeo-2b744ff80e20203f8d4e3e4a6891f799a500e8ac.tar.bz2
fix #1833: Export / Import GPX
Diffstat (limited to 'main/src/cgeo/geocaching/files/GPXParser.java')
-rw-r--r--main/src/cgeo/geocaching/files/GPXParser.java12
1 files changed, 8 insertions, 4 deletions
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();
}