On Tue, Oct 19, 2010 at 09:11:31PM +0100, Steve Ratcliffe wrote:
How could this check be reinstated in the refactored parser, for both
XML and PBF? This code should be easy to find in the old XML-only OSM
parser: just look for currentWayStartsWithFIXME in Osm5XmlHandler.java.
I hoped no one would miss it ;)
I couldn't see an easy way of doing it, which is why it was omitted.
I'm sure it is possible though.
It is possible with a small addition to the hook interface. I tested the
attached patch with XML input. I hope it uses the correct tab width for
indentation.
I tried to test with pbf input by converting one of my input tiles with
Osmosis from splitter's osm.gz to osm.pbf. Unfortunately, splitter
generates OSM XML 0.5, and Osmosis no longer supports --read-xml-0.5.
In the end, I downloaded a small area with JOSM and converted that one
to osm.pbf, before and after removing the fixme attribute from an end
node.
Marko
Index: src/uk/me/parabola/mkgmap/reader/osm/OsmReadingHooksChain.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/OsmReadingHooksChain.java (revision 1716)
+++ src/uk/me/parabola/mkgmap/reader/osm/OsmReadingHooksChain.java (working copy)
@@ -59,9 +59,9 @@ public class OsmReadingHooksChain implem
readingHooks[i].onCoordAddedToWay(way, coordId, co);
}
- public void onAddWay(Way way) {
+ public void onAddWay(Way way, Node lastNode) {
for (int i = 0; i < readingHooks.length; i++)
- readingHooks[i].onAddWay(way);
+ readingHooks[i].onAddWay(way, lastNode);
}
public void end() {
Index: src/uk/me/parabola/mkgmap/reader/osm/HighwayHooks.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/HighwayHooks.java (revision 1716)
+++ src/uk/me/parabola/mkgmap/reader/osm/HighwayHooks.java (working copy)
@@ -110,25 +110,25 @@ public class HighwayHooks extends OsmRea
}
}
- // See if the first Node of the Way has a FIXME attribute
- if (way.getPoints().isEmpty()) {
- boolean currentWayStartsWithFIXME = (currentNodeInWay != null &&
- (currentNodeInWay.getTag("FIXME") != null ||
- currentNodeInWay.getTag("fixme") != null));
- }
+ // if the first Node of the Way has a FIXME attribute,
+ // disable dead-end-check for oneways
+ if (currentNodeInWay != null &&
+ way.getPoints().isEmpty() &&
+ (currentNodeInWay.getTag("FIXME") != null ||
+ currentNodeInWay.getTag("fixme") != null))
+ way.addTag("mkgmap:dead-end-check", "false");
}
- public void onAddWay(Way way) {
+ public void onAddWay(Way way, Node lastNode) {
String highway = way.getTag("highway");
if (highway != null || "ferry".equals(way.getTag("route"))) {
boolean oneway = way.isBoolTag("oneway");
- // if the first or last Node of the Way has a
- // FIXME attribute, disable dead-end-check for
- // oneways
- //if (oneway && currentWayStartsWithFIXME ||
- // (currentNodeInWay != null && (currentNodeInWay.getTag("FIXME") != null || currentNodeInWay.getTag("fixme") != null))) {
- // way.addTag("mkgmap:dead-end-check", "false");
- //}
+ // if the last Node of the Way has a FIXME attribute,
+ // disable dead-end-check for oneways
+ if (oneway && lastNode != null &&
+ (lastNode.getTag("FIXME") != null ||
+ lastNode.getTag("fixme") != null))
+ way.addTag("mkgmap:dead-end-check", "false");
// if the way is a roundabout but isn't already
// flagged as "oneway", flag it here
Index: src/uk/me/parabola/mkgmap/reader/osm/OsmReadingHooksAdaptor.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/OsmReadingHooksAdaptor.java (revision 1716)
+++ src/uk/me/parabola/mkgmap/reader/osm/OsmReadingHooksAdaptor.java (working copy)
@@ -30,7 +30,7 @@ public class OsmReadingHooksAdaptor impl
public void onAddNode(Node node) {
}
- public void onAddWay(Way way) {
+ public void onAddWay(Way way, Node lastNode) {
}
public void onCoordAddedToWay(Way way, long coordId, Coord co) {
Index: src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (revision 1716)
+++ src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (working copy)
@@ -58,6 +58,7 @@ public class Osm5XmlHandler extends OsmH
// Current state.
private Node currentNode;
private Way currentWay;
+ private Node currentNodeInWay;
private Relation currentRelation;
private long currentElementId;
@@ -164,8 +165,9 @@ public class Osm5XmlHandler extends OsmH
if (qName.equals("way")) {
mode = 0;
saver.addWay(currentWay);
- hooks.onAddWay(currentWay);
+ hooks.onAddWay(currentWay, currentNodeInWay);
currentWay = null;
+ currentNodeInWay = null;
}
} else if (mode == MODE_BOUND) {
@@ -367,6 +369,7 @@ public class Osm5XmlHandler extends OsmH
Coord co = saver.getCoord(id);
if (co != null) {
+ currentNodeInWay = saver.getNode(id);
hooks.onCoordAddedToWay(currentWay, id, co);
co = saver.getCoord(id);
currentWay.addPoint(co);
Index: src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java (revision 1716)
+++ src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java (working copy)
@@ -135,10 +135,12 @@ public class OsmBinHandler extends OsmHa
}
long nid = 0;
+ Node lastNode = null;
for (long idDelta : binWay.getRefsList()) {
nid += idDelta;
Coord co = saver.getCoord(nid);
if (co != null) {
+ lastNode = saver.getNode(nid);
hooks.onCoordAddedToWay(way, nid, co);
way.addPoint(co);
@@ -150,7 +152,7 @@ public class OsmBinHandler extends OsmHa
}
saver.addWay(way);
- hooks.onAddWay(way);
+ hooks.onAddWay(way, lastNode);
}
}
Index: src/uk/me/parabola/mkgmap/reader/osm/OsmReadingHooks.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/OsmReadingHooks.java (revision 1716)
+++ src/uk/me/parabola/mkgmap/reader/osm/OsmReadingHooks.java (working copy)
@@ -65,8 +65,10 @@ public interface OsmReadingHooks {
* is seen for the XML format.
*
* @param way The osm way.
+ * @param lastNode The Node of the last point of the way
+ * (null if it is a Coord, not a Node)
*/
- public void onAddWay(Way way);
+ public void onAddWay(Way way, Node lastNode);
/**
* This is called whenever a node is added to a way. A node is something with tags, not just a Coord.
Index: resources/styles/default/lines
===================================================================
--- resources/styles/default/lines (revision 1716)
+++ resources/styles/default/lines (working copy)
@@ -25,6 +25,13 @@ contour=elevation | contour_ext=elevatio
{ name '${ele|conv:m=>ft}'; }
[0x21 resolution 20]
+# Hide unaccessible tunnels
+highway=* & tunnel=yes & (access=private|access=no)
+& !(foot=yes) & !(bicycle=yes) {delete highway;delete junction}
+# Disable dead-end-checks for unaccessible oneways
+highway=* & oneway=yes & (access=private|access=no)
+{add mkgmap:dead-end-check=false}
+
# Set highway names to include the reference if there is one
highway=motorway {name '${ref|highway-symbol:hbox} ${name}' | '${ref|highway-symbol:hbox}' | '${name}' }
highway=trunk {name '${ref|highway-symbol:hbox} ${name}' | '${ref|highway-symbol:hbox}' | '${name}'; add display_name = '${name} (${ref})' }
@@ -105,11 +112,11 @@ natural=coastline [0x15 resolution 12]
power=line [0x29 resolution 20]
railway=abandoned [0x0a road_class=0 road_speed=1 resolution 21]
-railway=light_rail & !(layer<0) [0x14 resolution 17]
-railway=narrow_gauge & !(layer<0) [0x14 resolution 17]
-railway=rail & !(layer<0) [0x14 resolution 17]
-railway=subway & !(layer<0) [0x14 resolution 17]
-railway=tram & !(layer<0) [0x14 resolution 18]
+railway=light_rail & !(tunnel=yes) [0x14 resolution 17]
+railway=narrow_gauge & !(tunnel=yes) [0x14 resolution 17]
+railway=rail & !(tunnel=yes) [0x14 resolution 17]
+railway=subway & !(tunnel=yes) [0x14 resolution 17]
+railway=tram & !(tunnel=yes) [0x14 resolution 18]
railway=platform {add access = no; add foot = yes} [0x16 road_class=0 road_speed=0 resolution 23]
route=ferry {add mkgmap:ferry=1} [0x1b road_class=3 road_speed=0 resolution 18]
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev