- Timestamp:
- 2007-05-21T22:07:24+02:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
r237 r241 14 14 import java.awt.event.KeyListener; 15 15 import java.util.HashMap; 16 import java.util.StringTokenizer; 16 17 17 18 import javax.swing.BorderFactory; … … 27 28 import org.openstreetmap.josm.gui.MapView; 28 29 import org.openstreetmap.josm.tools.GBC; 30 31 import com.sun.corba.se.spi.orb.StringPair; 29 32 /** 30 33 * Bounding box selector. … … 179 182 return null; 180 183 String[] args = url.substring(i+1).split("&"); 181 HashMap<String, Double> map = new HashMap<String, Double>();184 HashMap<String, String> map = new HashMap<String, String>(); 182 185 for (String arg : args) { 183 186 int eq = arg.indexOf('='); 184 187 if (eq != -1) { 185 try { 186 map.put(arg.substring(0, eq), Double.parseDouble(arg.substring(eq + 1))); 187 } catch (NumberFormatException e) { 188 } 189 } 190 } 191 try { 192 double size = 180.0 / Math.pow(2, map.get("zoom")); 193 return new Bounds( 194 new LatLon(map.get("lat") - size/2, map.get("lon") - size), 195 new LatLon(map.get("lat") + size/2, map.get("lon") + size)); 196 } catch (Exception x) { // NPE or IAE 197 return null; 188 map.put(arg.substring(0, eq), arg.substring(eq + 1)); 189 } 190 } 191 if (map.containsKey("bbox")) { 192 String bbox[] = map.get("bbox").split(","); 193 try { 194 return new Bounds( 195 new LatLon(Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0])), 196 new LatLon(Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2]))); 197 } catch (Exception x) { // NPE or IAE 198 return null; 199 } 200 201 } else { 202 try { 203 double size = 180.0 / Math.pow(2, Integer.parseInt(map.get("zoom"))); 204 return new Bounds( 205 new LatLon(Double.parseDouble(map.get("lat")) - size/2, Double.parseDouble(map.get("lon")) - size), 206 new LatLon(Double.parseDouble(map.get("lat")) + size/2, Double.parseDouble(map.get("lon")) + size)); 207 } catch (Exception x) { // NPE or IAE 208 return null; 209 } 198 210 } 199 211 }
Note:
See TracChangeset
for help on using the changeset viewer.