Changeset 15483 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2019-10-29T20:17:53+01:00 (5 years ago)
Author:
Don-vip
Message:

fix #18274 - BBox should have a method to determine functional equivalency (patch by taylor.smock)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/BBox.java

    r14026 r15483  
    337337
    338338    /**
     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    /**
    339369     * @return true if the bbox covers a part of the planets surface
    340370     * Height and width must be non-negative, but may (both) be 0.
Note: See TracChangeset for help on using the changeset viewer.