Am 03.03.2011 21:54, schrieb Johann Gail:
Okay I've done some comparisons between the two approximations.
For polygons the old version is much better because the patched version
creates bad artifacts. For streets at resolution 23 (if used) to 21 I
prefer it too. At resolution 20 I am indifferent and cannot really
decide what is better. However from 19 to x the  approach as given by
the patch is far superior (drawing speed on GPS much higher, actually
using the normal DP filter maps become more or less unusable for
resolution 16,18 or 19 on etrex).

Can someone see how this behaviour could be implemented for lines only
from resolution 20 or 19 downwards, while keeping the current approach
of the DP filter for the rest?

Thanks for intensively testing my old patches and the propose for them
being checked in.
Glad to see them work fine and beeing useful. :-)

I have looked at this patch again. I think your proposal of switching
between them at a given resolution is a good one. This should preserve
the accuracy at higher zooms and compress the data at lower zooms.
Should be worth a try.

I'm sorry, but at the moment I have no toolchain ready for compiling
mkgmap and preparing patches. If I find the time, I will look into it
the next days.

Okay great. Hope it's not too difficult to change the behaviour to get
the best of both. I think actually at resolution 20, the "straight"
patched behaviour should already be used for all lines.
Here is a patch which enables the straightening only at resolution level 20 and below. This is for testing purposes only! :-) Before checking it in, it needs a option to set the resolution at which this behaviour changes. I expect, not all people at the list will find it their taste matched... ;-)

Regards,
Johann
To tired to remember attaching the patch....

Index: src/uk/me/parabola/mkgmap/filters/DouglasPeuckerFilter.java
===================================================================
--- src/uk/me/parabola/mkgmap/filters/DouglasPeuckerFilter.java	(Revision 1878)
+++ src/uk/me/parabola/mkgmap/filters/DouglasPeuckerFilter.java	(Arbeitskopie)
@@ -29,6 +29,12 @@
 
 	//private static final double ERROR_DISTANCE = 5.4 / 2;	//One unit is 5.4 m, so error dist is 2.6m
 															//Can be increased more, but may lead to artifacts on T-crossings
+	
+	//Above this resolution the nodes of crossings are not touched. 
+	//Below the lines are straightened out more.
+	private static int PRESERVE_NODES_ABOVE_RESOLUTION = 20;
+	
+	private boolean preserveNodes;
 	private final double filterDistance;
 	private double maxErrorDistance;
 	private int resolution;
@@ -40,6 +46,7 @@
 	public void init(FilterConfig config) {
 		this.resolution = config.getResolution();
 		this.maxErrorDistance = filterDistance * (1<< config.getShift());
+		this.preserveNodes = (resolution > PRESERVE_NODES_ABOVE_RESOLUTION);
 	}
 
 	/**
@@ -65,35 +72,38 @@
 		List<Coord> coords = new ArrayList<Coord>(points.size());
 		coords.addAll(points);
 
-//#if (Node version)
-//Don't touch Coords, which are nodes.
-//So points at crossings will not be moved
-		// For now simplify all points, which are not nodes
-		// and no start and no end point
-		// Loop runs downwards, as the list length gets modified while running
-		int endIndex = coords.size()-1;
-		for(int i = endIndex-1; i > 0; i--) {
-			Coord p = coords.get(i);
-			//int highwayCount = p.getHighwayCount();
-			
-			// 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.preserved()) {
-				// point is "preserved", don't remove it
-				douglasPeucker(coords, i, endIndex, maxErrorDistance);
-				endIndex = i;
+		//#if (Node version)
+		//Don't touch Coords, which are nodes.
+		//So points at crossings will not be moved
+		if (preserveNodes)
+		{
+			// For now simplify all points, which are not nodes
+			// and no start and no end point
+			// Loop runs downwards, as the list length gets modified while running
+			int endIndex = coords.size()-1;
+			for(int i = endIndex-1; i > 0; i--) {
+				Coord p = coords.get(i);
+				//int highwayCount = p.getHighwayCount();
+				
+				// 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.preserved()) {
+					// point is "preserved", don't remove it
+					douglasPeucker(coords, i, endIndex, maxErrorDistance);
+					endIndex = i;
+				}
 			}
+			// Simplify the rest
+			douglasPeucker(coords, 0, endIndex, maxErrorDistance);
 		}
-		// Simplify the rest
-		douglasPeucker(coords, 0, endIndex, maxErrorDistance);
-
-//#else Straight version
-//Do the douglasPeucker on the whole line. 
-//Deletes more points, but may lead to incorrect display of crossings at given high error distances
-/*		
-		douglasPeucker(coords, 0, n, maxErrorDistance);
-	*/	
-//#endif
+		else
+		//#else Straight version
+		//Do the douglasPeucker on the whole line. 
+		//Deletes more points, but may lead to incorrect display of crossings at given high error distances
+		{
+			int endIndex = coords.size()-1;
+			douglasPeucker(coords, 0, endIndex, maxErrorDistance);
+		}
 		MapLine newline = line.copy();
 
 		newline.setPoints(coords);
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to