v2 - Now matches extra tags (lane, left, right, both).

Commented out setting of highway=cycleway until it's agreed that it's a
good idea.

---------------------

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..3b90407 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,33 +295,74 @@ class Osm5XmlHandler extends DefaultHandler {
 								currentWay.addTag("mkgmap:frig_roundabout", frigRoundabouts);
 						}
 					}
-					if(makeOppositeCycleways && currentWay.isBoolTag("oneway")) {
-						String cyclewayTag = currentWay.getTag("cycleway");
-						if("opposite".equals(cyclewayTag) ||
-						   "opposite_lane".equals(cyclewayTag) ||
-						   "opposite_track".equals(cyclewayTag)) {
-							// what we have here is a oneway street
-							// that allows bicycle traffic in both
-							// directions -- to enable bicyle routing
-							// in the reverse direction, 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);
-							// this reverses the direction of the way
-							// but that isn't really necessary as the
-							// cycleway isn't tagged as oneway
-							List<Coord> points = currentWay.getPoints();
-							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("oneway", "no");
-							cycleWay.addTag("access", "no");
-							cycleWay.addTag("bicycle", "yes");
-							log.info("Making opposite cycleway '" + cycleWay.getTag("name") + "'");
-						}
+					String cycleway = currentWay.getTag("cycleway");
+					if(makeOppositeCycleways &&
+					   cycleway != null &&
+					   !"cycleway".equals(highway) &&
+					   currentWay.isBoolTag("oneway") &&
+					   ("opposite".equals(cycleway) ||
+						"opposite_lane".equals(cycleway) ||
+						"opposite_track".equals(cycleway))) {
+						// what we have here is a oneway street
+						// that allows bicycle traffic in both
+						// directions -- to enable bicyle routing
+						// in the reverse direction, 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);
+						// this reverses the direction of the way but
+						// that isn't really necessary as the cycleway
+						// isn't tagged as oneway
+						List<Coord> points = currentWay.getPoints();
+						for(int i = points.size() - 1; i >= 0; --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("oneway", "no");
+						cycleWay.addTag("access", "no");
+						cycleWay.addTag("bicycle", "yes");
+						cycleWay.addTag("foot", "no");
+						log.info("Making " + cycleway + " cycleway '" + cycleWay.getTag("name") + "'");
+					}
+					else if(makeCyclewayTracks &&
+							cycleway != null &&
+							!"cycleway".equals(highway) &&
+							("track".equals(cycleway) ||
+							 "lane".equals(cycleway) ||
+							 "both".equals(cycleway) ||
+							 "left".equals(cycleway) ||
+							 "right".equals(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 + " cycleway '" + cycleWay.getTag("name") + "'");
 					}
 				}
 				if("motorway".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