Changeset 6118 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2013-08-08T19:08:38+02:00 (11 years ago)
Author:
framm
Message:

apply patch by Peter Wendorff. closes #8945

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java

    r6085 r6118  
    2828            return b;
    2929        int i = url.indexOf('?');
    30         if (i == -1)
    31             return null;
     30        if (i == -1) {
     31            //probably it's a URL following the new scheme?
     32            if (url.indexOf('#') >= 0)
     33                return parseHashURLs(url);
     34            else
     35                return null;
     36        }
    3237        String[] args = url.substring(i+1).split("&");
    3338        HashMap<String, String> map = new HashMap<String, String>();
     
    7176    }
    7277
     78    /**
     79     * Openstreetmap.org changed it's URL scheme in August 2013, which breaks the URL parsing.
     80     * The following function, called by the old parse function if necessary, provides parsing new URLs
     81     * the new URLs follow the scheme http://www.openstreetmap.org/#map=18/51.71873/8.76164&layers=CN
     82     * @param url
     83     * @return
     84     */
     85    private static Bounds parseHashURLs(String url) {
     86        int startIndex = url.indexOf("=");
     87        int endIndex = url.indexOf("&");
     88        String coordPart = url.substring(startIndex+1, endIndex);
     89        System.out.println(coordPart);
     90
     91        String[] parts = coordPart.split("/");
     92        Bounds b = positionToBounds(Double.parseDouble(parts[1]),
     93                Double.parseDouble(parts[2]),
     94                Integer.parseInt(parts[0]));
     95        return b;
     96    }
     97
    7398    private static double parseDouble(HashMap<String, String> map, String key) {
    7499        if (map.containsKey(key))
Note: See TracChangeset for help on using the changeset viewer.