Changeset 2626 in josm for trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
- Timestamp:
- 2009-12-13T11:48:12+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r2540 r2626 31 31 String bbox[] = map.get("bbox").split(","); 32 32 b = new Bounds( 33 new LatLon(Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0])),34 new LatLon(Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2])));33 new LatLon(Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0])), 34 new LatLon(Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2]))); 35 35 } else if (map.containsKey("minlat")) { 36 36 String s = map.get("minlat"); … … 45 45 } else { 46 46 b = positionToBounds(parseDouble(map, "lat"), 47 48 47 parseDouble(map, "lon"), 48 Integer.parseInt(map.get("zoom"))); 49 49 } 50 50 } catch (NumberFormatException x) { … … 81 81 */ 82 82 private static Bounds parseShortLink(final String url) { 83 if (!url.startsWith(SHORTLINK_PREFIX)) {83 if (!url.startsWith(SHORTLINK_PREFIX)) 84 84 return null; 85 }86 85 final String shortLink = url.substring(SHORTLINK_PREFIX.length()); 87 86 … … 125 124 // 2**32 == 4294967296 126 125 return positionToBounds(y * 180.0 / 4294967296.0 - 90.0, 127 128 129 126 x * 360.0 / 4294967296.0 - 180.0, 127 // TODO: -2 was not in ruby code 128 zoom - 8 - (zoomOffset % 3) - 2); 130 129 } 131 130 … … 133 132 final double size = 180.0 / Math.pow(2, zoom); 134 133 return new Bounds( 135 136 134 new LatLon(lat - size/2, lon - size), 135 new LatLon(lat + size/2, lon + size)); 137 136 } 138 137 … … 144 143 int zoom = 0; 145 144 while (zoom <= 20) { 146 if (size >= 180) 145 if (size >= 180) { 147 146 break; 147 } 148 148 size *= 2; 149 149 zoom++; … … 163 163 double lon = (Math.round(pos.lon() * decimals)); 164 164 lon /= decimals; 165 return new String("http://www.openstreetmap.org/?lat="+lat+"&lon="+lon+"&zoom="+zoom);165 return "http://www.openstreetmap.org/?lat="+lat+"&lon="+lon+"&zoom="+zoom; 166 166 } 167 167 }
Note:
See TracChangeset
for help on using the changeset viewer.