[PATCH] Option to extend sea sectors at extract borders

Hi, this patch (against 1485) adds a new option for generate-sea: "extend-sea-sectors" If this option is set, coastlines not reaching the borders of a map will be extended with a point at the nearest border. This prevents strange things happening at the borders of geofabrik extracts. See attached pictures of turkey created with options "polygon" (just_polygon.png), "polygon,no-sea-sectors" (noseasectors.png) and "polygon,extend-sea-sectors" (with_patch.png). Would be nice if someone could test and merge it. Thanks, Ronny

Hi Ronny,
this patch (against 1485) adds a new option for generate-sea: "extend-sea-sectors" If this option is set, coastlines not reaching the borders of a map will be extended with a point at the nearest border. This prevents strange things happening at the borders of geofabrik extracts. See attached pictures of turkey created with options "polygon" (just_polygon.png), "polygon,no-sea-sectors" (noseasectors.png) and "polygon,extend-sea-sectors" (with_patch.png).
Would be nice if someone could test and merge it.
That looks a useful addition but as you haven't put any comments in getNextEdgeHit() it's not immediately obvious what it's doing. You do have one comment: // create additional points at next border Perhaps I'm just stupid, but it doesn't really explain what happens next. The original generate sea code was not well commented but that doesn't mean that additions to it have to similar. Mark

On 18.01.2010 00:13, Mark Burton wrote:
Hi Ronny,
this patch (against 1485) adds a new option for generate-sea: "extend-sea-sectors" If this option is set, coastlines not reaching the borders of a map will be extended with a point at the nearest border. This prevents strange things happening at the borders of geofabrik extracts. See attached pictures of turkey created with options "polygon" (just_polygon.png), "polygon,no-sea-sectors" (noseasectors.png) and "polygon,extend-sea-sectors" (with_patch.png).
Would be nice if someone could test and merge it.
That looks a useful addition but as you haven't put any comments in getNextEdgeHit() it's not immediately obvious what it's doing.
You do have one comment: // create additional points at next border
Perhaps I'm just stupid, but it doesn't really explain what happens next.
The original generate sea code was not well commented but that doesn't mean that additions to it have to similar.
Mark _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
I just tried out this patch on Italy from geofabrik (on trunk plus wanmil's mp patch v3) and it was the first time for me that I got a correct sea generation (using --generate-sea=polygons,no-sea-sectors,extend-sea-sectors), (well the sea was empty so I had to color 0x4b blue in my style-file, but land was correct, however that is a problem still related to wanmil's mp patch v3.) I then tried it on Denmark (which previous to this patch posed problems) and it was working mint too.

