Changeset 11329 in josm


Ignore:
Timestamp:
2016-11-27T10:42:36+01:00 (4 months ago)
Author:
simon04
Message:

see #13201 - OsmUrlToBounds: also take Geo URLs into account

This adds Geo URL support to various actions, such as:

  • Download dialog
  • Jump to Position
  • Commandline parameters (OSM or GPS download)
Location:
trunk
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java

    r11286 r11329  
    2525
    2626import org.openstreetmap.josm.Main;
    27 import org.openstreetmap.josm.actions.downloadtasks.DownloadGeoUrlTask;
    2827import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
    2928import org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTask;
     
    7574        addDownloadTaskClass(DownloadOsmChangeTask.class);
    7675        addDownloadTaskClass(DownloadOsmUrlTask.class);
    77         addDownloadTaskClass(DownloadGeoUrlTask.class);
    7876        addDownloadTaskClass(DownloadOsmIdTask.class);
    7977        addDownloadTaskClass(DownloadOsmCompressedTask.class);
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmUrlTask.java

    r7937 r11329  
    77
    88import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     9import org.openstreetmap.josm.tools.GeoUrlToBounds;
    910import org.openstreetmap.josm.tools.OsmUrlToBounds;
    1011
     
    2425        return new String[]{
    2526                "https?://www\\.(osm|openstreetmap)\\.org/\\?lat=.*&lon=.*",
    26                 "https?://www\\.(osm|openstreetmap)\\.org/(.*)?#map=\\p{Digit}+/.*/.*"};
     27                "https?://www\\.(osm|openstreetmap)\\.org/(.*)?#map=\\p{Digit}+/.*/.*",
     28                GeoUrlToBounds.PATTERN.toString(),
     29        };
    2730    }
    2831
  • trunk/src/org/openstreetmap/josm/tools/GeoUrlToBounds.java

    r10757 r11329  
    1212/**
    1313 * Parses a Geo URL (as specified in <a href="https://tools.ietf.org/html/rfc5870">RFC 5870</a>) into {@link Bounds}.
     14 *
     15 * Note that Geo URLs are also handled by {@link OsmUrlToBounds}.
    1416 */
    1517public final class GeoUrlToBounds {
  • trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java

    r11302 r11329  
    1717import org.openstreetmap.josm.gui.util.GuiHelper;
    1818
     19/**
     20 * Parses various URL used in OpenStreetMap projects into {@link Bounds}.
     21 */
    1922public final class OsmUrlToBounds {
    2023    private static final String SHORTLINK_PREFIX = "http://osm.org/go/";
     
    2427    }
    2528
     29    /**
     30     * Parses an URL into {@link Bounds}
     31     * @param url the URL to be parsed
     32     * @return the parsed {@link Bounds}, or {@code null}
     33     */
    2634    public static Bounds parse(String url) {
     35        if (url.startsWith("geo:")) {
     36            return GeoUrlToBounds.parse(url);
     37        }
    2738        try {
    2839            // a percent sign indicates an encoded URL (RFC 1738).
  • trunk/test/unit/org/openstreetmap/josm/tools/OsmUrlToBoundsTest.java

    r11317 r11329  
    3939    private static final ParseTestItem[] parseTestData = {
    4040        new ParseTestItem("https://www.openstreetmap.org", null),
     41        new ParseTestItem("geo:12.34,56.78?z=9",
     42                OsmUrlToBounds.positionToBounds(12.34, 56.78, 9)),
    4143        new ParseTestItem("https://www.openstreetmap.org/?bbox=-0.489,51.28,0.236,51.686",
    4244                new Bounds(51.28, -0.489, 51.686, 0.236)),
Note: See TracChangeset for help on using the changeset viewer.