Ticket #9024: bbox2.diff
File bbox2.diff, 39.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/command/Command.java
241 241 } 242 242 243 243 private static boolean isOutlying(OsmPrimitive osm, Area area) { 244 if (osm instanceof Node && !osm.isNewOrUndeleted()) {244 if (osm instanceof Node && !osm.isNewOrUndeleted()) 245 245 return !((Node) osm).getCoor().isIn(area); 246 }else if (osm instanceof Way) {246 else if (osm instanceof Way) { 247 247 for (Node n : ((Way) osm).getNodes()) { 248 if (isOutlying(n, area)) {248 if (isOutlying(n, area)) 249 249 return true; 250 }251 250 } 252 251 return false; 253 252 } -
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 /** 31 * Returns min latitude of bounds. Efficient shortcut 32 * for getMin().lat(). 33 * 34 * @return min latitude of bounds. 35 */ 36 public double getMinLat() { 37 return minLat; 38 } 39 40 /** 41 * Returns min longitude of bounds. Efficient shortcut 42 * for getMin().lon(). 43 * 44 * @return min longitude of bounds. 45 */ 46 public double getMinLon() { 47 return minLon; 48 } 49 29 50 public LatLon getMax() { 30 51 return new LatLon(maxLat, maxLon); 31 52 } 32 53 54 /** 55 * Returns max latitude of bounds. Efficient shortcut 56 * for getMax().lat(). 57 * 58 * @return max latitude of bounds. 59 */ 60 public double getMaxLat() { 61 return maxLat; 62 } 63 64 /** 65 * Returns max longitude of bounds. Efficient shortcut 66 * for getMax().lon(). 67 * 68 * @return max longitude of bounds. 69 */ 70 public double getMaxLon() { 71 return maxLon; 72 } 73 33 74 public enum ParseMethod { 34 75 MINLAT_MINLON_MAXLAT_MAXLON, 35 76 LEFT_BOTTOM_RIGHT_TOP 36 77 } 37 78 38 79 /** 39 * Construct bounds out of two points 80 * Construct bounds out of two points. Coords will be rounded. 40 81 */ 41 82 public Bounds(LatLon min, LatLon max) { 42 83 this(min.lat(), min.lon(), max.lat(), max.lon()); … … 51 92 } 52 93 53 94 public Bounds(LatLon b, boolean roundToOsmPrecision) { 95 this(b.lat(), b.lon(), roundToOsmPrecision); 96 } 97 98 /** 99 * Single point Bounds defined by point [lat,lon]. 100 * Coordinates will be rounded to osm precision if <code>roundToOsmPrecision</code> is true. 101 * 102 * @param lat latitude of given point. 103 * @param lon longitude of given point. 104 * @param roundToOsmPrecision defines if lat/lon will be rounded. 105 */ 106 public Bounds(double lat, double lon, boolean roundToOsmPrecision) { 54 107 // Do not call this(b, b) to avoid GPX performance issue (see #7028) until roundToOsmPrecision() is improved 55 108 if (roundToOsmPrecision) { 56 this.minLat = LatLon.roundToOsmPrecision( b.lat());57 this.minLon = LatLon.roundToOsmPrecision( b.lon());109 this.minLat = LatLon.roundToOsmPrecision(lat); 110 this.minLon = LatLon.roundToOsmPrecision(lon); 58 111 } else { 59 this.minLat = b.lat();60 this.minLon = b.lon();112 this.minLat = lat; 113 this.minLon = lon; 61 114 } 62 115 this.maxLat = this.minLat; 63 116 this.maxLon = this.minLon; … … 152 205 return roundToOsmPrecision ? LatLon.roundToOsmPrecision(value) : value; 153 206 } 154 207 155 public Bounds( Bounds other) {156 this(other. getMin(), other.getMax());208 public Bounds(final Bounds other) { 209 this(other.minLat, other.minLon, other.maxLat, other.maxLon); 157 210 } 158 211 159 212 public Bounds(Rectangle2D rect) { … … 185 238 this.maxLon = LatLon.roundToOsmPrecision(LatLon.toIntervalLon(center.lon() + lonExtent / 2)); 186 239 } 187 240 241 /** 242 * Created BBox with same coordinates. 243 * 244 * @return BBox with same coordinates. 245 */ 246 public BBox toBBox(){ 247 return new BBox(minLon, minLat, maxLon, maxLat); 248 } 249 188 250 @Override public String toString() { 189 251 return "Bounds["+minLat+","+minLon+","+maxLat+","+maxLon+"]"; 190 252 } … … 202 264 */ 203 265 public LatLon getCenter() 204 266 { 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); 267 if (crosses180thMeridian()) { 268 double lat = (minLat + maxLat) / 2; 269 double lon = (minLon + maxLon - 360.0) / 2; 270 if (lon < -180.0){ 271 lon += 360.0; 209 272 } 210 return result;273 return new LatLon(lat, lon); 211 274 } else { 212 return getMin().getCenter(getMax());275 return new LatLon((minLat + maxLat) / 2, (minLon + maxLon) / 2); 213 276 } 214 277 } 215 278 … … 217 280 * Extend the bounds if necessary to include the given point. 218 281 */ 219 282 public void extend(LatLon ll) { 220 if (ll.lat() < minLat) { 221 minLat = LatLon.roundToOsmPrecision(ll.lat()); 283 extend(ll.lat(), ll.lon()); 284 } 285 286 /** 287 * Extend the bounds if necessary to include the given point [lat,lon]. 288 * Good to use if you know coordinates to avoid creation of LatLon object. 289 */ 290 public void extend(final double lat, final double lon) { 291 if (lat < minLat) { 292 minLat = LatLon.roundToOsmPrecision(lat); 222 293 } 223 if (l l.lat()> maxLat) {224 maxLat = LatLon.roundToOsmPrecision(l l.lat());294 if (lat > maxLat) { 295 maxLat = LatLon.roundToOsmPrecision(lat); 225 296 } 226 297 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());298 if (lon > maxLon && lon < minLon) { 299 if (Math.abs(lon - minLon) <= Math.abs(lon - maxLon)) { 300 minLon = LatLon.roundToOsmPrecision(lon); 230 301 } else { 231 maxLon = LatLon.roundToOsmPrecision(l l.lon());302 maxLon = LatLon.roundToOsmPrecision(lon); 232 303 } 233 304 } 234 305 } else { 235 if (l l.lon()< minLon) {236 minLon = LatLon.roundToOsmPrecision(l l.lon());306 if (lon < minLon) { 307 minLon = LatLon.roundToOsmPrecision(lon); 237 308 } 238 if (l l.lon()> maxLon) {239 maxLon = LatLon.roundToOsmPrecision(l l.lon());309 if (lon > maxLon) { 310 maxLon = LatLon.roundToOsmPrecision(lon); 240 311 } 241 312 } 242 313 } 243 314 244 315 public void extend(Bounds b) { 245 extend(b. getMin());246 extend(b. getMax());316 extend(b.minLat, b.minLon); 317 extend(b.maxLat, b.maxLon); 247 318 } 248 319 249 320 /** … … 323 394 * @return true, if this bounds are <em>collapsed</em> 324 395 */ 325 396 public boolean isCollapsed() { 326 return getMin().equals(getMax()); 397 return (minLat == maxLat) && (minLon == maxLon); 398 //return getMin().equals(getMax()); 327 399 } 328 400 329 401 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 single point BBox defined by this coordinate. 97 */ 98 public BBox toBBox(){ 99 return new BBox(x, y); 100 } 101 102 /** 103 * Creates bbox around this coordinate. Coordinate defines 104 * center of bbox, its edge will be 2*r. 105 * 106 * @param r size 107 * @return BBox around this coordinate 108 */ 109 public BBox toBBox(final double r){ 110 return new BBox(x - r, y - r, x + r, y + r); 111 } 112 113 91 114 @Override 92 115 public int hashCode() { 93 116 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 /** 30 * Creates BBox defined by points <code>[lat1,lon1]</code> and <code>[la2,lon2]</code>. 31 * Result is minimal BBox containing both points. 32 * 33 * @param lat1 lat of first point. 34 * @param lon1 lon of first point. 35 * @param lat2 lat of second point. 36 * @param lon2 lon of second point. 37 * 38 * @return BBox defined by given points. 39 */ 40 public static BBox fromLatLonPair(final double lat1, final double lon1, final double lat2, final double lon2){ 41 return new BBox(lon1, lat1, lon2, lat2); 42 } 43 44 /** 45 * BBox defined by points <code>a</code> and <code>b</code>. 46 * Result is minimal BBox containing both points. 47 * 48 * @param a 49 * @param b 50 */ 23 51 public BBox(LatLon a, LatLon b) { 24 add(a); 25 add(b); 52 this(a.lon(), a.lat(), b.lon(), b.lat()); 26 53 } 27 54 28 55 public BBox(BBox copy) { … … 33 60 } 34 61 35 62 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); 63 64 if (a_x > b_x){ 65 xmax = a_x; 66 xmin = b_x; 67 } 68 else { 69 xmax = b_x; 70 xmin = a_x; 71 } 72 73 if (a_y > b_y){ 74 ymax = a_y; 75 ymin = b_y; 76 } 77 else { 78 ymax = b_y; 79 ymin = a_y; 80 } 81 82 40 83 sanity(); 41 84 } 42 85 … … 83 126 * Extends this bbox to include the point (x, y) 84 127 */ 85 128 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); 129 130 if (x < xmin){ 131 xmin = x; 132 } 133 else if (x > xmax){ 134 xmax = x; 135 } 136 137 if (y < ymin){ 138 ymin = y; 139 } 140 else if (y > ymax){ 141 ymax = y; 142 } 143 90 144 sanity(); 91 145 } 92 146 93 147 public void add(BBox box) { 94 add(box.getTopLeft()); 95 add(box.getBottomRight()); 148 xmin = Math.min(xmin, box.xmin); 149 xmax = Math.max(xmax, box.xmax); 150 ymin = Math.min(ymin, box.ymin); 151 ymax = Math.max(ymax, box.ymax); 152 sanity(); 96 153 } 97 154 98 155 public void addPrimitive(OsmPrimitive primitive, double extraSpace) { … … 154 211 return new LatLon(ymax, xmin); 155 212 } 156 213 214 public double getTopLeftLat() { 215 return ymax; 216 } 217 218 public double getTopLeftLon() { 219 return xmin; 220 } 221 157 222 public LatLon getBottomRight() { 158 223 return new LatLon(ymin, xmax); 159 224 } 160 225 226 public double getBottomRightLat() { 227 return ymin; 228 } 229 230 public double getBottomRightLon() { 231 return xmax; 232 } 233 161 234 public LatLon getCenter() { 162 235 return new LatLon(ymin + (ymax-ymin)/2.0, xmin + (xmax-xmin)/2.0); 163 236 } -
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