Changeset 19272 in josm for trunk/src/org


Ignore:
Timestamp:
2024-12-19T22:13:29+01:00 (3 weeks ago)
Author:
taylor.smock
Message:

See #24046: Reduce cost of Geometry#filterInsidePolygon when a primitive is a relation

This was done by checking that the bounds of the polygon contain the bounds of
the multipolygon ring before creating an area from the multipolygon ring.

If the polygon does not contain the bounds of the ring, then at least part
of the ring is outside the polygon, and thus is not inside the polygon.

Measurements using validators at (57.5183581,-75.0512982),(57.2181217,-73.9434821):

  • CPU: -87%
  • Memory: -62%

Please note that the test area is still very expensive in
Geometry#filterInsideMultipolygon (note the Multipolygon).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r18990 r19272  
    705705        inter.intersect(a2);
    706706
     707        // Note: Area has an equals method that takes Area; it does _not_ override the Object.equals method.
    707708        if (inter.isEmpty() || !checkIntersection(inter, eps)) {
    708709            return new Pair<>(PolygonIntersection.OUTSIDE, inter);
     
    11961197                for (PolyData outer : mp.getOuterPolygons()) {
    11971198                    if (!outer.isClosed()
     1199                            || !polygonArea.getBounds2D().contains(outer.getBounds())
    11981200                            || PolygonIntersection.FIRST_INSIDE_SECOND != polygonIntersection(getArea(outer.getNodes()),
    11991201                                    polygonArea)) {
Note: See TracChangeset for help on using the changeset viewer.