Changeset 17703 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2021-04-07T20:40:02+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Bounds.java
r16664 r17703 22 22 * @see BBox to represent invalid areas. 23 23 */ 24 public class Bounds {24 public class Bounds implements IBounds { 25 25 /** 26 26 * The minimum and maximum coordinates. … … 32 32 * @return The point 33 33 */ 34 @Override 34 35 public LatLon getMin() { 35 36 return new LatLon(minLat, minLon); … … 42 43 * @since 6203 43 44 */ 45 @Override 44 46 public double getMinLat() { 45 47 return minLat; … … 52 54 * @since 6203 53 55 */ 56 @Override 54 57 public double getMinLon() { 55 58 return minLon; … … 60 63 * @return The point 61 64 */ 65 @Override 62 66 public LatLon getMax() { 63 67 return new LatLon(maxLat, maxLon); … … 70 74 * @since 6203 71 75 */ 76 @Override 72 77 public double getMaxLat() { 73 78 return maxLat; … … 80 85 * @since 6203 81 86 */ 87 @Override 82 88 public double getMaxLon() { 83 89 return maxLon; … … 364 370 * @return Center of the bounding box. 365 371 */ 372 @Override 366 373 public LatLon getCenter() { 367 374 if (crosses180thMeridian()) { … … 446 453 * @since 12161 447 454 */ 455 @Override 448 456 public boolean contains(ILatLon ll) { 449 457 if (!ll.isLatLonKnown()) { … … 462 470 } 463 471 464 private static boolean intersectsLonCrossing( Bounds crossing,Bounds notCrossing) {465 return notCrossing. minLon <= crossing.maxLon || notCrossing.maxLon >= crossing.minLon;472 private static boolean intersectsLonCrossing(IBounds crossing, IBounds notCrossing) { 473 return notCrossing.getMinLon() <= crossing.getMaxLon() || notCrossing.getMaxLon() >= crossing.getMinLon(); 466 474 } 467 475 … … 473 481 */ 474 482 public boolean intersects(Bounds b) { 475 if (b.maxLat < minLat || b.minLat > maxLat) 483 return intersects((IBounds) b); 484 } 485 486 @Override 487 public boolean intersects(IBounds b) { 488 if (b.getMaxLat() < minLat || b.getMinLat() > maxLat) 476 489 return false; 477 490 … … 483 496 return true; 484 497 } else { 485 return b. maxLon >= minLon && b.minLon<= maxLon;498 return b.getMaxLon() >= minLon && b.getMinLon() <= maxLon; 486 499 } 487 500 } … … 492 505 * @return true if this Bounds object crosses the 180th Meridian. 493 506 */ 507 @Override 494 508 public boolean crosses180thMeridian() { 495 509 return this.minLon > this.maxLon; … … 509 523 * @since 14521 510 524 */ 525 @Override 511 526 public double getHeight() { 512 527 return maxLat-minLat; … … 518 533 * @since 14521 519 534 */ 535 @Override 520 536 public double getWidth() { 521 537 return maxLon-minLon + (crosses180thMeridian() ? 360.0 : 0.0); … … 526 542 * @return The area 527 543 */ 544 @Override 528 545 public double getArea() { 529 546 return getWidth() * getHeight(); -
trunk/src/org/openstreetmap/josm/data/osm/BBox.java
r16673 r17703 6 6 7 7 import org.openstreetmap.josm.data.Bounds; 8 import org.openstreetmap.josm.data.IBounds; 8 9 import org.openstreetmap.josm.data.coor.ILatLon; 9 10 import org.openstreetmap.josm.data.coor.LatLon; … … 15 16 * In contrast to a {@link Bounds} object, a BBox can represent an invalid (empty) area. 16 17 */ 17 public class BBox {18 public class BBox implements IBounds { 18 19 19 20 protected double xmin = Double.POSITIVE_INFINITY; … … 173 174 */ 174 175 public void addPrimitive(OsmPrimitive primitive, double extraSpace) { 175 BBoxprimBbox = primitive.getBBox();176 add(primBbox. xmin - extraSpace, primBbox.ymin- extraSpace);177 add(primBbox. xmax + extraSpace, primBbox.ymax+ extraSpace);176 IBounds primBbox = primitive.getBBox(); 177 add(primBbox.getMinLon() - extraSpace, primBbox.getMinLat() - extraSpace); 178 add(primBbox.getMaxLon() + extraSpace, primBbox.getMaxLat() + extraSpace); 178 179 } 179 180 … … 196 197 */ 197 198 public double height() { 199 return getHeight(); 200 } 201 202 @Override 203 public double getHeight() { 198 204 if (isValid()) { 199 205 return ymax - ymin; … … 208 214 */ 209 215 public double width() { 216 return getWidth(); 217 } 218 219 @Override 220 public double getWidth() { 210 221 if (isValid()) { 211 222 return xmax - xmin; … … 229 240 */ 230 241 public boolean bounds(BBox b) { 231 return xmin <= b.xmin && xmax >= b.xmax 232 && ymin <= b.ymin && ymax >= b.ymax; 242 return contains(b); 233 243 } 234 244 … … 239 249 */ 240 250 public boolean bounds(LatLon c) { 241 return xmin <= c.lon() && xmax >= c.lon() 242 && ymin <= c.lat() && ymax >= c.lat(); 251 return contains(c); 243 252 } 244 253 … … 250 259 */ 251 260 public boolean intersects(BBox b) { 252 return xmin <= b.xmax && xmax >= b.xmin 253 && ymin <= b.ymax && ymax >= b.ymin; 261 return intersects((IBounds) b); 254 262 } 255 263 … … 268 276 */ 269 277 public double getTopLeftLat() { 278 return getMaxLat(); 279 } 280 281 @Override 282 public double getMaxLat() { 270 283 return ymax; 271 284 } … … 277 290 */ 278 291 public double getTopLeftLon() { 292 return getMinLon(); 293 } 294 295 @Override 296 public double getMinLon() { 279 297 return xmin; 280 298 } … … 294 312 */ 295 313 public double getBottomRightLat() { 314 return getMinLat(); 315 } 316 317 @Override 318 public double getMinLat() { 296 319 return ymin; 297 320 } … … 303 326 */ 304 327 public double getBottomRightLon() { 328 return getMaxLon(); 329 } 330 331 @Override 332 public double getMaxLon() { 305 333 return xmax; 306 334 } … … 310 338 * @return The center. 311 339 */ 340 @Override 312 341 public LatLon getCenter() { 313 342 return new LatLon(ymin + (ymax-ymin)/2.0, xmin + (xmax-xmin)/2.0); … … 391 420 * @since 11269 392 421 */ 422 @Override 393 423 public boolean isValid() { 394 424 return xmin <= xmax && ymin <= ymax;
Note:
See TracChangeset
for help on using the changeset viewer.