Ticket #9024: bbox.diff
File bbox.diff, 36.8 KB (added by , 11 years ago) |
---|
-
src/org/openstreetmap/josm/actions/JumpToAction.java
126 126 if(!url.hasFocus()) return; 127 127 Bounds b = OsmUrlToBounds.parse(url.getText()); 128 128 if (b != null) { 129 lat.setText(Double.toString((b.getMin ().lat() + b.getMax().lat())/2));130 lon.setText(Double.toString((b.getMin ().lon() + b.getMax().lon())/2));129 lat.setText(Double.toString((b.getMinLat() + b.getMaxLat())/2)); 130 lon.setText(Double.toString((b.getMinLon() + b.getMaxLon())/2)); 131 131 132 132 int zoomLvl = 16; 133 133 String[] args = url.getText().substring(url.getText().indexOf('?')+1).split("&"); -
src/org/openstreetmap/josm/data/Bounds.java
8 8 import java.text.MessageFormat; 9 9 10 10 import org.openstreetmap.josm.data.coor.LatLon; 11 import org.openstreetmap.josm.data.osm.BBox; 11 12 import org.openstreetmap.josm.tools.CheckParameterUtil; 12 13 13 14 /** … … 26 27 return new LatLon(minLat, minLon); 27 28 } 28 29 30 public double getMinLat() { 31 return minLat; 32 } 33 34 public double getMinLon() { 35 return minLon; 36 } 37 29 38 public LatLon getMax() { 30 39 return new LatLon(maxLat, maxLon); 31 40 } 32 41 42 public double getMaxLat() { 43 return maxLat; 44 } 45 46 public double getMaxLon() { 47 return maxLon; 48 } 49 33 50 public enum ParseMethod { 34 51 MINLAT_MINLON_MAXLAT_MAXLON, 35 52 LEFT_BOTTOM_RIGHT_TOP … … 51 68 } 52 69 53 70 public Bounds(LatLon b, boolean roundToOsmPrecision) { 71 this(b.lat(), b.lon(), roundToOsmPrecision); 72 } 73 74 public Bounds(double lat, double lon, boolean roundToOsmPrecision) { 54 75 // Do not call this(b, b) to avoid GPX performance issue (see #7028) until roundToOsmPrecision() is improved 55 76 if (roundToOsmPrecision) { 56 this.minLat = LatLon.roundToOsmPrecision( b.lat());57 this.minLon = LatLon.roundToOsmPrecision( b.lon());77 this.minLat = LatLon.roundToOsmPrecision(lat); 78 this.minLon = LatLon.roundToOsmPrecision(lon); 58 79 } else { 59 this.minLat = b.lat();60 this.minLon = b.lon();80 this.minLat = lat; 81 this.minLon = lon; 61 82 } 62 83 this.maxLat = this.minLat; 63 84 this.maxLon = this.minLon; … … 152 173 return roundToOsmPrecision ? LatLon.roundToOsmPrecision(value) : value; 153 174 } 154 175 155 public Bounds( Bounds other) {156 this(other. getMin(), other.getMax());176 public Bounds(final Bounds other) { 177 this(other.minLat, other.minLon, other.maxLat, other.maxLon); 157 178 } 158 179 159 180 public Bounds(Rectangle2D rect) { … … 185 206 this.maxLon = LatLon.roundToOsmPrecision(LatLon.toIntervalLon(center.lon() + lonExtent / 2)); 186 207 } 187 208 209 public BBox toBBox(){ 210 return new BBox(minLon, minLat, maxLon, maxLat); 211 } 212 188 213 @Override public String toString() { 189 214 return "Bounds["+minLat+","+minLon+","+maxLat+","+maxLon+"]"; 190 215 } … … 202 227 */ 203 228 public LatLon getCenter() 204 229 { 205 if (crosses180thMeridian()) { 206 LatLon result = new LatLon(minLat, minLon-360.0).getCenter(getMax()); 207 if (result.lon() < -180.0) { 208 result = new LatLon(result.lat(), result.lon() + 360.0); 230 if (crosses180thMeridian()) { 231 double lat = (minLat + maxLat) / 2; 232 double lon = (minLon + maxLon - 360.0) / 2; 233 if (lon < -180.0){ 234 lon += 360.0; 209 235 } 210 return result;236 return new LatLon(lat, lon); 211 237 } else { 212 return getMin().getCenter(getMax());238 return new LatLon((minLat + maxLat) / 2, (minLon + maxLon) / 2); 213 239 } 214 240 } 215 241 … … 217 243 * Extend the bounds if necessary to include the given point. 218 244 */ 219 245 public void extend(LatLon ll) { 220 if (ll.lat() < minLat) { 221 minLat = LatLon.roundToOsmPrecision(ll.lat()); 246 extend(ll.lat(), ll.lon()); 247 } 248 249 public void extend(final double lat, final double lon) { 250 if (lat < minLat) { 251 minLat = LatLon.roundToOsmPrecision(lat); 222 252 } 223 if (l l.lat()> maxLat) {224 maxLat = LatLon.roundToOsmPrecision(l l.lat());253 if (lat > maxLat) { 254 maxLat = LatLon.roundToOsmPrecision(lat); 225 255 } 226 256 if (crosses180thMeridian()) { 227 if (l l.lon() > maxLon && ll.lon()< minLon) {228 if (Math.abs(l l.lon() - minLon) <= Math.abs(ll.lon()- maxLon)) {229 minLon = LatLon.roundToOsmPrecision(l l.lon());257 if (lon > maxLon && lon < minLon) { 258 if (Math.abs(lon - minLon) <= Math.abs(lon - maxLon)) { 259 minLon = LatLon.roundToOsmPrecision(lon); 230 260 } else { 231 maxLon = LatLon.roundToOsmPrecision(l l.lon());261 maxLon = LatLon.roundToOsmPrecision(lon); 232 262 } 233 263 } 234 264 } else { 235 if (l l.lon()< minLon) {236 minLon = LatLon.roundToOsmPrecision(l l.lon());265 if (lon < minLon) { 266 minLon = LatLon.roundToOsmPrecision(lon); 237 267 } 238 if (l l.lon()> maxLon) {239 maxLon = LatLon.roundToOsmPrecision(l l.lon());268 if (lon > maxLon) { 269 maxLon = LatLon.roundToOsmPrecision(lon); 240 270 } 241 271 } 242 272 } 243 273 244 274 public void extend(Bounds b) { 245 extend(b. getMin());246 extend(b. getMax());275 extend(b.minLat, b.minLon); 276 extend(b.maxLat, b.maxLon); 247 277 } 248 278 249 279 /** … … 323 353 * @return true, if this bounds are <em>collapsed</em> 324 354 */ 325 355 public boolean isCollapsed() { 326 return getMin().equals(getMax()); 356 return (minLat == maxLat) && (minLon == maxLon); 357 //return getMin().equals(getMax()); 327 358 } 328 359 329 360 public boolean isOutOfTheWorld() { -
src/org/openstreetmap/josm/data/coor/Coordinate.java
3 3 4 4 import java.io.Serializable; 5 5 6 import org.openstreetmap.josm.data.osm.BBox; 7 6 8 /** 7 9 * Base class of points of both coordinate systems. 8 10 * … … 88 90 return dx*dx + dy*dy; 89 91 } 90 92 93 /** 94 * Converts to single point BBox. 95 * 96 * @return 97 */ 98 public BBox toBBox(){ 99 return new BBox(x, y); 100 } 101 102 /** 103 * Creates extension size bbox around point. 104 * 105 * @param extension 106 * @return 107 */ 108 public BBox toBBox(final double extension){ 109 return new BBox(x - extension, y - extension, x + extension, y + extension); 110 } 111 112 91 113 @Override 92 114 public int hashCode() { 93 115 final int prime = 31; -
src/org/openstreetmap/josm/data/coor/LatLon.java
215 215 */ 216 216 public boolean isOutSideWorld() { 217 217 Bounds b = Main.getProjection().getWorldBoundsLatLon(); 218 return lat() < b.getMin ().lat() || lat() > b.getMax().lat() ||219 lon() < b.getMin ().lon() || lon() > b.getMax().lon();218 return lat() < b.getMinLat() || lat() > b.getMaxLat() || 219 lon() < b.getMinLon() || lon() > b.getMaxLon(); 220 220 } 221 221 222 222 /** -
src/org/openstreetmap/josm/data/gpx/WayPoint.java
50 50 * We "inline" lat/lon, rather than usinga LatLon internally => reduces memory overhead. Relevant 51 51 * because a lot of GPX waypoints are created when GPS tracks are downloaded from the OSM server. 52 52 */ 53 private double lat = 0;54 private double lon = 0;53 private final double lat; 54 private final double lon; 55 55 56 56 /* 57 57 * internal cache of projected coordinates -
src/org/openstreetmap/josm/data/osm/BBox.java
3 3 4 4 import java.util.Arrays; 5 5 6 import org.openstreetmap.josm.data.Bounds;7 6 import org.openstreetmap.josm.data.coor.LatLon; 8 7 import org.openstreetmap.josm.data.coor.QuadTiling; 9 8 import org.openstreetmap.josm.tools.Utils; … … 15 14 private double ymin = Double.POSITIVE_INFINITY; 16 15 private double ymax = Double.NEGATIVE_INFINITY; 17 16 18 public BBox(Bounds bounds) { 19 add(bounds.getMin()); 20 add(bounds.getMax()); 17 /** 18 * Single point bbox. 19 * 20 * @param x 21 * @param y 22 */ 23 public BBox(final double x, final double y) { 24 xmax = xmin = x; 25 ymax = ymin = y; 26 sanity(); 21 27 } 22 28 29 public static BBox fromLatLonPair(final double lat1, final double lon1, final double lat2, final double lon2){ 30 return new BBox(lon1, lat1, lon2, lat2); 31 } 32 23 33 public BBox(LatLon a, LatLon b) { 24 add(a); 25 add(b); 34 this(a.lon(), a.lat(), b.lon(), b.lat()); 26 35 } 27 36 28 37 public BBox(BBox copy) { … … 33 42 } 34 43 35 44 public BBox(double a_x, double a_y, double b_x, double b_y) { 36 xmin = Math.min(a_x, b_x); 37 xmax = Math.max(a_x, b_x); 38 ymin = Math.min(a_y, b_y); 39 ymax = Math.max(a_y, b_y); 45 46 if (a_x > b_x){ 47 xmax = a_x; 48 xmin = b_x; 49 } 50 else { 51 xmax = b_x; 52 xmin = a_x; 53 } 54 55 if (a_y > b_y){ 56 ymax = a_y; 57 ymin = b_y; 58 } 59 else { 60 ymax = b_y; 61 ymin = a_y; 62 } 63 64 40 65 sanity(); 41 66 } 42 67 … … 83 108 * Extends this bbox to include the point (x, y) 84 109 */ 85 110 public void add(double x, double y) { 86 xmin = Math.min(xmin, x); 87 xmax = Math.max(xmax, x); 88 ymin = Math.min(ymin, y); 89 ymax = Math.max(ymax, y); 111 112 if (x < xmin){ 113 xmin = x; 114 } 115 else if (x > xmax){ 116 xmax = x; 117 } 118 119 if (y < ymin){ 120 ymin = y; 121 } 122 else if (y > ymax){ 123 ymax = y; 124 } 125 90 126 sanity(); 91 127 } 92 128 93 129 public void add(BBox box) { 94 add(box.getTopLeft()); 95 add(box.getBottomRight()); 130 xmin = Math.min(xmin, box.xmin); 131 xmax = Math.max(xmax, box.xmax); 132 ymin = Math.min(ymin, box.ymin); 133 ymax = Math.max(ymax, box.ymax); 134 sanity(); 96 135 } 97 136 98 137 public void addPrimitive(OsmPrimitive primitive, double extraSpace) { … … 154 193 return new LatLon(ymax, xmin); 155 194 } 156 195 196 public double getTopLeftLat() { 197 return ymax; 198 } 199 200 public double getTopLeftLon() { 201 return xmin; 202 } 203 157 204 public LatLon getBottomRight() { 158 205 return new LatLon(ymin, xmax); 159 206 } 160 207 208 public double getBottomRightLat() { 209 return ymin; 210 } 211 212 public double getBottomRightLon() { 213 return xmax; 214 } 215 161 216 public LatLon getCenter() { 162 217 return new LatLon(ymin + (ymax-ymin)/2.0, xmin + (xmax-xmin)/2.0); 163 218 } -
src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java
80 80 if (!n.isIncomplete() && !n.isDeleted()) { 81 81 LatLon c = n.getCoor(); 82 82 if (c != null) { 83 BBox box = new BBox(new LatLon(c.lat() - 0.0001, c.lon() - 0.0001), new LatLon(c.lat() + 0.0001, c.lon() + 0.0001));83 BBox box = c.toBBox(0.0001); 84 84 if (!dataSet.searchNodes(box).contains(n)) { 85 85 printError("SEARCH NODES", "%s not found using Dataset.searchNodes()", n); 86 86 } -
src/org/openstreetmap/josm/data/osm/QuadBuckets.java
116 116 LatLon bottom_left = this.coor(); 117 117 double lat = bottom_left.lat() + parent.height() / 2; 118 118 double lon = bottom_left.lon() + parent.width() / 2; 119 LatLon top_right = new LatLon(lat, lon); 120 return new BBox(bottom_left, top_right); 119 return BBox.fromLatLonPair(bottom_left.lat(),bottom_left.lon(), lat, lon); 121 120 } 122 121 123 122 QBLevel<T> findBucket(BBox bbox) { -
src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
1403 1403 @Override 1404 1404 public void render(final DataSet data, boolean renderVirtualNodes, Bounds bounds) { 1405 1405 //long start = System.currentTimeMillis(); 1406 BBox bbox = new BBox(bounds);1406 BBox bbox = bounds.toBBox(); 1407 1407 getSettings(renderVirtualNodes); 1408 1408 1409 1409 boolean drawArea = circum <= Main.pref.getInteger("mappaint.fillareas", 10000000); -
src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java
156 156 @SuppressWarnings("unchecked") 157 157 @Override 158 158 public void render(DataSet data, boolean virtual, Bounds bounds) { 159 BBox bbox = new BBox(bounds);159 BBox bbox = bounds.toBBox(); 160 160 this.ds = data; 161 161 getSettings(virtual); 162 162 -
src/org/openstreetmap/josm/data/projection/CustomProjection.java
123 123 datum = WGS84Datum.INSTANCE; 124 124 proj = new Mercator(); 125 125 bounds = new Bounds( 126 new LatLon(-85.05112877980659, -180.0),127 new LatLon(85.05112877980659, 180.0), true);126 -85.05112877980659, -180.0, 127 85.05112877980659, 180.0, true); 128 128 } else { 129 129 Map<String, String> parameters = parseParameterList(pref); 130 130 ellps = parseEllipsoid(parameters); -
src/org/openstreetmap/josm/gui/BookmarkList.java
183 183 Bookmark b = (Bookmark)o; 184 184 array[0] = b.getName(); 185 185 Bounds area = b.getArea(); 186 array[1] = String.valueOf(area.getMin ().lat());187 array[2] = String.valueOf(area.getMin ().lon());188 array[3] = String.valueOf(area.getMax ().lat());189 array[4] = String.valueOf(area.getMax ().lon());186 array[1] = String.valueOf(area.getMinLat()); 187 array[2] = String.valueOf(area.getMinLon()); 188 array[3] = String.valueOf(area.getMaxLat()); 189 array[4] = String.valueOf(area.getMaxLon()); 190 190 coll.add(Arrays.asList(array)); 191 191 } 192 192 Main.pref.putArray("bookmarks", coll); … … 216 216 Bounds area = b.getArea(); 217 217 StringBuffer sb = new StringBuffer(); 218 218 sb.append("<html>min[latitude,longitude]=<strong>[") 219 .append(area.getMin ().lat()).append(",").append(area.getMin().lon()).append("]</strong>")219 .append(area.getMinLat()).append(",").append(area.getMinLon()).append("]</strong>") 220 220 .append("<br>") 221 221 .append("max[latitude,longitude]=<strong>[") 222 .append(area.getMax ().lat()).append(",").append(area.getMax().lon()).append("]</strong>")222 .append(area.getMaxLat()).append(",").append(area.getMaxLon()).append("]</strong>") 223 223 .append("</html>"); 224 224 return sb.toString(); 225 225 -
src/org/openstreetmap/josm/gui/MapView.java
635 635 // draw world borders 636 636 tempG.setColor(Color.WHITE); 637 637 Bounds b = getProjection().getWorldBoundsLatLon(); 638 double lat = b.getMin ().lat();639 double lon = b.getMin ().lon();638 double lat = b.getMinLat(); 639 double lon = b.getMinLon(); 640 640 641 641 Point p = getPoint(b.getMin()); 642 642 … … 655 655 p = getPoint(new LatLon(lat, lon >= max ? max : lon)); 656 656 path.lineTo(p.x, p.y); 657 657 } 658 lon = max; max = b.getMin ().lat();658 lon = max; max = b.getMinLat(); 659 659 for(; lat >= max; lat -= 1.0) 660 660 { 661 661 p = getPoint(new LatLon(lat <= max ? max : lat, lon)); 662 662 path.lineTo(p.x, p.y); 663 663 } 664 lat = max; max = b.getMin ().lon();664 lat = max; max = b.getMinLon(); 665 665 for(; lon >= max; lon -= 1.0) 666 666 { 667 667 p = getPoint(new LatLon(lat, lon <= max ? max : lon)); -
src/org/openstreetmap/josm/gui/NavigatableComponent.java
200 200 201 201 private EastNorth calculateDefaultCenter() { 202 202 Bounds b = Main.getProjection().getWorldBoundsLatLon(); 203 double lat = (b.getMax ().lat() + b.getMin().lat())/2;204 double lon = (b.getMax ().lon() + b.getMin().lon())/2;205 203 double lat = (b.getMaxLat() + b.getMinLat())/2; 204 double lon = (b.getMaxLon() + b.getMinLon())/2; 205 // is it correct? b.getCenter() makes some adjustments... 206 206 return Main.getProjection().latlon2eastNorth(new LatLon(lat, lon)); 207 207 } 208 208 … … 400 400 boolean changed = false; 401 401 double lat = cl.lat(); 402 402 double lon = cl.lon(); 403 if(lat < b.getMin ().lat()) {changed = true; lat = b.getMin().lat(); }404 else if(lat > b.getMax ().lat()) {changed = true; lat = b.getMax().lat(); }405 if(lon < b.getMin ().lon()) {changed = true; lon = b.getMin().lon(); }406 else if(lon > b.getMax ().lon()) {changed = true; lon = b.getMax().lon(); }403 if(lat < b.getMinLat()) {changed = true; lat = b.getMinLat(); } 404 else if(lat > b.getMaxLat()) {changed = true; lat = b.getMaxLat(); } 405 if(lon < b.getMinLon()) {changed = true; lon = b.getMinLon(); } 406 else if(lon > b.getMaxLon()) {changed = true; lon = b.getMaxLon(); } 407 407 if(changed) { 408 408 newCenter = Projections.project(new LatLon(lat,lon)); 409 409 } 410 410 int width = getWidth()/2; 411 411 int height = getHeight()/2; 412 LatLon l1 = new LatLon(b.getMin ().lat(), lon);413 LatLon l2 = new LatLon(b.getMax ().lat(), lon);412 LatLon l1 = new LatLon(b.getMinLat(), lon); 413 LatLon l2 = new LatLon(b.getMaxLat(), lon); 414 414 EastNorth e1 = getProjection().latlon2eastNorth(l1); 415 415 EastNorth e2 = getProjection().latlon2eastNorth(l2); 416 416 double d = e2.north() - e1.north(); 417 417 if(d < height*newScale) 418 418 { 419 419 double newScaleH = d/height; 420 e1 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMin ().lon()));421 e2 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMax ().lon()));420 e1 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMinLon())); 421 e2 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMaxLon())); 422 422 d = e2.east() - e1.east(); 423 423 if(d < width*newScale) { 424 424 newScale = Math.max(newScaleH, d/width); -
src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java
352 352 */ 353 353 @Override 354 354 public void setBoundingBox(Bounds bbox) { 355 if (bbox == null || (bbox.getMin ().lat() == 0.0 && bbox.getMin().lon() == 0.0356 && bbox.getMax ().lat() == 0.0 && bbox.getMax().lon() == 0.0)) {355 if (bbox == null || (bbox.getMinLat() == 0.0 && bbox.getMinLon() == 0.0 356 && bbox.getMaxLat() == 0.0 && bbox.getMaxLon() == 0.0)) { 357 357 this.bbox = null; 358 358 iSelectionRectStart = null; 359 359 iSelectionRectEnd = null; … … 362 362 } 363 363 364 364 this.bbox = bbox; 365 double minLon = bbox.getMin ().lon();366 double maxLon = bbox.getMax ().lon();365 double minLon = bbox.getMinLon(); 366 double maxLon = bbox.getMaxLon(); 367 367 368 368 if (bbox.crosses180thMeridian()) { 369 369 minLon -= 360.0; 370 370 } 371 371 372 int y1 = OsmMercator.LatToY(bbox.getMin ().lat(), MAX_ZOOM);373 int y2 = OsmMercator.LatToY(bbox.getMax ().lat(), MAX_ZOOM);372 int y1 = OsmMercator.LatToY(bbox.getMinLat(), MAX_ZOOM); 373 int y2 = OsmMercator.LatToY(bbox.getMaxLat(), MAX_ZOOM); 374 374 int x1 = OsmMercator.LonToX(minLon, MAX_ZOOM); 375 375 int x2 = OsmMercator.LonToX(maxLon, MAX_ZOOM); 376 376 … … 378 378 iSelectionRectEnd = new Point(Math.max(x1, x2), Math.max(y1, y2)); 379 379 380 380 // calc the screen coordinates for the new selection rectangle 381 MapMarkerDot xmin_ymin = new MapMarkerDot(bbox.getMin ().lat(), bbox.getMin().lon());382 MapMarkerDot xmax_ymax = new MapMarkerDot(bbox.getMax ().lat(), bbox.getMax().lon());381 MapMarkerDot xmin_ymin = new MapMarkerDot(bbox.getMinLat(), bbox.getMinLon()); 382 MapMarkerDot xmax_ymax = new MapMarkerDot(bbox.getMaxLat(), bbox.getMaxLon()); 383 383 384 384 Vector<MapMarker> marker = new Vector<MapMarker>(2); 385 385 marker.add(xmin_ymin); -
src/org/openstreetmap/josm/gui/bbox/TileSelectionBBoxChooser.java
152 152 if (bbox == null) return; 153 153 154 154 // calc the screen coordinates for the new selection rectangle 155 MapMarkerDot xmin_ymin = new MapMarkerDot(bbox.getMin ().lat(), bbox.getMin().lon());156 MapMarkerDot xmax_ymax = new MapMarkerDot(bbox.getMax ().lat(), bbox.getMax().lon());155 MapMarkerDot xmin_ymin = new MapMarkerDot(bbox.getMinLat(), bbox.getMinLon()); 156 MapMarkerDot xmax_ymax = new MapMarkerDot(bbox.getMaxLat(), bbox.getMaxLon()); 157 157 158 158 Vector<MapMarker> marker = new Vector<MapMarker>(2); 159 159 marker.add(xmin_ymin); … … 341 341 TileBounds tb = new TileBounds(); 342 342 tb.zoomLevel = (Integer) spZoomLevel.getValue(); 343 343 tb.min = new Point( 344 Math.max(0,lonToTileX(tb.zoomLevel, bbox.getMin ().lon())),345 Math.max(0,latToTileY(tb.zoomLevel, bbox.getMax ().lat()-.00001))344 Math.max(0,lonToTileX(tb.zoomLevel, bbox.getMinLon())), 345 Math.max(0,latToTileY(tb.zoomLevel, bbox.getMaxLat() - 0.00001)) 346 346 ); 347 347 tb.max = new Point( 348 Math.max(0,lonToTileX(tb.zoomLevel, bbox.getMax ().lon())),349 Math.max(0,latToTileY(tb.zoomLevel, bbox.getMin ().lat()-.00001))348 Math.max(0,lonToTileX(tb.zoomLevel, bbox.getMaxLon())), 349 Math.max(0,latToTileY(tb.zoomLevel, bbox.getMinLat() - 0.00001)) 350 350 ); 351 351 doFireTileBoundChanged = false; 352 352 setTileBounds(tb); … … 681 681 min = null; 682 682 max = null; 683 683 } else { 684 int y1 = OsmMercator.LatToY(bbox.getMin ().lat(), MAX_ZOOM);685 int y2 = OsmMercator.LatToY(bbox.getMax ().lat(), MAX_ZOOM);686 int x1 = OsmMercator.LonToX(bbox.getMin ().lon(), MAX_ZOOM);687 int x2 = OsmMercator.LonToX(bbox.getMax ().lon(), MAX_ZOOM);684 int y1 = OsmMercator.LatToY(bbox.getMinLat(), MAX_ZOOM); 685 int y2 = OsmMercator.LatToY(bbox.getMaxLat(), MAX_ZOOM); 686 int x1 = OsmMercator.LonToX(bbox.getMinLon(), MAX_ZOOM); 687 int x2 = OsmMercator.LonToX(bbox.getMaxLon(), MAX_ZOOM); 688 688 689 689 min = new Point(Math.min(x1, x2), Math.min(y1, y2)); 690 690 max = new Point(Math.max(x1, x2), Math.max(y1, y2)); -
src/org/openstreetmap/josm/gui/download/BookmarkSelection.java
22 22 23 23 import org.openstreetmap.josm.Main; 24 24 import org.openstreetmap.josm.data.Bounds; 25 import org.openstreetmap.josm.data.osm.BBox;26 25 import org.openstreetmap.josm.gui.BookmarkList; 27 26 import org.openstreetmap.josm.gui.BookmarkList.Bookmark; 28 27 import org.openstreetmap.josm.gui.JMultilineLabel; … … 153 152 lblCurrentDownloadArea.setText(tr("<html>There is currently no download area selected.</html>")); 154 153 } else { 155 154 lblCurrentDownloadArea.setText(tr("<html><strong>Current download area</strong> (minlon, minlat, maxlon, maxlat): </html>")); 156 bboxDisplay.setText( new BBox(currentArea).toStringCSV(","));155 bboxDisplay.setText(currentArea.toBBox().toStringCSV(",")); 157 156 } 158 157 } 159 158 -
src/org/openstreetmap/josm/gui/download/PlaceSelection.java
241 241 currentResult.lon = Double.parseDouble(atts.getValue("lon")); 242 242 String[] bbox = atts.getValue("boundingbox").split(","); 243 243 currentResult.bounds = new Bounds( 244 new LatLon(Double.parseDouble(bbox[0]), Double.parseDouble(bbox[2])),245 new LatLon(Double.parseDouble(bbox[1]), Double.parseDouble(bbox[3])));244 Double.parseDouble(bbox[0]), Double.parseDouble(bbox[2]), 245 Double.parseDouble(bbox[1]), Double.parseDouble(bbox[3])); 246 246 data.add(currentResult); 247 247 } 248 248 } catch (NumberFormatException x) { -
src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
398 398 if (defaultTable.getSelectionModel().isSelectedIndex(i)) { 399 399 if (!mapRectangles.containsKey(i)) { 400 400 // Add new map rectangle 401 Coordinate topLeft = new Coordinate(bounds.getMax ().lat(), bounds.getMin().lon());402 Coordinate bottomRight = new Coordinate(bounds.getMin ().lat(), bounds.getMax().lon());401 Coordinate topLeft = new Coordinate(bounds.getMaxLat(), bounds.getMinLon()); 402 Coordinate bottomRight = new Coordinate(bounds.getMinLat(), bounds.getMaxLon()); 403 403 MapRectangle rectangle = new MapRectangleImpl(topLeft, bottomRight); 404 404 mapRectangles.put(i, rectangle); 405 405 defaultMap.addMapRectangle(rectangle); -
src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
25 25 protected final boolean crosses180th; 26 26 27 27 public BoundingBoxDownloader(Bounds downloadArea) { 28 this.lat1 = downloadArea.getMin ().lat();29 this.lon1 = downloadArea.getMin ().lon();30 this.lat2 = downloadArea.getMax ().lat();31 this.lon2 = downloadArea.getMax ().lon();28 this.lat1 = downloadArea.getMinLat(); 29 this.lon1 = downloadArea.getMinLon(); 30 this.lat2 = downloadArea.getMaxLat(); 31 this.lon2 = downloadArea.getMaxLon(); 32 32 this.crosses180th = downloadArea.crosses180thMeridian(); 33 33 } 34 34 -
src/org/openstreetmap/josm/io/GpxWriter.java
156 156 157 157 Bounds bounds = data.recalculateBounds(); 158 158 if (bounds != null) { 159 String b = "minlat=\"" + bounds.getMin ().lat() + "\" minlon=\"" + bounds.getMin().lon() +160 "\" maxlat=\"" + bounds.getMax ().lat() + "\" maxlon=\"" + bounds.getMax().lon() + "\"" ;159 String b = "minlat=\"" + bounds.getMinLat() + "\" minlon=\"" + bounds.getMinLon() + 160 "\" maxlat=\"" + bounds.getMaxLat() + "\" maxlon=\"" + bounds.getMaxLon() + "\"" ; 161 161 inline("bounds", b); 162 162 } 163 163 -
src/org/openstreetmap/josm/io/OsmWriter.java
162 162 public void writeDataSources(DataSet ds) { 163 163 for (DataSource s : ds.dataSources) { 164 164 out.println(" <bounds minlat='" 165 + s.bounds.getMin ().lat()+"' minlon='"166 + s.bounds.getMin ().lon()+"' maxlat='"167 + s.bounds.getMax ().lat()+"' maxlon='"168 + s.bounds.getMax ().lon()165 + s.bounds.getMinLat()+"' minlon='" 166 + s.bounds.getMinLon()+"' maxlat='" 167 + s.bounds.getMaxLat()+"' maxlon='" 168 + s.bounds.getMaxLon() 169 169 +"' origin='"+XmlWriter.encode(s.origin)+"' />"); 170 170 } 171 171 } -
src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
158 158 }); 159 159 } 160 160 161 final Bounds bbox = new Bounds( new LatLon(minlat, minlon), new LatLon(maxlat, maxlon));161 final Bounds bbox = new Bounds(minlat, minlon, maxlat, maxlon); 162 162 if (args.containsKey("select") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) { 163 163 // select objects after downloading, zoom to selection. 164 164 GuiHelper.executeByMainWorkerInEDT(new Runnable() { -
src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
49 49 if (map.containsKey("bbox")) { 50 50 String[] bbox = map.get("bbox").split(","); 51 51 b = new Bounds( 52 new LatLon(Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0])),53 new LatLon(Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2])));52 Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0]), 53 Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2])); 54 54 } else if (map.containsKey("minlat")) { 55 String s = map.get("minlat"); 56 Double minlat = Double.parseDouble(s); 57 s = map.get("minlon"); 58 Double minlon = Double.parseDouble(s); 59 s = map.get("maxlat"); 60 Double maxlat = Double.parseDouble(s); 61 s = map.get("maxlon"); 62 Double maxlon = Double.parseDouble(s); 63 b = new Bounds(new LatLon(minlat, minlon), new LatLon(maxlat, maxlon)); 55 double minlat = Double.parseDouble(map.get("minlat")); 56 double minlon = Double.parseDouble(map.get("minlon")); 57 double maxlat = Double.parseDouble(map.get("maxlat")); 58 double maxlon = Double.parseDouble(map.get("maxlon")); 59 b = new Bounds(minlat, minlon, maxlat, maxlon); 64 60 } else { 65 61 String z = map.get("zoom"); 66 62 b = positionToBounds(parseDouble(map, "lat"), … … 233 229 */ 234 230 static public int getZoom(Bounds b) { 235 231 // convert to mercator (for calculation of zoom only) 236 double latMin = Math.log(Math.tan(Math.PI/4.0+b.getMin ().lat()/180.0*Math.PI/2.0))*180.0/Math.PI;237 double latMax = Math.log(Math.tan(Math.PI/4.0+b.getMax ().lat()/180.0*Math.PI/2.0))*180.0/Math.PI;238 double size = Math.max(Math.abs(latMax-latMin), Math.abs(b.getMax ().lon()-b.getMin().lon()));232 double latMin = Math.log(Math.tan(Math.PI/4.0+b.getMinLat()/180.0*Math.PI/2.0))*180.0/Math.PI; 233 double latMax = Math.log(Math.tan(Math.PI/4.0+b.getMaxLat()/180.0*Math.PI/2.0))*180.0/Math.PI; 234 double size = Math.max(Math.abs(latMax-latMin), Math.abs(b.getMaxLon()-b.getMinLon())); 239 235 int zoom = 0; 240 236 while (zoom <= 20) { 241 237 if (size >= 180) { -
test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
102 102 lat = prev.ll.lat(); 103 103 lon = prev.ll.lon(); 104 104 } else { 105 lat = b.getMin ().lat() + rand.nextDouble() * (b.getMax().lat() - b.getMin().lat());106 lon = b.getMin ().lon() + rand.nextDouble() * (b.getMax().lon() - b.getMin().lon());105 lat = b.getMinLat() + rand.nextDouble() * (b.getMaxLat() - b.getMinLat()); 106 lon = b.getMinLon() + rand.nextDouble() * (b.getMaxLon() - b.getMinLon()); 107 107 } 108 108 EastNorth en = proj.latlon2eastNorth(new LatLon(lat, lon)); 109 109 LatLon ll2 = proj.eastNorth2latlon(en); -
test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java
67 67 text += String.format("*** %s %s\n", p.toString(), p.toCode()); 68 68 for (int num=0; num < 1000; ++num) { 69 69 70 double lat = rand.nextDouble() * (b.getMax ().lat() - b.getMin().lat()) + b.getMin().lat();71 double lon = rand.nextDouble() * (b.getMax ().lon() - b.getMin().lon()) + b.getMin().lon();70 double lat = rand.nextDouble() * (b.getMaxLat() - b.getMinLat()) + b.getMinLat(); 71 double lon = rand.nextDouble() * (b.getMaxLon() - b.getMinLon()) + b.getMinLon(); 72 72 73 73 LatLon ll = new LatLon(lat, lon); 74 74