Hi list

I am debugging a coastline/sea generation issue and in the process of this, discovered what I believe to be a splitter bug.

There is a method in RoundingUtils.java that rounds the boundaries of an area to multiples of Garmin units. The minimum and maximum longitude are both rounded down while the minimum and maximum latitude are both rounded up. The resulting rounded area is therefore shifted relative to the original area and does not necessarily bound all the data.

This looks like a bug to me. The attached patch rounds the minimum longitude/latitude down and the maximum longitude/latitude up, making sure that the rounded area always fully contains the original area.

- Bartosz
Index: src/uk/me/parabola/splitter/RoundingUtils.java
===================================================================
--- src/uk/me/parabola/splitter/RoundingUtils.java      (revision 179)
+++ src/uk/me/parabola/splitter/RoundingUtils.java      (working copy)
@@ -71,12 +71,12 @@
                int minLat = Math.max(b.getMinLat(), Utils.toMapUnit(-85.0d));
                int maxLat = Math.min(b.getMaxLat(), Utils.toMapUnit(85.0d));
 
-               int roundedMinLat = roundUp(minLat, shift);
+               int roundedMinLat = roundDown(minLat, shift);
                int roundedMaxLat = roundUp(maxLat, shift);
                if ((roundedMinLat & alignment) != (roundedMaxLat & alignment)) 
{
                        // The new height isn't a multiple of twice the 
alignment. Fix it by pushing
                        // the tile edge that moved the least out by another 
'alignment' units.
-                       if (minLat - roundedMinLat < maxLat - roundedMaxLat) {
+                       if (minLat - roundedMinLat < roundedMaxLat - maxLat) {
                                roundedMinLat -= alignment;
                        } else {
                                roundedMaxLat += alignment;
@@ -87,7 +87,7 @@
                assert (roundedMaxLat - roundedMinLat) % doubleAlignment == 0 : 
"The area's height is not a multiple of " + doubleAlignment;
 
                int roundedMinLon = roundDown(b.getMinLong(), shift);
-               int roundedMaxLon = roundDown(b.getMaxLong(), shift);
+               int roundedMaxLon = roundUp(b.getMaxLong(), shift);
                if ((roundedMinLon & alignment) != (roundedMaxLon & alignment)) 
{
                        // The new width isn't a multiple of twice the 
alignment. Fix it by pushing
                        // the tile edge that moved the least out by another 
'alignment' units.
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to