Changeset 6841 in josm for trunk/src/org


Ignore:
Timestamp:
2014-02-12T00:55:05+01:00 (10 years ago)
Author:
Don-vip
Message:

see #9680 - Boost multipolygon computation performance by caching Areas

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

Legend:

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

    r6093 r6841  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.geom.Area;
    67import java.util.ArrayList;
    78import java.util.Collection;
     
    2627        public final List<Boolean> reversed;
    2728        public final List<Node> nodes;
     29        public final Area area;
    2830
    2931        public JoinedPolygon(List<Way> ways, List<Boolean> reversed) {
     
    3133            this.reversed = reversed;
    3234            this.nodes = this.getNodes();
     35            this.area = Geometry.getArea(nodes);
    3336        }
    3437
     
    3841         */
    3942        public JoinedPolygon(Way way) {
    40             this.ways = Collections.singletonList(way);
    41             this.reversed = Collections.singletonList(Boolean.FALSE);
    42             this.nodes = this.getNodes();
    43         }
    44 
     43            this(Collections.singletonList(way), Collections.singletonList(Boolean.FALSE));
     44        }
    4545
    4646        /**
     
    233233                }
    234234
    235                 PolygonIntersection intersection = Geometry.polygonIntersection(outerWay.nodes, innerWay.nodes);
     235                PolygonIntersection intersection = Geometry.polygonIntersection(outerWay.area, innerWay.area);
    236236
    237237                if (intersection == PolygonIntersection.FIRST_INSIDE_SECOND) {
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r6830 r6841  
    441441    }
    442442
    443     private static Area getArea(List<Node> polygon) {
     443    /**
     444     * Returns the Area of a polygon, from its list of nodes.
     445     * @param polygon List of nodes forming polygon
     446     * @return Area for the given list of nodes
     447     * @since 6841
     448     */
     449    public static Area getArea(List<Node> polygon) {
    444450        Path2D path = new Path2D.Double();
    445451
     
    462468    /**
    463469     * Tests if two polygons intersect.
    464      * @param first
    465      * @param second
     470     * @param first List of nodes forming first polygon
     471     * @param second List of nodes forming second polygon
    466472     * @return intersection kind
    467473     */
    468474    public static PolygonIntersection polygonIntersection(List<Node> first, List<Node> second) {
    469 
    470475        Area a1 = getArea(first);
    471476        Area a2 = getArea(second);
     477        return polygonIntersection(a1, a2);
     478    }
     479
     480    /**
     481     * Tests if two polygons intersect.
     482     * @param a1 Area of first polygon
     483     * @param a2 Area of second polygon
     484     * @return intersection kind
     485     * @since 6841
     486     */
     487    public static PolygonIntersection polygonIntersection(Area a1, Area a2) {
    472488
    473489        Area inter = new Area(a1);
Note: See TracChangeset for help on using the changeset viewer.