The patch handles the problem reported by Minko
(http://www.mkgmap.org.uk/pipermail/mkgmap-dev/2012q4/015287.html).
It adds the tag mkgmap:tagsincomplete=true to all mps where tags are not
loaded because they are not addressed in the style file. The mp
algorithm uses the tag to decide if the tags must be taken from the
outer ways or from the mp itself.
WanMil
Index: src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java (revision 2346)
+++ src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java (working copy)
@@ -50,6 +50,8 @@
private static final Logger log = Logger
.getLogger(MultiPolygonRelation.class);
+ public static final String TAGS_INCOMPLETE_TAG = "mkgmap:tagsincomplete";
+
public static final String STYLE_FILTER_TAG = "mkgmap:stylefilter";
public static final String STYLE_FILTER_LINE = "polyline";
public static final String STYLE_FILTER_POLYGON = "polygon";
@@ -245,6 +247,9 @@
JoinedWay jw = new JoinedWay(orgSegment);
roleMap.put(jw.getId(), getRole(orgSegment));
if (orgSegment.isClosed()) {
+ if (orgSegment.getPoints().isEmpty()==false && orgSegment.getPoints().get(0).equals(orgSegment.getPoints().get(orgSegment.getPoints().size()-1)) == false) {
+ log.error("Segment "+orgSegment.getId()+" not really closed");
+ }
joinedWays.add(jw);
} else {
unclosedWays.add(jw);
@@ -746,7 +751,7 @@
// check if the multipolygon itself or the non inner member ways have a tag
// if not it does not make sense to process it and we could save the time
boolean shouldProcess = hasStyleRelevantTags(this);
- if (shouldProcess == false) {
+ if (hasTags(this) == false && shouldProcess == false) {
for (Way w : allWays) {
shouldProcess = hasStyleRelevantTags(w);
if (shouldProcess) {
@@ -1512,6 +1517,14 @@
}
protected boolean hasTags(Element element) {
+ if (element instanceof MultiPolygonRelation) {
+ // if a multipolygon has had tags that were removed during load
+ // it has relevant tags although they cannot be evaluated
+ if ("true".equals(element.getTag(TAGS_INCOMPLETE_TAG))) {
+ return true;
+ }
+ }
+
for (Map.Entry<String, String> tagEntry : element.getEntryIteratable()) {
if ("type".equals(tagEntry.getKey()) == false) {
// return true if there is more than one tag other than "type"
@@ -1525,7 +1538,7 @@
for (Map.Entry<String, String> tagEntry : element.getEntryIteratable()) {
String tagName = tagEntry.getKey();
boolean isStyleRelevant = tagName.equals("type") == false
- && tagName.startsWith("name") == false;
+ && tagName.startsWith("name") == false && tagName.equals(TAGS_INCOMPLETE_TAG) == false;
if (isStyleRelevant) {
return true;
}
Index: src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java (revision 2351)
+++ src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java (working copy)
@@ -19,6 +19,7 @@
import uk.me.parabola.log.Logger;
import uk.me.parabola.mkgmap.reader.osm.Element;
import uk.me.parabola.mkgmap.reader.osm.GeneralRelation;
+import uk.me.parabola.mkgmap.reader.osm.MultiPolygonRelation;
import uk.me.parabola.mkgmap.reader.osm.Node;
import uk.me.parabola.mkgmap.reader.osm.OsmHandler;
import uk.me.parabola.mkgmap.reader.osm.Way;
@@ -167,14 +168,23 @@
long id = binRel.getId();
GeneralRelation rel = new GeneralRelation(id);
+ boolean tagsIncomplete = false;
for (int j = 0; j < binRel.getKeysCount(); j++) {
String key = getStringById(binRel.getKeys(j));
String val = getStringById(binRel.getVals(j));
key = keepTag(key, val);
- if (key != null)
+ if (key == null)
+ tagsIncomplete = true;
+ else
rel.addTag(key, val.intern());
}
+ if (tagsIncomplete) {
+ String relType = rel.getTag("type");
+ if ("multipolygon".equals(relType) || "boundary".equals(relType)) {
+ rel.addTag(MultiPolygonRelation.TAGS_INCOMPLETE_TAG, "true");
+ }
+ }
long lastMid = 0;
Index: src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (revision 2351)
+++ src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (working copy)
@@ -20,6 +20,7 @@
import uk.me.parabola.log.Logger;
import uk.me.parabola.mkgmap.reader.osm.Element;
import uk.me.parabola.mkgmap.reader.osm.GeneralRelation;
+import uk.me.parabola.mkgmap.reader.osm.MultiPolygonRelation;
import uk.me.parabola.mkgmap.reader.osm.Node;
import uk.me.parabola.mkgmap.reader.osm.OsmHandler;
import uk.me.parabola.mkgmap.reader.osm.Relation;
@@ -179,6 +180,15 @@
} else if (mode == MODE_RELATION) {
if (qName.equals("relation")) {
mode = 0;
+
+ // remove the mkgmap:tagsincomplete tags which is used in multipolygons only
+ if (currentRelation.getTag(MultiPolygonRelation.TAGS_INCOMPLETE_TAG) != null) {
+ String type = currentRelation.getTag("type");
+ if ("multipolygon".equals(type) == false && "boundary".equals(type) == false) {
+ currentRelation.deleteTag(MultiPolygonRelation.TAGS_INCOMPLETE_TAG);
+ }
+ }
+
saver.addRelation(currentRelation);
}
}
@@ -284,8 +294,11 @@
String key = attributes.getValue("k");
String val = attributes.getValue("v");
key = keepTag(key, val);
- if (key != null)
+ if (key == null) {
+ currentRelation.addTag(MultiPolygonRelation.TAGS_INCOMPLETE_TAG, "true");
+ } else {
currentRelation.addTag(key, val.intern());
+ }
}
}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev