logo separator

[mkgmap-dev] Putting the DP code under the microscope

From Johann Gail johann.gail at gmx.de on Wed Jun 17 19:46:45 BST 2009

> What are your thoughts on the patch (I think it was by Thilo) that
> replaces the lost last point in each polygon? Seems like a good idea to
> me.
>
>   
I have looked at the patch only one minute. Seems correct.
May thoughts was that the last segment ist not needed, if it is a 
polygon which gets filled. But with only contours there will arise 
problems. Right.

In my private working copy I have tested another solution in the meanwhile.

Do not remove the first point. Instead divide the line in two parts and 
simplify both of them. Could not say if it works better or not.

Sorry, I'm in a hurry,  no more time left to create a patch.



        // Create a new list to rewrite the points into. Don't alter the 
original one
        List<Coord> coords = new ArrayList<Coord>(n);
        coords.addAll(points);

        //Handle Polygons different
+        if (element instanceof MapShape) {
+           int middle = n/2;
+           douglasPeucker(coords, middle, n, maxErrorDistance);
+            douglasPeucker(coords, 0, middle, maxErrorDistance);
+
+        }
+        else
        {
            // 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--) {



Regards,
Johann



More information about the mkgmap-dev mailing list