Changeset 12679 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2017-08-27T23:42:54+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmServerLocationReader.java
r10315 r12679 9 9 import java.util.List; 10 10 11 import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;12 11 import org.openstreetmap.josm.data.gpx.GpxData; 13 12 import org.openstreetmap.josm.data.notes.Note; … … 22 21 */ 23 22 public class OsmServerLocationReader extends OsmServerReader { 23 24 // CHECKSTYLE.OFF: MethodParamPad 25 // CHECKSTYLE.OFF: SingleSpaceSeparator 26 27 /** 28 * Patterns for OSM data download URLs. 29 * @since 12679 30 */ 31 public enum OsmUrlPattern { 32 OSM_API_URL ("https?://.*/api/0.6/(map|nodes?|ways?|relations?|\\*).*"), 33 OVERPASS_API_URL ("https?://.*/interpreter\\?data=.*"), 34 OVERPASS_API_XAPI_URL ("https?://.*/xapi(\\?.*\\[@meta\\]|_meta\\?).*"), 35 EXTERNAL_OSM_FILE ("https?://.*/.*\\.osm"); 36 37 private final String urlPattern; 38 39 OsmUrlPattern(String urlPattern) { 40 this.urlPattern = urlPattern; 41 } 42 43 /** 44 * Returns the URL pattern. 45 * @return the URL pattern 46 */ 47 public String pattern() { 48 return urlPattern; 49 } 50 } 51 52 /** 53 * Patterns for GPX download URLs. 54 * @since 12679 55 */ 56 public enum GpxUrlPattern { 57 TRACE_ID ("https?://.*(osm|openstreetmap).org/trace/\\p{Digit}+/data"), 58 USER_TRACE_ID("https?://.*(osm|openstreetmap).org/user/[^/]+/traces/(\\p{Digit}+)"), 59 EDIT_TRACE_ID("https?://.*(osm|openstreetmap).org/edit/?\\?gpx=(\\p{Digit}+)(#.*)?"), 60 61 TRACKPOINTS_BBOX("https?://.*/api/0.6/trackpoints\\?bbox=.*,.*,.*,.*"), 62 63 EXTERNAL_GPX_SCRIPT("https?://.*exportgpx.*"), 64 EXTERNAL_GPX_FILE ("https?://.*/(.*\\.gpx)"); 65 66 private final String urlPattern; 67 68 GpxUrlPattern(String urlPattern) { 69 this.urlPattern = urlPattern; 70 } 71 72 /** 73 * Returns the URL pattern. 74 * @return the URL pattern 75 */ 76 public String pattern() { 77 return urlPattern; 78 } 79 } 80 81 /** 82 * Patterns for Note download URLs. 83 * @since 12679 84 */ 85 public enum NoteUrlPattern { 86 API_URL ("https?://.*/api/0.6/notes.*"), 87 DUMP_FILE("https?://.*/(.*\\.osn(.bz2)?)"); 88 89 private final String urlPattern; 90 91 NoteUrlPattern(String urlPattern) { 92 this.urlPattern = urlPattern; 93 } 94 95 /** 96 * Returns the URL pattern. 97 * @return the URL pattern 98 */ 99 public String pattern() { 100 return urlPattern; 101 } 102 } 103 104 // CHECKSTYLE.ON: SingleSpaceSeparator 105 // CHECKSTYLE.ON: MethodParamPad 24 106 25 107 protected final String url; … … 163 245 gpxParsedProperly = reader.parse(false); 164 246 GpxData result = reader.getGpxData(); 165 result.fromServer = DownloadGpsTask.isFromServer(url);247 result.fromServer = isGpxFromServer(url); 166 248 return result; 167 249 } … … 185 267 } 186 268 } 269 270 /** 271 * Determines if the given URL denotes an OSM gpx-related API call. 272 * @param url The url to check 273 * @return true if the url matches "Trace ID" API call or "Trackpoints bbox" API call, false otherwise 274 * @see GpxData#fromServer 275 * @since 12679 276 */ 277 public static final boolean isGpxFromServer(String url) { 278 return url != null && (url.matches(GpxUrlPattern.TRACE_ID.pattern()) || url.matches(GpxUrlPattern.TRACKPOINTS_BBOX.pattern())); 279 } 187 280 }
Note:
See TracChangeset
for help on using the changeset viewer.