Subject: [ggl] Polygon DP simplification
From: Mateusz Loskot (mateusz)
Date: 2011-09-29 18:50:12
On 27/09/11 21:24, V D wrote:
> Basically, the original polygon has values between 0 and 1, and is
> simplified with 1.0/2048.0
> The second polygon is the original with point values multiplied by 2047
> (0..2047, so 2048 pixels for example) and is simplified with 1.0
> Original polygon has 37 points, simplified with 1.0/2048 I get 20 points
> Multiplied by 2047 and simplified with 1.0, I get 35 points (correct
> behavior with 1 pixel distance).
> Shouldn't the number of points of the simplified polygons be the same if
> the point coordinates and max distance are proportional ?
I confirm there is a problem indeed.
I quickly checked and I think there is a bug in distance calculation.
Simply, pythagorean distance calculation is not hooking sqrt.
I managed to solve it, but in spite of that the solution is technically
trivial, it potentially affects other areas. It causes number of unit
test failures, etc.
So, I decided to not to commit it to the trunk, but I submitted ticket
with patch attached;
Can you apply the patch and see if it solves the problem for you?
My tests (also comparing with results from other geometry libs)
confirm it should solve the problem.
-- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org Member of ACCU, http://accu.org
Geometry list run by mateusz at loskot.net