logo separator

[mkgmap-dev] Understanding the sea

From Martin Simon grenzdebil at gmail.com on Mon Dec 28 21:07:33 GMT 2009

2009/12/28 Mark Burton <markb at ordern.com>:
> 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?
> I hesitate to whine about contributions to mkgmap as I don't want to
> stop them arriving but if we can't easily work out how the code works
> then it doesn't bode well for maintenance and bug fixing when the
> original author has moved on.
> I have agreed to help produce a marine map of the Baltic so
> it would be really nice if the sea was filled in without any really
> major problems (flooded land, etc.) I realise that this is dependent on
> the performance of the MP stuff but it seems to me that generating the
> right polygons in the first place would be a good start.

Hi Mark!

I can't help you with the code directly, but I'm facing a similar
problem because i use elevation contours as polygons for visualisation
of terrain shapes and have to do a _lot_ of manual fixing with JOSM
just to close the ways of my rather small srtm tiles.

What I do is the following (described how i think a program could do it):

1. find the end node of a way tagged with the lowest elevation level
that is on the tile boundary.

2. as my srtm tiles are generated by "ground truth", contour lines
always go clockwise around a peak (higher terrain is on the right hand
side). So I follow the tile border clockwise until I either hit a
corner node (i have to insert them manually), which I would then
append to the way and continue, or hit a start node of a contour with
the same elevation, which I would combine with my way and continue *at
the new end node of the current way*(this is important because there
can be other ways in between which should form a polygon on thier

3. If I hit the start node of the way i'm currently working on, i
close the way and look for others I did'nt touch before

5. if there are none left, i add all counter-clockwise ways not
touching the boundary to a multipolygon with role=inner and move on to
the next elevation step

I think the scheme is pretty simple and should work for sea, but I
since I can't write code, I can't create a tool that does the job for

If you work on the generate-sea-code, maybe you could consider to make
the close-ways-(anti)clockwise-around-tile-borders-to-form-polygons
functionality usable for other things, too - such as creating usable
polygons from elevation contours?

I'll upload a 1°x2° test area map of this stuff within the next days,
in case someone wonders what the hell this guy is talking about. ;-)


More information about the mkgmap-dev mailing list