- Timestamp:
- 2016-10-02T22:12:40+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
r10432 r11073 6 6 import java.io.IOException; 7 7 import java.net.URL; 8 import java.util.Optional; 8 9 import java.util.concurrent.Future; 9 10 import java.util.regex.Matcher; 10 11 import java.util.regex.Pattern; 12 import java.util.stream.Stream; 11 13 12 14 import org.openstreetmap.josm.Main; … … 39 41 40 42 private static final String PATTERN_TRACE_ID = "https?://.*(osm|openstreetmap).org/trace/\\p{Digit}+/data"; 43 private static final String PATTERN_USER_TRACE_ID = "https?://.*(osm|openstreetmap).org/user/[^/]+/traces/(\\p{Digit}+)"; 44 private static final String PATTERN_EDIT_TRACE_ID = "https?://.*(osm|openstreetmap).org/edit/?\\?gpx=(\\p{Digit}+)"; 41 45 42 46 private static final String PATTERN_TRACKPOINTS_BBOX = "https?://.*/api/0.6/trackpoints\\?bbox=.*,.*,.*,.*"; … … 49 53 @Override 50 54 public String[] getPatterns() { 51 return new String[] {PATTERN_EXTERNAL_GPX_FILE, PATTERN_EXTERNAL_GPX_SCRIPT, PATTERN_TRACE_ID, PATTERN_TRACKPOINTS_BBOX}; 55 return new String[] { 56 PATTERN_EXTERNAL_GPX_FILE, PATTERN_EXTERNAL_GPX_SCRIPT, 57 PATTERN_TRACE_ID, PATTERN_USER_TRACE_ID, PATTERN_EDIT_TRACE_ID, 58 PATTERN_TRACKPOINTS_BBOX, 59 }; 52 60 } 53 61 … … 69 77 public Future<?> loadUrl(boolean newLayer, String url, ProgressMonitor progressMonitor) { 70 78 CheckParameterUtil.ensureParameterNotNull(url, "url"); 79 final Optional<String> mappedUrl = Stream.of(PATTERN_USER_TRACE_ID, PATTERN_EDIT_TRACE_ID) 80 .map(p -> Pattern.compile(p).matcher(url)) 81 .filter(Matcher::matches) 82 .map(m -> "https://www.openstreetmap.org/trace/" + m.group(2) + "/data") 83 .findFirst(); 84 if (mappedUrl.isPresent()) { 85 return loadUrl(newLayer, mappedUrl.get(), progressMonitor); 86 } 71 87 if (url.matches(PATTERN_TRACE_ID) 72 88 || url.matches(PATTERN_EXTERNAL_GPX_SCRIPT)
Note:
See TracChangeset
for help on using the changeset viewer.