aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/files/GPXParser.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/files/GPXParser.java')
-rw-r--r--main/src/cgeo/geocaching/files/GPXParser.java33
1 files changed, 28 insertions, 5 deletions
diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java
index e083f58..f8ec61c 100644
--- a/main/src/cgeo/geocaching/files/GPXParser.java
+++ b/main/src/cgeo/geocaching/files/GPXParser.java
@@ -51,6 +51,7 @@ public abstract class GPXParser extends FileParser {
*/
private static final Pattern patternGeocode = Pattern.compile("([A-Z][0-9A-Z]+)");
private static final Pattern patternGuid = Pattern.compile(".*" + Pattern.quote("guid=") + "([0-9a-z\\-]+)", Pattern.CASE_INSENSITIVE);
+ private static final Pattern patternUrlGeocode = Pattern.compile(".*" + Pattern.quote("wp=") + "([A-Z][0-9A-Z]+)", Pattern.CASE_INSENSITIVE);
/**
* supported groundspeak extensions of the GPX format
*/
@@ -228,7 +229,7 @@ public abstract class GPXParser extends FileParser {
static Date parseDate(String inputUntrimmed) throws ParseException {
String input = inputUntrimmed.trim();
- // remove milli seconds to reduce number of needed patterns
+ // remove milliseconds to reduce number of needed patterns
final Matcher matcher = PATTERN_MILLISECONDS.matcher(input);
input = matcher.replaceFirst("");
if (input.contains("Z")) {
@@ -422,6 +423,11 @@ public abstract class GPXParser extends FileParser {
cache.setGuid(guid);
}
}
+ final Matcher matcherCode = patternUrlGeocode.matcher(url);
+ if (matcherCode.matches()) {
+ String geocode = matcherCode.group(1);
+ cache.setGeocode(geocode);
+ }
}
});
@@ -485,8 +491,17 @@ public abstract class GPXParser extends FileParser {
gcCache.getChild(nsGC, "owner").setEndTextElementListener(new EndTextElementListener() {
@Override
- public void end(String cacheOwner) {
- cache.setOwner(validate(cacheOwner));
+ public void end(String ownerUserId) {
+ cache.setOwnerUserId(validate(ownerUserId));
+ }
+ });
+
+ // waypoint.cache.getOwner()
+ gcCache.getChild(nsGC, "placed_by").setEndTextElementListener(new EndTextElementListener() {
+
+ @Override
+ public void end(String ownerDisplayName) {
+ cache.setOwnerDisplayName(validate(ownerDisplayName));
}
});
@@ -775,9 +790,17 @@ public abstract class GPXParser extends FileParser {
return WaypointType.TRAILHEAD;
} else if ("final location".equalsIgnoreCase(sym)) {
return WaypointType.FINAL;
- } else {
- return WaypointType.WAYPOINT;
}
+ // this is not fully correct, but lets also look for localized waypoint types
+ for (WaypointType waypointType : WaypointType.ALL_TYPES_EXCEPT_OWN) {
+ final String localized = waypointType.getL10n();
+ if (StringUtils.isNotEmpty(localized)) {
+ if (localized.equalsIgnoreCase(sym)) {
+ return waypointType;
+ }
+ }
+ }
+ return WaypointType.WAYPOINT;
}
private void findGeoCode(final String input) {