Support larger Table B sizes.
Until now, we have limited Table B to less than 0x40 entries but by using
an extra byte to hold the Table B index in RouteArc objects, the number of
entries can be increased up to a new limit of 0x100.
Just discovered that Table B can actually be larger than we have been
using. Table B overflow is one of the criteria for dividing a route
centre so by allowing them to be larger, it should reduce the number of
route centre splits. Having said that, on the GB map data, only a few
Table B's grew larger than the previous limit so I think the benefit is
probably marginal. Still, for complex city regions it could make a
difference. I have verified that for the GB map, those roads that
cause a Table B to be larger than the previous limit are routable as
normal. Anyway, please test if you can and as long as it doesn't
introduce any problems it's worth incorporating this.
Mark
diff --git a/src/uk/me/parabola/imgfmt/app/net/NOD1Part.java b/src/uk/me/parabola/imgfmt/app/net/NOD1Part.java
index 4566dbc..5f3bc07 100644
--- a/src/uk/me/parabola/imgfmt/app/net/NOD1Part.java
+++ b/src/uk/me/parabola/imgfmt/app/net/NOD1Part.java
@@ -65,18 +65,15 @@ public class NOD1Part {
// maximal width and height of the bounding box, since
// NOD 1 coordinate offsets are at most 16 bit wide.
private static final int MAX_SIZE_UNSAFE = 1 << 16;
-// private static final int MAX_SIZE = MAX_SIZE_UNSAFE / 2;
private static final int MAX_SIZE = MAX_SIZE_UNSAFE - 0x800;
// Table A has at most 0x100 entries
private static final int MAX_TABA_UNSAFE = 0x100;
-// private static final int MAX_TABA = MAX_TABA_UNSAFE / 2;
private static final int MAX_TABA = MAX_TABA_UNSAFE - 0x8;
- // Table B has at most 0x40 entries
- private static final int MAX_TABB_UNSAFE = 0x40;
-// private static final int MAX_TABB = MAX_TABB_UNSAFE / 2;
- private static final int MAX_TABB = MAX_TABB_UNSAFE - 0x2;
+ // Table B has at most 0x100 entries
+ private static final int MAX_TABB_UNSAFE = 0x100;
+ private static final int MAX_TABB = MAX_TABB_UNSAFE - 0x8;
// Nodes size is max 0x2000 to cope with signed 14 bit node offsets
private static final int MAX_NODES_SIZE = 0x2000;
diff --git a/src/uk/me/parabola/imgfmt/app/net/RouteArc.java b/src/uk/me/parabola/imgfmt/app/net/RouteArc.java
index 26d3a64..83d02b0 100644
--- a/src/uk/me/parabola/imgfmt/app/net/RouteArc.java
+++ b/src/uk/me/parabola/imgfmt/app/net/RouteArc.java
@@ -212,7 +212,13 @@ public class RouteArc {
writer.put(flagB);
writer.put((byte) 0);
} else {
- writer.put((byte) (flagB | indexB));
+ if(indexB < 0x3f)
+ writer.put((byte) (flagB | indexB));
+ else {
+ log.info("Way " + getRoadDef() + " has indexB value of " + indexB);
+ writer.put((byte) (flagB | 0x3f));
+ writer.put(indexB);
+ }
}
writer.put(indexA);
diff --git a/src/uk/me/parabola/imgfmt/app/net/TableB.java b/src/uk/me/parabola/imgfmt/app/net/TableB.java
index bdc09ac..9b777f1 100644
--- a/src/uk/me/parabola/imgfmt/app/net/TableB.java
+++ b/src/uk/me/parabola/imgfmt/app/net/TableB.java
@@ -52,7 +52,7 @@ public class TableB {
* it isn't too large.
*/
public byte getNumberOfItems() {
- assert nodes.size() < 0x40 : "Table B too large.";
+ assert nodes.size() < 0x100 : "Table B too large.";
return (byte) nodes.size();
}
@@ -76,7 +76,7 @@ public class TableB {
public byte getIndex(RouteNode node) {
int i = nodes.indexOf(node);
assert i >= 0 : "Trying to read Table B index for non-registered node.";
- assert i < 0x40 : "Table B index too large.";
+ assert i < 0x100 : "Table B index too large.";
return (byte) i;
}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev