logo separator

[mkgmap-dev] Multipolygons and disappearing coastlines

From Mark Burton markb at ordern.com on Sat Dec 26 22:11:55 GMT 2009

Hi Chris,

> Mark Burton schrieb:
> 
> > So, is putting the coastline into a multipolygon a reasonable OSM
> > thing? 
> 
> A coastline is often also a boundary and boundaries are
> multipolygons in OSM.
> 
> > If so, should mkgmap be breaking the coastline by removing its
> > tags? If not, how do we fix that?
> 
> My guess is, that the multipolygon handling in mkgmap is not working
> perfectly.
> 
> See an older thread on this list where I suggest a
> workaround. (I check if the MP has no inner elements
> and change the type=multipolygon to type=boundarypolygon
> if this is the case).
> 
> Chris

OK, that's understood.

But why do we have to trash the original ways when we make a
multipolygon from them? Would it not be better to give the relation a
duplicate of the way to trash so that the original way can go on to
serve its original purpose. Perhaps we should do this:

diff --git a/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java b/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
index acc5cf9..fbb1d57 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
@@ -266,10 +266,12 @@ class Osm5XmlHandler extends DefaultHandler {
        private void startInRelation(String qName, Attributes attributes) {
                if (qName.equals("member")) {
                        long id = idVal(attributes.getValue("ref"));
-                       Element el;
+                       Element el = null;
                        String type = attributes.getValue("type");
-                       if ("way".equals(type)){
-                               el = wayMap.get(id);
+                       if ("way".equals(type)) {
+                               Way way = wayMap.get(id);
+                               if(way != null)
+                                       el = way.duplicate();
                        } else if ("node".equals(type)) {
                                el = nodeMap.get(id);
                                if(el == null) {

I just tried this patch and (just like magic) the coastline reappears.

Cheers,

Mark



More information about the mkgmap-dev mailing list