Ticket #8945: osmURLtoBoundsPatch.diff
| File osmURLtoBoundsPatch.diff, 1.8 KB (added by , 13 years ago) |
|---|
-
JOSM/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
27 27 if (b != null) 28 28 return b; 29 29 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 } 32 37 String[] args = url.substring(i+1).split("&"); 33 38 HashMap<String, String> map = new HashMap<String, String>(); 34 39 for (String arg : args) { … … 70 75 return b; 71 76 } 72 77 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 73 98 private static double parseDouble(HashMap<String, String> map, String key) { 74 99 if (map.containsKey(key)) 75 100 return Double.parseDouble(map.get(key));