Hi Felix,
I just tried out this patch on Italy from geofabrik (on trunk plus wanmil's mp patch v3) and it was the first time for me that I got a correct sea generation (using --generate-sea=polygons,no-sea-sectors,extend-sea-sectors),
(well the sea was empty so I had to color 0x4b blue in my style-file, but land was correct, however that is a problem still related to wanmil's mp patch v3.)
I then tried it on Denmark (which previous to this patch posed problems) and it was working mint too.
That's good. BTW, does mapsource for you draw lines at the tile boundaries which get covered up by the land/sea polygons? I'm getting them now but I haven't a clue where they are coming from. Also, I posted a little patch the other day that frigged the overview map rounding so that it makes mapsource mouse popup balloons right up to either side of the tile boundaries (without the patch, it only pops up a balloon on one side of the boundary). Do you see that problem on your maps? Mark

On 18.01.2010 00:53, Mark Burton wrote:
Hi Felix,
I just tried out this patch on Italy from geofabrik (on trunk plus wanmil's mp patch v3) and it was the first time for me that I got a correct sea generation (using --generate-sea=polygons,no-sea-sectors,extend-sea-sectors),
(well the sea was empty so I had to color 0x4b blue in my style-file, but land was correct, however that is a problem still related to wanmil's mp patch v3.)
Ups, just noticed that that once I zoom in to closer than 3km in Italy everything is flooded (in Denmark there is no problem) as 0x10100 is not set on resolution 24-20 (only 17-19) ( when using --generate-sea=polygons,no-sea-sectors,extend-sea-sectors option and then setting 0x4b to blue.
So the bug you discovered here (in WanMil's patch v3) cannot safely be circumvented by using a clever TYPFile. On the other hand if I use --generate-sea=no-sea-sectors,extend-sea-sectors then I miss most of the sea in Italy (only Sicilly tile has sea). I'll try right now with only --generate-sea=extend-sea-sectors. Using the =polygon switch it is clear that mkgmap does know 100% where there is sea and where not. I simply don't understand why 0x10100 is not set below 3km in Italy...
I then tried it on Denmark (which previous to this patch posed problems) and it was working mint too.
That's good.
BTW, does mapsource for you draw lines at the tile boundaries which get covered up by the land/sea polygons? I'm getting them now but I haven't a clue where they are coming from.
They are allways present. I just haven't got a clue why since a few versions (can't really say which one), the are covered up by polygons. Before and with "original" Garmin maps they are not covered up (at least not when zoomed far out, they disappear once you zoom in). There are even Mapsource or Basecamp versions (I'm not sure current or historic) where there is an option to switch them off. They are there to help you pick the tiles you want to have (needed if maps have 0x4b set in TYP-file because then you can't always see the tile being highlighted if selected (to be sent to the GPS)). The color of these lines actually depends on 0x4b color.....
Also, I posted a little patch the other day that frigged the overview map rounding so that it makes mapsource mouse popup balloons right up to either side of the tile boundaries (without the patch, it only pops up a balloon on one side of the boundary). Do you see that problem on your maps?
I cannot relate the above. Do you mean this patch: /This patch stops the DP filter from discarding points at either end of a horizontal or vertical line segment (such segments are created by the clipper and also by the polygon splitter and, of course, could occur naturally in the OSM data but I'd guess they are relatively rare)./ .....
Mark _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Felix,
Ups, just noticed that that once I zoom in to closer than 3km in Italy everything is flooded (in Denmark there is no problem) as 0x10100 is not set on resolution 24-20 (only 17-19) ( when using --generate-sea=polygons,no-sea-sectors,extend-sea-sectors option and then setting 0x4b to blue.
So the bug you discovered here (in WanMil's patch v3) cannot safely be circumvented by using a clever TYPFile. On the other hand if I use --generate-sea=no-sea-sectors,extend-sea-sectors then I miss most of the sea in Italy (only Sicilly tile has sea).
I am guessing that the oversize sea sector is getting dropped somehow by the clipping. Hopefully, WanMil will issue a new version that only bloats the sea box when MP is being used.
I'll try right now with only --generate-sea=extend-sea-sectors. Using the =polygon switch it is clear that mkgmap does know 100% where there is sea and where not. I simply don't understand why 0x10100 is not set below 3km in Italy...
I then tried it on Denmark (which previous to this patch posed problems) and it was working mint too.
That's good.
BTW, does mapsource for you draw lines at the tile boundaries which get covered up by the land/sea polygons? I'm getting them now but I haven't a clue where they are coming from.
They are allways present. I just haven't got a clue why since a few versions (can't really say which one), the are covered up by polygons. Before and with "original" Garmin maps they are not covered up (at least not when zoomed far out, they disappear once you zoom in). There are even Mapsource or Basecamp versions (I'm not sure current or historic) where there is an option to switch them off. They are there to help you pick the tiles you want to have (needed if maps have 0x4b set in TYP-file because then you can't always see the tile being highlighted if selected (to be sent to the GPS)). The color of these lines actually depends on 0x4b color.....
OK. Somehow, I have never really noticed those lines before (I live in a dream world).
Also, I posted a little patch the other day that frigged the overview map rounding so that it makes mapsource mouse popup balloons right up to either side of the tile boundaries (without the patch, it only pops up a balloon on one side of the boundary). Do you see that problem on your maps?
I cannot relate the above. Do you mean this patch:
/This patch stops the DP filter from discarding points at either end of a horizontal or vertical line segment (such segments are created by the clipper and also by the polygon splitter and, of course, could occur naturally in the OSM data but I'd guess they are relatively rare)./
No, it was called "fix overview bounding box rounding", but what I'm asking is not whether you have tried that patch but do you see the problem that the patch fixes? i.e. can you move the mouse across a tile boundary and get a popup describing the map feature you are above. For me, that popup would only happen on one side of the boundary, on the other side, you had to move the mouse a quite a long way before it started popping up words again. My belief is that the overview map's rounding is wrong and so it doesn't match all of the tile's edges. Mark

Felix,
I am guessing that the oversize sea sector is getting dropped somehow by the clipping. Hopefully, WanMil will issue a new version that only bloats the sea box when MP is being used.
Yes, I changed his code so that it only bloats the sea sector when using multipolygon for the sea generation and generate-sea=polygons works again: if(generateSeaUsingMP) { // the sea background area must be a little bigger than all // inner land areas. this is a workaround for a mp shortcoming: // mp is not able to combine outer and inner if they intersect // or have overlaying lines // the added area will be clipped later by the style generator (?) sea.addPoint(new Coord(nw.getLatitude()-1,nw.getLongitude()-1)); sea.addPoint(new Coord(sw.getLatitude()+1,sw.getLongitude()-1)); sea.addPoint(new Coord(se.getLatitude()+1,se.getLongitude()+1)); sea.addPoint(new Coord(ne.getLatitude()-1,ne.getLongitude()+1)); sea.addPoint(new Coord(nw.getLatitude()-1,nw.getLongitude()-1)); } else { sea.addPoint(nw); sea.addPoint(sw); sea.addPoint(se); sea.addPoint(ne); sea.addPoint(nw); }

On 18.01.2010 13:19, Mark Burton wrote:
Felix,
I am guessing that the oversize sea sector is getting dropped somehow by the clipping. Hopefully, WanMil will issue a new version that only bloats the sea box when MP is being used.
Yes, I changed his code so that it only bloats the sea sector when using multipolygon for the sea generation and generate-sea=polygons works again:
if(generateSeaUsingMP) { // the sea background area must be a little bigger than all // inner land areas. this is a workaround for a mp shortcoming: // mp is not able to combine outer and inner if they intersect // or have overlaying lines // the added area will be clipped later by the style generator (?) sea.addPoint(new Coord(nw.getLatitude()-1,nw.getLongitude()-1)); sea.addPoint(new Coord(sw.getLatitude()+1,sw.getLongitude()-1)); sea.addPoint(new Coord(se.getLatitude()+1,se.getLongitude()+1)); sea.addPoint(new Coord(ne.getLatitude()-1,ne.getLongitude()+1)); sea.addPoint(new Coord(nw.getLatitude()-1,nw.getLongitude()-1)); } else { sea.addPoint(nw); sea.addPoint(sw); sea.addPoint(se); sea.addPoint(ne); sea.addPoint(nw); }
Which file is this supposed to be in? Well if it works, I think you should submit this patch, the mp patches and the extend-sea patches into trunk. It all seems to work very well.
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Felix,
Which file is this supposed to be in?
Osm5x...
Well if it works, I think you should submit this patch, the mp patches and the extend-sea patches into trunk. It all seems to work very well.
Ideally, WanMill will add that change to his MP code and then issue a new patch that can be "approved" and, hopefully, committed. Mark

dropping --no-sea-sectors did not help. Still sea got omitted if not using "polygons". Probably someone should analyse what's the problem in Italy, maybe then the bug why "polygons" is not working as expected can be found. The good thing is.... in principal it should work...

Am 18.01.2010 00:13, schrieb Mark Burton:
Hi Ronny,
this patch (against 1485) adds a new option for generate-sea: "extend-sea-sectors" If this option is set, coastlines not reaching the borders of a map will be extended with a point at the nearest border. This prevents strange things happening at the borders of geofabrik extracts. See attached pictures of turkey created with options "polygon" (just_polygon.png), "polygon,no-sea-sectors" (noseasectors.png) and "polygon,extend-sea-sectors" (with_patch.png).
Would be nice if someone could test and merge it.
That looks a useful addition but as you haven't put any comments in getNextEdgeHit() it's not immediately obvious what it's doing.
You do have one comment: // create additional points at next border
Perhaps I'm just stupid, but it doesn't really explain what happens next.
The original generate sea code was not well commented but that doesn't mean that additions to it have to similar.
Mark
OK. I added some comments. Hope this explains what is done. Ronny

Ronny, Sorry, I missed this before. Could you please add a line to the generate-sea help blurb that describes the new option and also add similar words in the appropriate place in resources/help/en/options. Thanks, Mark

Am 18.01.2010 01:05, schrieb Mark Burton:
Ronny,
Sorry, I missed this before. Could you please add a line to the generate-sea help blurb that describes the new option and also add similar words in the appropriate place in resources/help/en/options.
Thanks,
Mark
Hi, Added the help texts in this new patch. Ronny
participants (3)
-
Felix Hartmann
-
Mark Burton
-
Ronny Klier