Hi WanMil,

The patch closes all ways having both endpoints on the same side
outside the bounding box. In this case it is not necessary to check
if closing the way intersects the way itself.

This fixes most (but not all) of the outstanding tile splitter
problems.

I still see some warnings presumably due to tile splitter, but other
than that, this and mp_lesscuts_v2.patch look fine to me. Compared to
the unpatched mkgmap r1593, these two patches shaved more than 11k off
the warning log (181452 bytes for today, 192079 for yesterday, even
though today's run contained many non-multipolygon warnings).

        Marko

Torsten Leistikow pointed me to another problem with the tile bounds. In case a polygon was splitted by the bounding box into different distinct polygons only the first of it was taken.

Version 2 of this patch handles this case.

Summary for version 2:
- Closing ways with both endpoints outside the bounding box and with both orientation towards the bounding box. - Bugfix: if a polygon was splitted by the bounding box into different distinct polygons only the first of it was taken. Now all distinct polygons are processed. (thanks to Torsten Leistikow)

I give a very big "GO for commit" to this patch :-)

WanMil
Index: src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java      
(revision 1593)
+++ src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java      
(working copy)
@@ -325,6 +325,22 @@
                        }
                        Coord p1 = way.getPoints().get(0);
                        Coord p2 = way.getPoints().get(way.getPoints().size() - 
1);
+                       
+                       // check if both endpoints are outside the bounding box 
+                       // and if they are on the same side of the bounding box
+                       if ((p1.getLatitude() <= bbox.getMinLat() && 
p2.getLatitude() <= bbox.getMinLat())
+                                || (p1.getLatitude() >= bbox.getMaxLat() && 
p2.getLatitude() >= bbox.getMaxLat())              
+                                || (p1.getLongitude() <= bbox.getMinLong() && 
p2.getLongitude() <= bbox.getMinLong())          
+                                || (p1.getLongitude() >= bbox.getMaxLong() && 
p2.getLongitude() >= bbox.getMaxLong())) {
+                               // they are on the same side outside of the bbox
+                               // so just close them without worrying about if
+                               // they intersect itself because the 
intersection also
+                               // is outside the bbox
+                               way.closeWayArtificially();
+                               log.info("Endpoints of way",way,"are both 
outside the bbox. Closing it directly.");
+                               continue;
+                       }
+                       
                        Line2D closingLine = new 
Line2D.Float(p1.getLongitude(), p1
                                        .getLatitude(), p2.getLongitude(), 
p2.getLatitude());
 
@@ -792,10 +808,17 @@
                        .getMinLat(), bbox.getMaxLong() - bbox.getMinLong(),
                        bbox.getMaxLat() - bbox.getMinLat()));
                
+               // clip the bounding box
                for (Area outerArea : oa) {
-                       // clip all areas to the bounding box
-                       outerArea.intersect(bboxArea);
-                       outerAreas.add(outerArea);
+                       if (bboxArea.contains(outerArea.getBounds())) {
+                               // no clipping necessary
+                               outerAreas.add(outerArea);
+                       } else {
+                               // the area might intersect the bounding box
+                               // => clip it to the bounding box
+                               outerArea.intersect(bboxArea);
+                               
outerAreas.addAll(areaToSingularAreas(outerArea));
+                       }
                }
 
                List<Area> innerAreas = new ArrayList<Area>();
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to