Further to my earlier email about the problem of ways that have both
highway and boundary tags defined, here's a patch that possibly
provides a workaround. 

It lets you specify pairs of tags. If a way has both of the tags
defined, it is cloned and one of the clones has one of the tags and
the other clone has the other tag. So for the example in question, you
could specify the option:

 --clone-ways-with-these-tags=highway/boundary

Another possible tag pair could be waterway/boundary

All feedback is welcome.

Cheers,

Mark
diff --git a/resources/help/en/options b/resources/help/en/options
index 8268745..7624638 100644
--- a/resources/help/en/options
+++ b/resources/help/en/options
@@ -157,6 +157,12 @@ Misc options:
 	direction and this option makes a way with the same points as
 	the original that allows bicycle traffic (in both directions).
 
+--clone-ways-with-these-tags=tag1/tag2[,tag1/tag2]...
+	Clone each way that has both tag1 and tag2 defined - the
+	clones are identical except that they each contain only one of
+	tag1 and tag2. Multiple tag pairs can be specified (pairs
+	separated by commas).
+
 --tdbfile
 	Write a .tdb file.
 
diff --git a/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java b/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
index aa5bab1..0ee0ef9 100644
--- a/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
+++ b/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
@@ -96,6 +96,8 @@ public class StyledConverter implements OsmConverter {
 	private final Rule nodeRules;
 	private final Rule relationRules;
 
+	private List<String[]> cloneWaysWithTheseTagPairs;
+
 	private boolean ignoreMaxspeeds;
 
 	class AccessMapping {
@@ -142,6 +144,30 @@ public class StyledConverter implements OsmConverter {
 		LineAdder overlayAdder = style.getOverlays(lineAdder);
 		if (overlayAdder != null)
 			lineAdder = overlayAdder;
+
+		String cloneWaysOptionName = "clone-ways-with-these-tags";
+		String s = props.getProperty(cloneWaysOptionName);
+		boolean cloneWaysSyntaxError = false;
+
+		if(s != null) {
+			String[] tagPairs = s.split(",");
+			if(tagPairs.length == 0)
+				cloneWaysSyntaxError = true;
+			for(int i = 0; i < tagPairs.length; ++i) {
+				String[] tags = tagPairs[i].split("/");
+				if(tags.length != 2)
+					cloneWaysSyntaxError = true;
+				else if(!tags[0].equals(tags[1])) {
+					if(cloneWaysWithTheseTagPairs == null)
+						cloneWaysWithTheseTagPairs = new ArrayList<String[]>();
+					cloneWaysWithTheseTagPairs.add(tags);
+				}
+			}
+		}
+
+		if(cloneWaysSyntaxError) {
+			log.error(cloneWaysOptionName + " option value should be of the form 'tag1/tag2' (multiple tag pairs can be specified, separate each pair with ',')");
+		}
 	}
 
 	/**
@@ -157,6 +183,21 @@ public class StyledConverter implements OsmConverter {
 		if (way.getPoints().size() < 2)
 			return;
 
+		if(cloneWaysWithTheseTagPairs != null) {
+			for(String[] tags : cloneWaysWithTheseTagPairs) {
+				if(way.getTag(tags[0]) != null &&
+				   way.getTag(tags[1]) != null) {
+					// copy the way's name and tags to the new way
+					Way dupWay = new Way(way.getId());
+					dupWay.copyTags(way);
+					dupWay.deleteTag(tags[0]);
+					way.deleteTag(tags[1]);
+					log.info("Cloning way " + way.getTag("name") + " (OSM id " + way.getId() + ") so that both " + tags[0] + " and " + tags[1] + " tags will generate map objects");
+					convertWay(dupWay);
+				}
+			}
+		}
+
 		preConvertRules(way);
 
 		GType foundType = wayRules.resolveType(way);
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to