blob: 3361341a03ff7a2e5fc54fb7a7e3a76475a5b4c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package cgeo.geocaching.connector;
import cgeo.geocaching.Geocache;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
class WaymarkingConnector extends AbstractConnector {
@Override
@NonNull
public String getName() {
return "Waymarking";
}
@Override
@NonNull
public String getCacheUrl(@NonNull final Geocache cache) {
return getCacheUrlPrefix() + cache.getGeocode();
}
@Override
@NonNull
public String getHost() {
return "www.waymarking.com";
}
@Override
public boolean isOwner(@NonNull final Geocache cache) {
// this connector has no user management
return false;
}
@Override
@NonNull
protected String getCacheUrlPrefix() {
return "http://" + getHost() + "/waymarks/";
}
@Override
public boolean canHandle(@NonNull final String geocode) {
return StringUtils.startsWith(geocode, "WM");
}
@Override
@Nullable
public String getGeocodeFromUrl(@NonNull final String url) {
// coord.info URLs
String code = StringUtils.substringAfterLast(url, "coord.info/");
if (code != null && canHandle(code)) {
return code;
}
// waymarking URLs http://www.waymarking.com/waymarks/WMNCDT_American_Legion_Flagpole_1983_University_of_Oregon
code = StringUtils.substringBetween(url, "waymarks/", "_");
if (code != null && canHandle(code)) {
return code;
}
return null;
}
}
|