The mp code warns if a polygon intersects itself.

This has a drawback to performance by ~10% in log level WARN is turned on. With log level ERROR the check is not performed.

WanMil

Index: src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java      
(revision 1538)
+++ src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java      
(working copy)
@@ -671,7 +671,7 @@
                List<Area> outerAreas = new ArrayList<Area>();
 
                // 1st create an Area object of the outerRing and put it to the 
list
-               Area oa = createArea(outerRing.getPoints());
+               Area oa = createArea(outerRing);
 
                // the polygons will be later clipped in the style converter
                // so it is not necessary to clip it here
@@ -679,7 +679,7 @@
 
                // go through all innerRings (holes) and cut them from the 
outerRing
                for (Way innerRing : innerRings) {
-                       Area innerArea = createArea(innerRing.getPoints());
+                       Area innerArea = createArea(innerRing);
 
                        List<Area> outerAfterThisStep = new ArrayList<Area>();
                        for (Area outerArea : outerAreas) {
@@ -834,14 +834,22 @@
        }
 
        /**
-        * Create an area from a list of points.
+        * Create an area from a closed way.
         * 
-        * @param points
-        *            list of points
+        * @param w
+        *            a closed way
         * @return the area
         */
-       private Area createArea(List<Coord> points) {
-               return new Area(createPolygon(points));
+       private Area createArea(Way w) {
+               Area area = new Area(createPolygon(w.getPoints()));
+               if (log.isWarnEnabled()) {
+                       if (area.isSingular() == false) {
+                               log.warn("Way", w.getId(), "intersects 
itself.");
+                               log.warn("The way is composed of");
+                               logWayURLs(Level.WARNING, "-", w);
+                       }
+               }
+               return area;
        }
 
        /**
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to