[PATCH] Splitter area rounding seems wrong

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

Hi Bartosz, thanks for your bugfix. It seems reasonable for me. @Steve: can you check that and commit it? WanMil
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
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi
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.
Not sure that I agree. Wouldn't this mean that tile boundaries would overlap if they were originally touching but not aligned? There is a case for expanding the dimensions of the outside edges of a complete tile set. ..Steve

Wouldn't this mean that tile boundaries would overlap if they were originally touching but not aligned?
Yes, you are right. The splitter code is not sufficiently documented to make it clear what it is trying to achieve. After looking at the code, it seemed to me that the goal was to expand the boundary of *each tile separately* so that it falls onto a coarse grid while still bounding the original tile. Having read your comment, I see now that this was an incorrect interpretation. The goal is to shift the boundaries *between tiles* so that they fall onto a coarse grid without introducing overlap. In this case, my patch is not correct. However, I have three observations/questions: 1. If the goal is to shift the boundaries onto a coarse grid, why round *down* for longitudes and *up* for latitudes? Why not round in the same direction for both? 2. After rounding boundaries, the code may shift some of them to ensure that the tile sizes are even multiples of the grid spacing. Since this is done for each tile separately, I think there is a potential to introduce overlap here. If overlap really is a problem (does it break drawing and/or routing?), the decision which boundaries to shift should be coordinated among the tiles.
There is a case for expanding the dimensions of the outside edges of a complete tile set.
3. My last point is related to this comment. The current rounding code does not distinguish between internal subdivisions and outside boundaries. Thus, it will shift the area covered by the tiles so that it no longer include the complete region originally requested. To fix this, as you say, the outside boundaries should be expanded onto the coarse grid. Finally, I am wondering how important the rounding is. It seems that mkgmap will happily process arbitrary .osm files, including those that never passed through the splitter and thus do not have rounded boundaries. Would it be possible to leave out the rounding? Or is it needed for inter-tile routing for example? - Bartosz

Hi
1. If the goal is to shift the boundaries onto a coarse grid, why round *down* for longitudes and *up* for latitudes? Why not round in the same direction for both?
Even though I made that change (originally it rounded down/up in the same way as your patch). I have no idea why one goes up and the other down! Probably no good reason.
Finally, I am wondering how important the rounding is. It seems that mkgmap will happily process arbitrary .osm files, including those that never passed through the splitter and thus do not have rounded boundaries. Would it be possible to leave out the rounding? Or is it needed for inter-tile routing for example?
For routing to work across tiles the nodes at the edge of the tile must match exactly (or within a few units at least) the edge node of the same road in the adjacent tile. The page: http://www.mkgmap.org.uk/page/17 gives some background on the original design. The point about rounding to the course boundaries is not true from the point of view of the Garmin format. At the time I didn't know how to make it work without putting them on course boundaries, but now we probably could. In general the tiles can have completely arbitary boundaries that follow a country border for example, but this would need corresponding support in mkgmap. ..Steve
participants (3)
-
Bartosz Fabianowski
-
Steve Ratcliffe
-
WanMil