v4 - err, try again
---------
v3 - hopefully, now works again after being broken by the round coords
filter.
---------
v2 - based on r1402.
-----------
Hi Felix,
Please try the attached patch. I've tested it inasmuch that it doesn't
blow up but whether it actually does the right thing when you have a
routable and non-routable way from the same set of points, I don't know.
Cheers,
Mark
diff --git a/src/uk/me/parabola/imgfmt/app/Coord.java b/src/uk/me/parabola/imgfmt/app/Coord.java
index 335284d..6eecf2e 100644
--- a/src/uk/me/parabola/imgfmt/app/Coord.java
+++ b/src/uk/me/parabola/imgfmt/app/Coord.java
@@ -39,6 +39,7 @@ public class Coord implements Comparable<Coord> {
private final int longitude;
private byte highwayCount; // number of highways that use this point
private boolean onBoundary; // true if point lies on a boundary
+ private boolean fixed; // true if point should not be filtered out
/**
* Construct from co-ordinates that are already in map-units.
@@ -90,6 +91,14 @@ public class Coord implements Comparable<Coord> {
this.onBoundary = onBoundary;
}
+ public boolean fixed() {
+ return fixed;
+ }
+
+ public void fixed(boolean fixed) {
+ this.fixed = fixed;
+ }
+
public int hashCode() {
return latitude+longitude;
}
diff --git a/src/uk/me/parabola/imgfmt/app/CoordNode.java b/src/uk/me/parabola/imgfmt/app/CoordNode.java
index ebcfd58..fa90993 100644
--- a/src/uk/me/parabola/imgfmt/app/CoordNode.java
+++ b/src/uk/me/parabola/imgfmt/app/CoordNode.java
@@ -24,8 +24,6 @@ package uk.me.parabola.imgfmt.app;
*/
public class CoordNode extends Coord {
private final long id;
- //private int roadCount;
- private final boolean boundary;
/**
* Construct from co-ordinates that are already in map-units.
@@ -38,14 +36,11 @@ public class CoordNode extends Coord {
public CoordNode(int latitude, int longitude, long id, boolean boundary) {
super(latitude, longitude);
this.id = id;
- this.boundary = boundary;
+ setOnBoundary(boundary);
+ fixed(true);
}
public long getId() {
return id;
}
-
- public boolean isBoundary() {
- return boundary;
- }
}
diff --git a/src/uk/me/parabola/imgfmt/app/net/RouteNode.java b/src/uk/me/parabola/imgfmt/app/net/RouteNode.java
index b8ffdcc..4ea1e03 100644
--- a/src/uk/me/parabola/imgfmt/app/net/RouteNode.java
+++ b/src/uk/me/parabola/imgfmt/app/net/RouteNode.java
@@ -80,7 +80,7 @@ public class RouteNode implements Comparable<RouteNode> {
public RouteNode(Coord coord) {
this.coord = (CoordNode) coord;
nodeId = nodeCount++; // XXX: take coord.getId() instead?
- setBoundary(this.coord.isBoundary());
+ setBoundary(this.coord.getOnBoundary());
}
private boolean haveLargeOffsets() {
diff --git a/src/uk/me/parabola/mkgmap/filters/DouglasPeuckerFilter.java b/src/uk/me/parabola/mkgmap/filters/DouglasPeuckerFilter.java
index 9a9c141..465a229 100644
--- a/src/uk/me/parabola/mkgmap/filters/DouglasPeuckerFilter.java
+++ b/src/uk/me/parabola/mkgmap/filters/DouglasPeuckerFilter.java
@@ -79,7 +79,8 @@ public class DouglasPeuckerFilter implements MapFilter {
// If a node in the line use the douglas peucker algorithm for upper segment
// TODO: Should consider only nodes connected to roads visible at current resolution.
- if (p instanceof CoordNode) {
+ if (p.fixed()) {
+ // point is "fixed", don't remove it
douglasPeucker(coords, i, endIndex, maxErrorDistance);
endIndex = i;
}
diff --git a/src/uk/me/parabola/mkgmap/filters/RoundCoordsFilter.java b/src/uk/me/parabola/mkgmap/filters/RoundCoordsFilter.java
index 2cdb95b..90780b6 100644
--- a/src/uk/me/parabola/mkgmap/filters/RoundCoordsFilter.java
+++ b/src/uk/me/parabola/mkgmap/filters/RoundCoordsFilter.java
@@ -53,9 +53,11 @@ public class RoundCoordsFilter implements MapFilter {
int lon = (p.getLongitude() + half) & mask;
Coord newP;
if(p instanceof CoordNode)
- newP = new CoordNode(lat, lon, ((CoordNode)p).getId(), ((CoordNode)p).isBoundary());
+ newP = new CoordNode(lat, lon, ((CoordNode)p).getId(), p.getOnBoundary());
else
newP = new Coord(lat, lon);
+ newP.fixed(p.fixed());
+
// only add the new point if it has different
// coordinates to the last point or if it's a
// CoordNode and the last point wasn't a CoordNode
@@ -65,6 +67,14 @@ public class RoundCoordsFilter implements MapFilter {
newPoints.add(newP);
lastP = newP;
}
+ else if(newP.fixed()) {
+ // this point is not going to be used because it
+ // has the same (rounded) coordinates as the last
+ // node but it has been marked as being "fixed" -
+ // transfer that property to the previous point so
+ // that it's not lost
+ lastP.fixed(true);
+ }
}
if(newPoints.size() > 1) {
newLine.setPoints(newPoints);
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 549b1bf..3a5c794 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
@@ -741,6 +741,9 @@ class Osm5XmlHandler extends DefaultHandler {
// this point is a node if it has an arc count
Integer arcCount = arcCounts.get(p);
if (arcCount != null) {
+ // make the point "fixed" so that it won't
+ // get filtered out later
+ p.fixed(true);
// merge this node to previous node if the
// two points have identical coordinates
// or are closer than the minimum distance
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev