Changeset 7422 in josm for trunk/src


Ignore:
Timestamp:
2014-08-16T18:10:32+02:00 (5 years ago)
Author:
Don-vip
Message:

see #9680 - small multipolygon computation optimization (reduces time from 26s to 19s) + fix bug in validator preferences

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r7402 r7422  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Rectangle;
    67import java.awt.geom.Area;
    78import java.util.ArrayList;
     
    3233        public final List<Node> nodes;
    3334        public final Area area;
     35        public final Rectangle bounds;
    3436
    3537        /**
     
    4244            this.nodes = this.getNodes();
    4345            this.area = Geometry.getArea(nodes);
     46            this.bounds = area.getBounds();
    4447        }
    4548
     
    275278                }
    276279
    277                 PolygonIntersection intersection = Geometry.polygonIntersection(outerWay.area, innerWay.area);
    278 
    279                 if (intersection == PolygonIntersection.FIRST_INSIDE_SECOND) {
    280                     outerGood = false;  // outer is inside another polygon
    281                     break;
    282                 } else if (intersection == PolygonIntersection.SECOND_INSIDE_FIRST) {
    283                     innerCandidates.add(innerWay);
    284                 } else if (intersection == PolygonIntersection.CROSSING) {
    285                     //ways intersect
    286                     return null;
     280                // Preliminary computation on bounds. If bounds do not intersect, no need to do a costly area intersection
     281                if (outerWay.bounds.intersects(innerWay.bounds)) {
     282                    // Bounds intersection, let's see in detail
     283                    PolygonIntersection intersection = Geometry.polygonIntersection(outerWay.area, innerWay.area);
     284
     285                    if (intersection == PolygonIntersection.FIRST_INSIDE_SECOND) {
     286                        outerGood = false;  // outer is inside another polygon
     287                        break;
     288                    } else if (intersection == PolygonIntersection.SECOND_INSIDE_FIRST) {
     289                        innerCandidates.add(innerWay);
     290                    } else if (intersection == PolygonIntersection.CROSSING) {
     291                        //ways intersect
     292                        return null;
     293                    }
    287294                }
    288295            }
  • trunk/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreference.java

    r7005 r7422  
    4444        }
    4545    }
    46    
     46
    4747    private JCheckBox prefUseIgnore;
    4848    private JCheckBox prefUseLayer;
     
    9292            test.addGui(testPanel);
    9393        }
    94        
     94
    9595        gui.getValidatorPreference().addSubTab(this, tr("Tests"),
    9696                GuiHelper.embedInVerticalScrollPane(testPanel),
     
    105105        for (Test test : allTests) {
    106106            test.ok();
    107             String name = test.getClass().getSimpleName();
     107            String name = test.getClass().getName();
    108108            if(!test.enabled)
    109109                tests.add(name);
     
    111111                testsBeforeUpload.add(name);
    112112        }
    113        
     113
    114114        // Initializes all tests but MapCSSTagChecker because it is initialized
    115115        // later in ValidatorTagCheckerRulesPreference.ok(),
Note: See TracChangeset for help on using the changeset viewer.