As requested, here's an option (--make-cycleway-tracks) to enable the
synthesis of cycleways when a (non-cycleway) way is tagged
cycleway=track.

I have also tweaked the code for making opposite cycleways - it now
gives the synthesised way a highway=cycleway tag which it wasn't doing
before.

So anyone who was using the --make-opposite-cycleways option, please
test to see it hasn't been broken.

Cheers,

Mark
diff --git a/resources/help/en/options b/resources/help/en/options
index 5dc82cc..80fff50 100644
--- a/resources/help/en/options
+++ b/resources/help/en/options
@@ -168,6 +168,11 @@ Misc options:
 	direction and this option makes a way with the same points as
 	the original that allows bicycle traffic (in both directions).
 
+--make-cycleway-tracks
+	Some streets have a separate cycleway just for bicycle traffic
+	and this option makes a way with the same points as the
+	original that allows bicycle traffic.
+
 --link-pois-to-ways
 	If this option is enabled, POIs that are situated at a point
 	in a way will be associated with that way and may modify the
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 2f463f0..c672dbe 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
@@ -87,6 +87,7 @@ class Osm5XmlHandler extends DefaultHandler {
 	private long nextFakeId = 1;
 
 	private final boolean makeOppositeCycleways;
+	private final boolean makeCyclewayTracks;
 	private final boolean ignoreBounds;
 	private final boolean ignoreTurnRestrictions;
 	private final boolean linkPOIsToWays;
@@ -96,6 +97,7 @@ class Osm5XmlHandler extends DefaultHandler {
 
 	public Osm5XmlHandler(EnhancedProperties props) {
 		makeOppositeCycleways = props.getProperty("make-opposite-cycleways", false);
+		makeCyclewayTracks = props.getProperty("make-cycleway-tracks", false);
 		linkPOIsToWays = props.getProperty("link-pois-to-ways", false);
 		ignoreBounds = props.getProperty("ignore-osm-bounds", false);
 		routing = props.containsKey("route");
@@ -293,7 +295,9 @@ class Osm5XmlHandler extends DefaultHandler {
 								currentWay.addTag("mkgmap:frig_roundabout", frigRoundabouts);
 						}
 					}
-					if(makeOppositeCycleways && currentWay.isBoolTag("oneway")) {
+					if(makeOppositeCycleways &&
+					   !"cycleway".equals(highway) &&
+					   currentWay.isBoolTag("oneway")) {
 						String cyclewayTag = currentWay.getTag("cycleway");
 						if("opposite".equals(cyclewayTag) ||
 						   "opposite_lane".equals(cyclewayTag) ||
@@ -314,13 +318,47 @@ class Osm5XmlHandler extends DefaultHandler {
 							for(int i = points.size() - 1; i >= 0; --i)
 								cycleWay.addPoint(points.get(i));
 							cycleWay.copyTags(currentWay);
-							cycleWay.addTag("name", currentWay.getTag("name") + " (cycleway)");
+							cycleWay.addTag("highway", "cycleway");
+							String name = currentWay.getTag("name");
+							if(name != null)
+								name += " (cycleway)";
+							else
+								name = "cycleway";
+							cycleWay.addTag("name", name);
 							cycleWay.addTag("oneway", "no");
 							cycleWay.addTag("access", "no");
 							cycleWay.addTag("bicycle", "yes");
+							cycleWay.addTag("foot", "no");
 							log.info("Making opposite cycleway '" + cycleWay.getTag("name") + "'");
 						}
 					}
+					if(makeCyclewayTracks &&
+					   !"cycleway".equals(highway) &&
+					   "track".equals(currentWay.getTag("cycleway"))) {
+						// what we have here is a highway with a
+						// separate track for cycles -- to enable
+						// bicyle routing, we synthesise a cycleway
+						// that has the same points as the original
+						// way
+						long cycleWayId = currentWay.getId() + CYCLEWAY_ID_OFFSET;
+						Way cycleWay = new Way(cycleWayId);
+						wayMap.put(cycleWayId, cycleWay);
+						List<Coord> points = currentWay.getPoints();
+						for(int i = 0; i < points.size(); ++i)
+							cycleWay.addPoint(points.get(i));
+						cycleWay.copyTags(currentWay);
+						cycleWay.addTag("highway", "cycleway");
+						String name = currentWay.getTag("name");
+						if(name != null)
+							name += " (cycleway)";
+						else
+							name = "cycleway";
+						cycleWay.addTag("name", name);
+						cycleWay.addTag("access", "no");
+						cycleWay.addTag("bicycle", "yes");
+						cycleWay.addTag("foot", "no");
+						log.info("Making cycleway track '" + cycleWay.getTag("name") + "'");
+					}
 				}
 				if("motorway".equals(highway) ||
 				   "trunk".equals(highway))
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to