# Geometry :

Subject: [ggl] Polygon DP simplification
From: V D (zedxz2)
Date: 2011-09-21 13:24:35

Hi,

I'm hoping someone with experience with bg::simplify might help me here:
I am quite mystified as to why the following 2 simplifications does not return the "same" polygon.

Suppose in the first case, my coordinates are ratios between 0 and 1, and that I simplify with 1/2048 max distance (pixels)

Between 0...1, simplify with 1.0/2048.0

Original:
MULTIPOLYGON(((0.561648 1,1 1,1 0,0.468083 0,0.52758 0.00800554,0.599683 0.0280924,0.601611 0.265374,0.622693 0.316765,0.69507 0.357497,0.695623 0.429711,0.655111 0.502298,0.696467 0.543147,0.840712 0.593546,0.882583 0.66546,0.852357 0.748213,0.84264 0.789567,0.832667 0.841202,0.832667 0.841202,0.740538 0.873004,0.617349 0.905045,0.566576 0.977697,0.561648 1)),((0 0.801979,0.0308575 0.786234,0.0705513 0.631135,0.141616 0.527248,0.233985 0.505872,0.264777 0.526263,0.336631 0.505009,0.356603 0.422321,0.355803 0.350038,0.375252 0.205364,0.415206 0.0709182,0.45479 0,0 0,0 0,0 0.801979)))

Simplified:
MULTIPOLYGON(((0.561648 1,1 1,1 0,0.468083 0,0.599683 0.0280924,0.601611 0.265374,0.69507 0.357497,0.655111 0.502298,0.840712 0.593546,0.882583 0.66546,0.832667 0.841202,0.617349 0.905045,0.561648 1)),((0 0.801979,0.141616 0.527248,0.336631 0.505009,0.375252 0.205364,0.45479 0,0 0,0 0.801979)))

If I bring my values to actual pixel coordinates by multiplying everything by 2047:

Between 0...2047, simplify with 1.0
Original:
MULTIPOLYGON(((1149.69 2047,2047 2047,2047 0,958.165 0,1079.96 16.3873,1227.55 57.5051,1231.5 543.22,1274.65 648.418,1422.81 731.796,1423.94 879.619,1341.01 1028.2,1425.67 1111.82,1720.94 1214.99,1806.65 1362.2,1744.78 1531.59,1724.88 1616.24,1704.47 1721.94,1704.47 1721.94,1515.88 1787.04,1263.71 1852.63,1159.78 2001.35,1149.69 2047)),((0 1641.65,63.1654 1609.42,144.419 1291.93,289.888 1079.28,478.968 1035.52,541.999 1077.26,689.084 1033.75,729.967 864.492,728.33 716.527,768.141 420.381,849.927 145.17,930.954 0,0 0,0 0,0 1641.65)))

Simplified:
MULTIPOLYGON(((1149.69 2047,2047 2047,2047 0,958.165 0,1079.96 16.3873,1227.55 57.5051,1231.5 543.22,1274.65 648.418,1422.81 731.796,1423.94 879.619,1341.01 1028.2,1425.67 1111.82,1720.94 1214.99,1806.65 1362.2,1744.78 1531.59,1724.88 1616.24,1704.47 1721.94,1515.88 1787.04,1263.71 1852.63,1159.78 2001.35,1149.69 2047)),((0 1641.65,63.1654 1609.42,144.419 1291.93,289.888 1079.28,478.968 1035.52,541.999 1077.26,689.084 1033.75,729.967 864.492,728.33 716.527,768.141 420.381,849.927 145.17,930.954 0,0 0,0 1641.65)))

The later works, meaning it simplifies polygons with a tolerance of 1 pixel correctly.
But simplifying when my values are still between 0 and 1 (ratios) with 1/2048 tolerance, a LOT more vertices gets dropped by the simplification and it doesn't seem to respect the "would be" 1 pixel tolerance.

Anyone know why this happens?

Thank you,
-v
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/ggl/attachments/20110920/de07ca9e/attachment.html

Geometry list run by mateusz at loskot.net