Changeset 15483 in josm
- Timestamp:
- 2019-10-29T20:17:53+01:00 (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/BBox.java
r14026 r15483 337 337 338 338 /** 339 * Check if bboxes are functionally equal 340 * @param other The other bbox to compare with 341 * @param maxDifference The maximum difference (in degrees) between the bboxes. May be null. 342 * @return true if they are functionally equivalent 343 * @since 15483 344 */ 345 public boolean bboxesAreFunctionallyEqual(BBox other, Double maxDifference) { 346 return bboxesAreFunctionallyEqual(this, other, maxDifference); 347 } 348 349 /** 350 * Check if bboxes are functionally equal 351 * @param bbox1 A bbox to compare with another bbox 352 * @param bbox2 The other bbox to compare with 353 * @param maxDifference The maximum difference (in degrees) between the bboxes. May be null. 354 * @return true if they are functionally equivalent 355 * @since 15483 356 */ 357 public static boolean bboxesAreFunctionallyEqual(BBox bbox1, BBox bbox2, Double maxDifference) { 358 if (maxDifference == null) { 359 maxDifference = LatLon.MAX_SERVER_PRECISION; 360 } 361 return (bbox1 != null && bbox2 != null) 362 && (Math.abs(bbox1.getBottomRightLat() - bbox2.getBottomRightLat()) <= maxDifference 363 && Math.abs(bbox1.getBottomRightLon() - bbox2.getBottomRightLon()) <= maxDifference 364 && Math.abs(bbox1.getTopLeftLat() - bbox2.getTopLeftLat()) <= maxDifference 365 && Math.abs(bbox1.getTopLeftLon() - bbox2.getTopLeftLon()) <= maxDifference); 366 } 367 368 /** 339 369 * @return true if the bbox covers a part of the planets surface 340 370 * Height and width must be non-negative, but may (both) be 0. -
trunk/test/unit/org/openstreetmap/josm/data/osm/BBoxTest.java
r13079 r15483 37 37 .suppress(Warning.NONFINAL_FIELDS) 38 38 .verify(); 39 } 40 41 /** 42 * Unit test of method {@link BBox#bboxesAreFunctionallyEqual} 43 */ 44 @Test 45 public void testBboxesAreFunctionallyEqual() { 46 BBox bbox1 = new BBox(0, 1, 1, 0); 47 BBox bbox2 = new BBox(0.1, 0.9, 0.9, 0.1); 48 49 assertFalse(BBox.bboxesAreFunctionallyEqual(bbox1, null, null)); 50 assertFalse(BBox.bboxesAreFunctionallyEqual(null, bbox2, null)); 51 assertFalse(BBox.bboxesAreFunctionallyEqual(null, null, null)); 52 53 assertFalse(bbox1.bboxesAreFunctionallyEqual(bbox2, null)); 54 assertTrue(bbox1.bboxesAreFunctionallyEqual(bbox2, 0.1)); 55 bbox1.add(0, 1.1); 56 assertFalse(bbox1.bboxesAreFunctionallyEqual(bbox2, 0.1)); 57 bbox1.add(2, 0); 58 assertFalse(bbox1.bboxesAreFunctionallyEqual(bbox2, 0.1)); 39 59 } 40 60
Note:
See TracChangeset
for help on using the changeset viewer.