Changeset 6203 in josm
- Timestamp:
- 2013-08-28T03:03:40+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/JumpToAction.java
r5966 r6203 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; -
trunk/src/org/openstreetmap/josm/data/Bounds.java
r6162 r6203 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 … … 27 28 } 28 29 30 /** 31 * Returns min latitude of bounds. Efficient shortcut for {@code getMin().lat()}. 32 * 33 * @return min latitude of bounds. 34 * @since 6203 35 */ 36 public double getMinLat() { 37 return minLat; 38 } 39 40 /** 41 * Returns min longitude of bounds. Efficient shortcut for {@code getMin().lon()}. 42 * 43 * @return min longitude of bounds. 44 * @since 6203 45 */ 46 public double getMinLon() { 47 return minLon; 48 } 49 29 50 public LatLon getMax() { 30 51 return new LatLon(maxLat, maxLon); 52 } 53 54 /** 55 * Returns max latitude of bounds. Efficient shortcut for {@code getMax().lat()}. 56 * 57 * @return max latitude of bounds. 58 * @since 6203 59 */ 60 public double getMaxLat() { 61 return maxLat; 62 } 63 64 /** 65 * Returns max longitude of bounds. Efficient shortcut for {@code getMax().lon()}. 66 * 67 * @return max longitude of bounds. 68 * @since 6203 69 */ 70 public double getMaxLon() { 71 return maxLon; 31 72 } 32 73 … … 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) { … … 51 92 } 52 93 94 /** 95 * Single point Bounds defined by lat/lon {@code b}. 96 * Coordinates will be rounded to osm precision if {@code roundToOsmPrecision} is true. 97 * 98 * @param b lat/lon of given point. 99 * @param roundToOsmPrecision defines if lat/lon will be rounded. 100 */ 53 101 public Bounds(LatLon b, boolean roundToOsmPrecision) { 102 this(b.lat(), b.lon(), roundToOsmPrecision); 103 } 104 105 /** 106 * Single point Bounds defined by point [lat,lon]. 107 * Coordinates will be rounded to osm precision if {@code roundToOsmPrecision} is true. 108 * 109 * @param lat latitude of given point. 110 * @param lon longitude of given point. 111 * @param roundToOsmPrecision defines if lat/lon will be rounded. 112 * @since 6203 113 */ 114 public Bounds(double lat, double lon, boolean roundToOsmPrecision) { 54 115 // Do not call this(b, b) to avoid GPX performance issue (see #7028) until roundToOsmPrecision() is improved 55 116 if (roundToOsmPrecision) { 56 this.minLat = LatLon.roundToOsmPrecision( b.lat());57 this.minLon = LatLon.roundToOsmPrecision( b.lon());58 } else { 59 this.minLat = b.lat();60 this.minLon = b.lon();117 this.minLat = LatLon.roundToOsmPrecision(lat); 118 this.minLon = LatLon.roundToOsmPrecision(lon); 119 } else { 120 this.minLat = lat; 121 this.minLon = lon; 61 122 } 62 123 this.maxLat = this.minLat; … … 153 214 } 154 215 155 public Bounds(Bounds other) { 156 this(other.getMin(), other.getMax()); 216 /** 217 * Creates new {@code Bounds} from an existing one. 218 * @param other The bounds to copy 219 */ 220 public Bounds(final Bounds other) { 221 this(other.minLat, other.minLon, other.maxLat, other.maxLon); 157 222 } 158 223 … … 186 251 } 187 252 253 /** 254 * Creates BBox with same coordinates. 255 * 256 * @return BBox with same coordinates. 257 * @since 6203 258 */ 259 public BBox toBBox() { 260 return new BBox(minLon, minLat, maxLon, maxLat); 261 } 262 188 263 @Override public String toString() { 189 264 return "Bounds["+minLat+","+minLon+","+maxLat+","+maxLon+"]"; … … 203 278 public LatLon getCenter() 204 279 { 280 if (crosses180thMeridian()) { 281 double lat = (minLat + maxLat) / 2; 282 double lon = (minLon + maxLon - 360.0) / 2; 283 if (lon < -180.0){ 284 lon += 360.0; 285 } 286 return new LatLon(lat, lon); 287 } else { 288 return new LatLon((minLat + maxLat) / 2, (minLon + maxLon) / 2); 289 } 290 } 291 292 /** 293 * Extend the bounds if necessary to include the given point. 294 * @param ll The point to include into these bounds 295 */ 296 public void extend(LatLon ll) { 297 extend(ll.lat(), ll.lon()); 298 } 299 300 /** 301 * Extend the bounds if necessary to include the given point [lat,lon]. 302 * Good to use if you know coordinates to avoid creation of LatLon object. 303 * @param lat Latitude of point to include into these bounds 304 * @param lon Longitude of point to include into these bounds 305 * @since 6203 306 */ 307 public void extend(final double lat, final double lon) { 308 if (lat < minLat) { 309 minLat = LatLon.roundToOsmPrecision(lat); 310 } 311 if (lat > maxLat) { 312 maxLat = LatLon.roundToOsmPrecision(lat); 313 } 205 314 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); 209 } 210 return result; 211 } else { 212 return getMin().getCenter(getMax()); 213 } 214 } 215 216 /** 217 * Extend the bounds if necessary to include the given point. 218 */ 219 public void extend(LatLon ll) { 220 if (ll.lat() < minLat) { 221 minLat = LatLon.roundToOsmPrecision(ll.lat()); 222 } 223 if (ll.lat() > maxLat) { 224 maxLat = LatLon.roundToOsmPrecision(ll.lat()); 225 } 226 if (crosses180thMeridian()) { 227 if (ll.lon() > maxLon && ll.lon() < minLon) { 228 if (Math.abs(ll.lon() - minLon) <= Math.abs(ll.lon() - maxLon)) { 229 minLon = LatLon.roundToOsmPrecision(ll.lon()); 315 if (lon > maxLon && lon < minLon) { 316 if (Math.abs(lon - minLon) <= Math.abs(lon - maxLon)) { 317 minLon = LatLon.roundToOsmPrecision(lon); 230 318 } else { 231 maxLon = LatLon.roundToOsmPrecision(l l.lon());319 maxLon = LatLon.roundToOsmPrecision(lon); 232 320 } 233 321 } 234 322 } else { 235 if (l l.lon()< minLon) {236 minLon = LatLon.roundToOsmPrecision(l l.lon());323 if (lon < minLon) { 324 minLon = LatLon.roundToOsmPrecision(lon); 237 325 } 238 if (l l.lon()> maxLon) {239 maxLon = LatLon.roundToOsmPrecision(l l.lon());326 if (lon > maxLon) { 327 maxLon = LatLon.roundToOsmPrecision(lon); 240 328 } 241 329 } … … 243 331 244 332 public void extend(Bounds b) { 245 extend(b.getMin()); 246 extend(b.getMax()); 247 } 248 249 /** 250 * Is the given point within this bounds? 333 extend(b.minLat, b.minLon); 334 extend(b.maxLat, b.maxLon); 335 } 336 337 /** 338 * Determines if the given point {@code ll} is within these bounds. 339 * @param ll The lat/lon to check 340 * @return {@code true} if {@code ll} is within these bounds, {@code false} otherwise 251 341 */ 252 342 public boolean contains(LatLon ll) { … … 324 414 */ 325 415 public boolean isCollapsed() { 326 return getMin().equals(getMax());416 return (minLat == maxLat) && (minLon == maxLon); 327 417 } 328 418 -
trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java
r6169 r6203 3 3 4 4 import java.io.Serializable; 5 6 import org.openstreetmap.josm.data.osm.BBox; 5 7 6 8 /** … … 89 91 } 90 92 93 /** 94 * Converts to single point BBox. 95 * 96 * @return single point BBox defined by this coordinate. 97 * @since 6203 98 */ 99 public BBox toBBox() { 100 return new BBox(x, y); 101 } 102 103 /** 104 * Creates bbox around this coordinate. Coordinate defines 105 * center of bbox, its edge will be 2*r. 106 * 107 * @param r size 108 * @return BBox around this coordinate 109 * @since 6203 110 */ 111 public BBox toBBox(final double r) { 112 return new BBox(x - r, y - r, x + r, y + r); 113 } 114 91 115 @Override 92 116 public int hashCode() { -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r6178 r6203 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 -
trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
r6084 r6203 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 /* -
trunk/src/org/openstreetmap/josm/data/osm/BBox.java
r6178 r6203 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; … … 16 15 private double ymax = Double.NEGATIVE_INFINITY; 17 16 18 public BBox(Bounds bounds) { 19 add(bounds.getMin()); 20 add(bounds.getMax()); 21 } 22 17 /** 18 * Constructs a new {@code BBox} defined by a single point. 19 * 20 * @param x X coordinate 21 * @param y Y coordinate 22 * @since 6203 23 */ 24 public BBox(final double x, final double y) { 25 xmax = xmin = x; 26 ymax = ymin = y; 27 sanity(); 28 } 29 30 /** 31 * Constructs a new {@code BBox} defined by points <code>a</code> and <code>b</code>. 32 * Result is minimal BBox containing both points. 33 * 34 * @param a 35 * @param b 36 */ 23 37 public BBox(LatLon a, LatLon b) { 24 add(a); 25 add(b); 26 } 27 38 this(a.lon(), a.lat(), b.lon(), b.lat()); 39 } 40 41 /** 42 * Constructs a new {@code BBox} from another one. 43 * 44 * @param copy the BBox to copy 45 */ 28 46 public BBox(BBox copy) { 29 47 this.xmin = copy.xmin; … … 34 52 35 53 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); 54 55 if (a_x > b_x) { 56 xmax = a_x; 57 xmin = b_x; 58 } else { 59 xmax = b_x; 60 xmin = a_x; 61 } 62 63 if (a_y > b_y) { 64 ymax = a_y; 65 ymin = b_y; 66 } else { 67 ymax = b_y; 68 ymin = a_y; 69 } 70 40 71 sanity(); 41 72 } … … 84 115 */ 85 116 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); 117 118 if (x < xmin) { 119 xmin = x; 120 } else if (x > xmax) { 121 xmax = x; 122 } 123 124 if (y < ymin) { 125 ymin = y; 126 } else if (y > ymax) { 127 ymax = y; 128 } 129 90 130 sanity(); 91 131 } 92 132 93 133 public void add(BBox box) { 94 add(box.getTopLeft()); 95 add(box.getBottomRight()); 134 xmin = Math.min(xmin, box.xmin); 135 xmax = Math.max(xmax, box.xmax); 136 ymin = Math.min(ymin, box.ymin); 137 ymax = Math.max(ymax, box.ymax); 138 sanity(); 96 139 } 97 140 … … 151 194 } 152 195 196 /** 197 * Returns the top-left point. 198 * @return The top-left point 199 */ 153 200 public LatLon getTopLeft() { 154 201 return new LatLon(ymax, xmin); 155 202 } 156 203 204 /** 205 * Returns the latitude of top-left point. 206 * @return The latitude of top-left point 207 * @since 6203 208 */ 209 public double getTopLeftLat() { 210 return ymax; 211 } 212 213 /** 214 * Returns the longitude of top-left point. 215 * @return The longitude of top-left point 216 * @since 6203 217 */ 218 public double getTopLeftLon() { 219 return xmin; 220 } 221 222 /** 223 * Returns the bottom-right point. 224 * @return The bottom-right point 225 */ 157 226 public LatLon getBottomRight() { 158 227 return new LatLon(ymin, xmax); 228 } 229 230 /** 231 * Returns the latitude of bottom-right point. 232 * @return The latitude of bottom-right point 233 * @since 6203 234 */ 235 public double getBottomRightLat() { 236 return ymin; 237 } 238 239 /** 240 * Returns the longitude of bottom-right point. 241 * @return The longitude of bottom-right point 242 * @since 6203 243 */ 244 public double getBottomRightLon() { 245 return xmax; 159 246 } 160 247 -
trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java
r5356 r6203 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); -
trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
r6181 r6203 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 new BBox(bottom_left.lon(), bottom_left.lat(), lon, lat); 121 120 } 122 121 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r6172 r6203 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 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java
r6113 r6203 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); -
trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r6142 r6203 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); -
trunk/src/org/openstreetmap/josm/gui/BookmarkList.java
r6084 r6203 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 } … … 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(); -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r6107 r6203 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()); … … 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 { … … 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 { -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r6142 r6203 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 // FIXME is it correct? b.getCenter() makes some adjustments... 206 206 return Main.getProjection().latlon2eastNorth(new LatLon(lat, lon)); 207 207 } … … 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)); … … 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); … … 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) { -
trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java
r6084 r6203 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; … … 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()) { … … 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); … … 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); -
trunk/src/org/openstreetmap/josm/gui/bbox/TileSelectionBBoxChooser.java
r6087 r6203 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); … … 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; … … 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)); -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java
r6087 r6203 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; … … 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 } -
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r6084 r6203 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 } -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r6104 r6203 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); -
trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
r6070 r6203 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 } -
trunk/src/org/openstreetmap/josm/io/GpxWriter.java
r6142 r6203 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 } -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r6070 r6203 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 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r6091 r6203 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. -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r6155 r6203 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"); … … 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) {
Note:
See TracChangeset
for help on using the changeset viewer.