aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/files/GPXParser.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-06-08 11:42:58 +0200
committerBananeweizen <bananeweizen@gmx.de>2013-06-08 11:42:58 +0200
commit4db2bf20294175048bf1124bc29143074d01c42b (patch)
tree0e2428604c2793213f9fcc0e1932cb43b2361f4a /main/src/cgeo/geocaching/files/GPXParser.java
parent934945bddf33ec77ee77daff1add6498fe08e400 (diff)
downloadcgeo-4db2bf20294175048bf1124bc29143074d01c42b.zip
cgeo-4db2bf20294175048bf1124bc29143074d01c42b.tar.gz
cgeo-4db2bf20294175048bf1124bc29143074d01c42b.tar.bz2
new: support for waymarking GPX files
* Now one can load cache and waymark GPX together (as unknown caches) * I do not plan on adding any online features to the connector. * It is only there for creating the URLs for waymarks.
Diffstat (limited to 'main/src/cgeo/geocaching/files/GPXParser.java')
-rw-r--r--main/src/cgeo/geocaching/files/GPXParser.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java
index 4150b87..8412207 100644
--- a/main/src/cgeo/geocaching/files/GPXParser.java
+++ b/main/src/cgeo/geocaching/files/GPXParser.java
@@ -296,11 +296,7 @@ public abstract class GPXParser extends FileParser {
}
}
- if (StringUtils.isNotBlank(cache.getGeocode())
- && cache.getCoords() != null
- && ((type == null && sym == null)
- || StringUtils.contains(type, "geocache")
- || StringUtils.contains(sym, "geocache"))) {
+ if (isValidForImport()) {
fixCache(cache);
cache.setListId(listId);
cache.setDetailed(true);
@@ -451,6 +447,17 @@ public abstract class GPXParser extends FileParser {
}
});
+ // waypoint.urlname (name for waymarks)
+ waypoint.getChild(namespace, "urlname").setEndTextElementListener(new EndTextElementListener() {
+
+ @Override
+ public void end(String urlName) {
+ if (cache.getName().equals(cache.getGeocode()) && StringUtils.startsWith(cache.getGeocode(), "WM")) {
+ cache.setName(StringUtils.trim(urlName));
+ }
+ }
+ });
+
// for GPX 1.0, cache info comes from waypoint node (so called private children,
// for GPX 1.1 from extensions node
final Element cacheParent = getCacheParent(waypoint);
@@ -892,4 +899,17 @@ public abstract class GPXParser extends FileParser {
}
}
}
+
+ private boolean isValidForImport() {
+ if (StringUtils.isBlank(cache.getGeocode())) {
+ return false;
+ }
+ if (cache.getCoords() == null) {
+ return false;
+ }
+ return ((type == null && sym == null)
+ || StringUtils.contains(type, "geocache")
+ || StringUtils.contains(sym, "geocache")
+ || StringUtils.containsIgnoreCase(sym, "waymark"));
+ }
}