Josef,
you are right. Some parts of the boundary are not created although the
ways are in the tile. The reason is the incomplete boundary relation
which cannot be fully processed by the multipolygon algorithm.
Can you try the patch? This fixes that the ways of a multipolygon are
tagged with the multipolygon tags no matter if the mulitpolygon could be
processed successfully.
WanMil
Hi,
I create my own map with 'boundary=administrative& admin_level=2' in
the line style file to display the German boundary. I made a sreenshot
(available at http://ge.tt/57JRmwj) where you can see the gaps.
The boundary is a relation with the ID 51477.
The relation itself has no gaps as far as I could estimate.
Any hints?
Thanks
Josef
Index: src/uk/me/parabola/mkgmap/reader/osm/Element.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/Element.java (revision 1896)
+++ src/uk/me/parabola/mkgmap/reader/osm/Element.java (working copy)
@@ -117,10 +117,7 @@
}
protected void removeAllTags() {
- if (tags != null) {
- tags.removeAll();
- tags = null;
- }
+ tags = null;
}
public Iterable<Map.Entry<String, String>> getEntryIteratable() {
Index: src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java (revision 1896)
+++ src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java (working copy)
@@ -1,6 +1,7 @@
package uk.me.parabola.mkgmap.reader.osm;
-import java.awt.*;
+import java.awt.Polygon;
+import java.awt.Rectangle;
import java.awt.geom.Area;
import java.awt.geom.Line2D;
import java.util.ArrayList;
@@ -613,6 +614,7 @@
// do nothing
log.info("Multipolygon " + toBrowseURL()
+ " does not contain a closed polygon.");
+ tagOuterWays();
cleanup();
return;
}
@@ -623,6 +625,7 @@
// do nothing
log.info("Multipolygon " + toBrowseURL()
+ " is completely outside the bounding box. It is not processed.");
+ tagOuterWays();
cleanup();
return;
}
@@ -809,7 +812,7 @@
// this is the outer most polygon - copy its tags. They will be used
// later for tagging of the lines
- // all cut polygons have the same tags - get the first way to copy them
+ // all cut polygons have the same tags - copy them from the first polygon
Way outerWay = singularOuterPolygons.get(0);
for (Entry<String, String> tag : outerWay.getEntryIteratable()) {
outerTags.put(tag.getKey(), tag.getValue());
@@ -1769,6 +1772,42 @@
}
}
+ private void tagOuterWays() {
+ Map<String, String> tags;
+ if (hasTags(this)) {
+ tags = new HashMap<String, String>();
+ for (Entry<String, String> relTag : getEntryIteratable()) {
+ tags.put(relTag.getKey(), relTag.getValue());
+ }
+ } else {
+ tags = JoinedWay.getMergedTags(outerWaysForLineTagging);
+ }
+
+
+ // Go through all original outer ways, create a copy, tag them
+ // with the mp tags and mark them only to be used for polyline processing
+ // This enables the style file to decide if the polygon information or
+ // the simple line information should be used.
+ for (Way orgOuterWay : outerWaysForLineTagging) {
+ Way lineTagWay = new Way(FakeIdGenerator.makeFakeId(), orgOuterWay.getPoints());
+ lineTagWay.setName(orgOuterWay.getName());
+ lineTagWay.addTag(STYLE_FILTER_TAG, STYLE_FILTER_LINE);
+ for (Entry<String,String> tag : tags.entrySet()) {
+ lineTagWay.addTag(tag.getKey(), tag.getValue());
+
+ // remove the tag from the original way if it has the same value
+ if (tag.getValue().equals(orgOuterWay.getTag(tag.getKey()))) {
+ removeTagsInOrgWays(orgOuterWay, tag.getKey());
+ }
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Add line way", lineTagWay.getId(), lineTagWay.toTagString());
+ tileWayMap.put(lineTagWay.getId(), lineTagWay);
+ }
+ }
+
+
/**
* Marks all tags of the original ways of the given JoinedWay that are also
* contained in the given tagElement for removal.
@@ -1985,40 +2024,54 @@
return closedArtificially;
}
- /**
- * Tags this way with a merge of the tags of all original ways.
- */
- public void mergeTagsFromOrgWays() {
- if (log.isDebugEnabled()) {
- log.debug("Way",getId(),"merge tags from",getOriginalWays().size(),"ways");
- }
+ public static Map<String,String> getMergedTags(Collection<Way> ways) {
+ Map<String,String> mergedTags = new HashMap<String, String>();
boolean first = true;
- for (Way way : getOriginalWays()) {
+ for (Way way : ways) {
if (first) {
// the tags of the first way are copied completely
for (Map.Entry<String, String> tag : way.getEntryIteratable()) {
- addTag(tag.getKey(), tag.getValue());
- }
- if (log.isDebugEnabled()) {
- log.debug("Copy all tags from the first way", way.getId(), toTagString());
+ mergedTags.put(tag.getKey(), tag.getValue());
}
first = false;
} else {
// for all other ways all non matching tags are removed
- for (Map.Entry<String, String> tag : this.getEntryIteratable()) {
+ ArrayList<String> tagsToRemove = null;
+ for (Map.Entry<String, String> tag : mergedTags.entrySet()) {
String wayTagValue = way.getTag(tag.getKey());
if (!tag.getValue().equals(wayTagValue)) {
// the tags are different
- if (log.isDebugEnabled()) {
- log.debug("Remove differing tag",tag.getKey(),getId()+"="+tag.getValue(),way.getId()+"="+wayTagValue);
- }
if (wayTagValue!= null) {
- deleteTag(tag.getKey());
+ if (tagsToRemove == null) {
+ tagsToRemove=new ArrayList<String>();
+ }
+ tagsToRemove.add(tag.getKey());
}
}
}
+ if (tagsToRemove!=null) {
+ for (String tag : tagsToRemove) {
+ mergedTags.remove(tag);
+ }
+ }
}
}
+ return mergedTags;
+ }
+
+ /**
+ * Tags this way with a merge of the tags of all original ways.
+ */
+ public void mergeTagsFromOrgWays() {
+ if (log.isDebugEnabled()) {
+ log.debug("Way",getId(),"merge tags from",getOriginalWays().size(),"ways");
+ }
+ removeAllTags();
+
+ Map<String,String> mergedTags = getMergedTags(getOriginalWays());
+ for (Entry<String,String> tag : mergedTags.entrySet()) {
+ addTag(tag.getKey(),tag.getValue());
+ }
}
public List<Way> getOriginalWays() {
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev