logo separator

[mkgmap-dev] Understanding the sea

From Ronny Klier ronny.klier at s1999.tu-chemnitz.de on Wed Dec 30 00:13:53 GMT 2009


Am 20:59, schrieb Mark Burton:
> Hi,
>
> I'm trying to understand how the --generate-sea stuff works. I want to
> know how it decides whether an "island" is water or land. The code does
> not really contain sufficient comments for me to work out what it's
> doing. I would expect it to close coastline segments that reach the
> tile boundary in a direction that is consistent with the "water on the
> right" convention but I can't see that in the code. Can anyone help
> please?
>
> Thanks,
>
> Mark
>
>    
Hi,

I'm working for a while on the flooded island problem. Here's what I found:

While parsing the OSM file all ways tagged as "natural=coastline" are added to "List<Way>  shoreline" (in method Osm5XmlHandler::endElement).
The main work is done in method generateSeaPolygon called from Osm5XmlHandler::endDocument.
First all not closed ways are tryed to be closed by finding ways with matching end and start points (method concatenateWays).
All closed ways are added to a "seaRelation". For the remaining non closed ways its assumed they hit the tile boundary.
There is a class EdgeHit which contains the information which tile border was hit and where. A HashMap holds this info for every start and end point of the non closed ways. The method EdgeHit::compareTo is used to decide how these ways are closed along the tile bordes by adding points at the required corners (lines 1164 to 1225).
I'm not sure if this is really done with the "water on the right" convention, but it works fine ;-).
The problems I found are caused by what is done with the ways not hitting the tile borders. This may happen with data from e.g. geofabrik, where the data does not fill the whole tile border. If such a way exists there is a check if the way is nearly closed.
If this check fails the way is added as an "outer way" to the seaRelation, preventing the bounding box to become the "outer way".
Tiles being cut in a sea part and land part are the visible effect of this.
To solve this I added code to find the nearest border and add a point at this border. There should be no new problem through this because the created point is in an empty area. (sea attached patch)

The rest is done by the multipolygon code. In this class is also a major bug which causes flooded islands. While connecting the inner ways with the outer way, the connection for the current inner way is always added at the shortest distance to the already created result polygon. If a later inner way is nearer to the outer way the connection lines will cross the islands.
So MapSource and perhaps other renderes of img files will not know where the sea is and the islands become flooded.

I hope this helps a bit.

Ronny




More information about the mkgmap-dev mailing list