Hello,
After playing around with restrictions I found how to enable exception
for pedestrian and emergency vehicles. The attached patch does just that.
Now the subsidiary question: by default pedestrian routing follows
restrictions. Should we make this the other way. But then is there a
restriction type to enforce turn restrictions for pedestrians? An
intermediate solution could be a command line option.
BTW does anybody have a concrete example of pedestrian turn restriction?
Thanks,
N.
Index: uk/me/parabola/imgfmt/app/net/RouteRestriction.java
===================================================================
--- uk/me/parabola/imgfmt/app/net/RouteRestriction.java (revision 1647)
+++ uk/me/parabola/imgfmt/app/net/RouteRestriction.java (working copy)
@@ -37,10 +37,22 @@
// size in bytes
private static final int SIZE = 11;
- // first three bytes of the header -- might specify the type of
restriction
+ // first bytes of the header -- might specify the type of restriction
// and when it is active
- private static final int HEADER = 0x004005;
+ private static final int HEADER = 0x05;
+
+ // flags for the second byte
+ private byte flagByte;
+ public final static byte FLAG_PEDESTRIAN = 0x02;
+ public final static byte FLAG_EMERGENCY = 0x04;
+ public final static byte FLAG_EXCEPT_OTHER = 0x08;
+ public final static byte BASE_FLAG = 0x40;
+
+ // third byte (always 0?)
+ public final static byte THIRD_BYTE = 0x00;
+
+
// To specifiy that a node is given by a relative offset instead
// of an entry to Table B.
private static final int F_INTERNAL = 0x8000;
@@ -57,14 +69,18 @@
private boolean last;
// mask that specifies which vehicle types the restriction doesn't
apply to
- private final byte exceptMask;
+ private final int exceptMask;
- public final static byte EXCEPT_CAR = 0x01;
- public final static byte EXCEPT_BUS = 0x02;
- public final static byte EXCEPT_TAXI = 0x04;
- public final static byte EXCEPT_DELIVERY = 0x10;
- public final static byte EXCEPT_BICYCLE = 0x20;
- public final static byte EXCEPT_TRUCK = 0x40;
+ public final static int EXCEPT_CAR = 0x0001;
+ public final static int EXCEPT_BUS = 0x0002;
+ public final static int EXCEPT_TAXI = 0x0004;
+ public final static int EXCEPT_DELIVERY = 0x0010;
+ public final static int EXCEPT_BICYCLE = 0x0020;
+ public final static int EXCEPT_TRUCK = 0x0040;
+ public final static int EXCEPT_PEDESTRIAN = 0x0100;
+ public final static int EXCEPT_EMERGENCY = 0x0200;
+
+
/**
* Create a route restriction.
@@ -72,11 +88,12 @@
* @param from The inverse arc of "from" arc.
* @param to The "to" arc.
*/
- public RouteRestriction(RouteArc from, RouteArc to, byte exceptMask) {
+ public RouteRestriction(RouteArc from, RouteArc to, int exceptMask) {
assert from.getSource().equals(to.getSource()) : "arcs in
restriction don't meet";
this.from = from;
this.to = to;
this.exceptMask = exceptMask;
+ this.flagByte = BASE_FLAG;
}
private int calcOffset(RouteNode node, int tableOffset) {
@@ -93,16 +110,23 @@
* @param tableOffset The offset in NOD 1 of the tables area.
*/
public void write(ImgFileWriter writer, int tableOffset) {
- int header = HEADER;
+ byte header = HEADER;
- if(exceptMask != 0)
- header |= 0x0800;
+ writer.put(header);
+ if( (exceptMask & 0xFF) != 0)
+ flagByte |= FLAG_EXCEPT_OTHER;
+ if( (exceptMask & EXCEPT_PEDESTRIAN) != 0)
+ flagByte |= FLAG_PEDESTRIAN;
+ if( (exceptMask & EXCEPT_EMERGENCY) != 0)
+ flagByte |= FLAG_EMERGENCY;
- writer.put3(header);
+ writer.put(flagByte);
- if(exceptMask != 0)
- writer.put(exceptMask);
+ writer.put(THIRD_BYTE);
+ if((exceptMask & 0xFF) != 0)
+ writer.put((byte)exceptMask);
+
int[] offsets = new int[3];
if (from.isInternal())
Index: uk/me/parabola/mkgmap/general/MapCollector.java
===================================================================
--- uk/me/parabola/mkgmap/general/MapCollector.java (revision 1647)
+++ uk/me/parabola/mkgmap/general/MapCollector.java (working copy)
@@ -72,7 +72,7 @@
* no left turn.
* @param exceptMask For exceptions eg. no-left-turn except for buses.
*/
- public void addRestriction(CoordNode fromNode, CoordNode toNode,
CoordNode viaNode, byte exceptMask);
+ public void addRestriction(CoordNode fromNode, CoordNode toNode,
CoordNode viaNode, int exceptMask);
/**
* Add a through route to the map.
Index: uk/me/parabola/mkgmap/general/MapDetails.java
===================================================================
--- uk/me/parabola/mkgmap/general/MapDetails.java (revision 1647)
+++ uk/me/parabola/mkgmap/general/MapDetails.java (working copy)
@@ -115,7 +115,7 @@
addLine(road);
}
- public void addRestriction(CoordNode fromNode, CoordNode toNode,
CoordNode viaNode, byte exceptMask) {
+ public void addRestriction(CoordNode fromNode, CoordNode toNode,
CoordNode viaNode, int exceptMask) {
roadNetwork.addRestriction(fromNode, toNode, viaNode,
exceptMask);
}
Index: uk/me/parabola/mkgmap/general/RoadNetwork.java
===================================================================
--- uk/me/parabola/mkgmap/general/RoadNetwork.java (revision 1647)
+++ uk/me/parabola/mkgmap/general/RoadNetwork.java (working copy)
@@ -264,7 +264,7 @@
return boundary;
}
- public void addRestriction(CoordNode fromNode, CoordNode toNode,
CoordNode viaNode, byte exceptMask) {
+ public void addRestriction(CoordNode fromNode, CoordNode toNode,
CoordNode viaNode, int exceptMask) {
RouteNode fn = nodes.get(fromNode.getId());
RouteNode tn = nodes.get(toNode.getId());
RouteNode vn = nodes.get(viaNode.getId());
Index: uk/me/parabola/mkgmap/main/StyleTester.java
===================================================================
--- uk/me/parabola/mkgmap/main/StyleTester.java (revision 1647)
+++ uk/me/parabola/mkgmap/main/StyleTester.java (working copy)
@@ -716,7 +716,7 @@
lines.add(road);
}
- public void addRestriction(CoordNode fromNode, CoordNode
toNode, CoordNode viaNode, byte exceptMask) {
+ public void addRestriction(CoordNode fromNode, CoordNode
toNode, CoordNode viaNode, int exceptMask) {
}
public void addThroughRoute(long junctionNodeId, long roadIdA,
long roadIdB) {
@@ -758,7 +758,7 @@
}
}
- public void addRestriction(CoordNode fromNode, CoordNode
toNode, CoordNode viaNode, byte exceptMask) {
+ public void addRestriction(CoordNode fromNode, CoordNode
toNode, CoordNode viaNode, int exceptMask) {
}
public void addThroughRoute(long junctionNodeId, long roadIdA,
long roadIdB) {
Index: uk/me/parabola/mkgmap/reader/osm/RestrictionRelation.java
===================================================================
--- uk/me/parabola/mkgmap/reader/osm/RestrictionRelation.java (revision 1647)
+++ uk/me/parabola/mkgmap/reader/osm/RestrictionRelation.java (working copy)
@@ -31,7 +31,7 @@
private CoordNode toNode;
private CoordNode viaNode;
private final List<CoordNode> otherNodes = new ArrayList<CoordNode>();
- private byte exceptMask;
+ private int exceptMask;
private String messagePrefix;
/**
@@ -148,6 +148,10 @@
exceptMask |=
RouteRestriction.EXCEPT_BICYCLE;
else if(e.equals("hgv") || e.equals("truck"))
exceptMask |=
RouteRestriction.EXCEPT_TRUCK;
+ else if(e.equals("emergency"))
+ exceptMask |=
RouteRestriction.EXCEPT_EMERGENCY;
+ else if(e.equals("pedestrian"))
+ exceptMask |=
RouteRestriction.EXCEPT_PEDESTRIAN;
else
log.warn(messagePrefix + "ignoring
unsupported vehicle class '" + e + "' in turn restriction exception");
}
Index: uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java
===================================================================
--- uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java
(revision 1647)
+++ uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java
(working copy)
@@ -140,7 +140,7 @@
addLine(road);
}
- public void addRestriction(CoordNode fromNode, CoordNode toNode,
CoordNode viaNode, byte exceptMask) {
+ public void addRestriction(CoordNode fromNode, CoordNode toNode,
CoordNode viaNode, int exceptMask) {
getRoadNetwork().addRestriction(fromNode, toNode, viaNode,
exceptMask);
}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev