v3
renamed option for enabling this to --make-cycleways
added --make-all-cycleways option to turn on all cycleway synthesising
options
Now removes bicycle access from the original way (unless that way has a
"bicycle" tag) to force the routing to use the cycleway.
BTW - this may be a complete red herring but mapsource was not showing
me the cycleway names like "Foo (cycleway)" it was only showing the
original road name "Foo". I then rebuilt the map without the
--lower-case option and the cycleway names started appearing. So, either
mapsource was just being its usual weird self or there is some badness
related to using --lower-case. Just thought I would mention it!
---------------------
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..3afd3b4 100644
--- a/resources/help/en/options
+++ b/resources/help/en/options
@@ -163,11 +163,21 @@ Misc options:
style is applied and only for polygon types that have a
reasonable point equivalent.
+--make-all-cycleways
+ Turn on all of the options that make cycleways.
+
--make-opposite-cycleways
Some oneway streets allow bicycle traffic in the reverse
direction and this option makes a way with the same points as
the original that allows bicycle traffic (in both directions).
+--make-cycleways
+ Some streets have a separate cycleway track/lane just for
+ bicycle traffic and this option makes a way with the same
+ points as the original that allows bicycle traffic and, also,
+ prohibits that traffic from the original way (unless the way
+ is tagged bicycle=yes).
+
--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..81c5a8e 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 makeCycleways;
private final boolean ignoreBounds;
private final boolean ignoreTurnRestrictions;
private final boolean linkPOIsToWays;
@@ -95,7 +96,13 @@ class Osm5XmlHandler extends DefaultHandler {
private final String frigRoundabouts;
public Osm5XmlHandler(EnhancedProperties props) {
- makeOppositeCycleways = props.getProperty("make-opposite-cycleways", false);
+ if(props.getProperty("make-all-cycleways", false)) {
+ makeOppositeCycleways = makeCycleways = true;
+ }
+ else {
+ makeOppositeCycleways = props.getProperty("make-opposite-cycleways", false);
+ makeCycleways = props.getProperty("make-cycleways", false);
+ }
linkPOIsToWays = props.getProperty("link-pois-to-ways", false);
ignoreBounds = props.getProperty("ignore-osm-bounds", false);
routing = props.containsKey("route");
@@ -293,33 +300,76 @@ 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(makeCycleways &&
+ 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);
+ if(currentWay.getTag("bicycle") == null)
+ currentWay.addTag("bicycle", "no");
+ //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
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev