|
Geometry : |
Subject: [ggl] bg::unique and precision
From: V D (zedxz2)
Date: 2011-10-13 12:39:27
Hi all,
I'm trying to use the boost::geometry::unique algorithm with my floating point (double) coordinates to help remove some points caused by multiple boost::geometry::union_ operations.
My problem is that I have a point I expect to be dropped but it is not.
If I output my polygon with boost::geometry::wkt with a precision of 10 on the standard output, I get:
"POLYGON((0.1228458425 0.2762994994,0.1618719912 0.3754430551,0.1894760088 0.3636949449,0.1520441575 0.2831885006,0.1586053516 0.2553795616,0.2015310664 0.194547869,0.2037415316 0.1710501379,0.1913271833 0.1505169551,-0.009684323661 0.02362241945,-0.2155940476 0.03852861759,-0.3258553122 0.1010639906,-0.4243909597 0.2413998863,-0.4792082935 0.3224697229,-0.5243502805 0.4385846314,-0.5328413562 0.4913225858,-0.523493889 0.5239744398,-0.5051443617 0.5471896845,-0.4405497839 0.5733801208,-0.1044661376 0.5448176013,-0.01166747447 0.5365554459,-0.01166747447 0.5365554459,0.1209963645 0.5286512668,0.2317872492 0.5035039166,0.2251467508 0.4742480834,0.1167556355 0.4988507332,-0.01345172553 0.5066085541,-0.1070658624 0.5149303987,-0.4430902161 0.5434878792,-0.4862676383 0.5226923155,-0.499958111 0.5053715602,-0.5022606438 0.4901154142,-0.4947317195 0.4433533686,-0.4524917065 0.3365162771,-0.3995390403 0.2582041137,-0.2869026878 0.1479500094,-0.1859939524 0.09071898241,0.02607116366 0.08167178055,0.1753128167 0.17588
50449,0.1730924684 0.1765418621,0.1716629336 0.191738131,0.1308486484 0.2423804384,0.1228458425 0.2762994994))"
Notice the points in bold. Building a polygon from this wkt and running bg::unique will indeed drop the duplicate.
But since the algorithm runs on the actual polygon, double coordinates, it has much more precision and the duplicate is not dropped.
So if I augment the precision of the output to 20, as wkt for my polygon I get:
"POLYGON((0.12284584246626920057 0.2762994994439921248,0.16187199118432568645 0.37544305505164943249,0.1894760088156743072 0.36369494494835052922,0.15204415753373082265 0.28318850055600786053,0.15860535158945385237 0.25537956161947428235,0.20153106639398876698 0.19454786901519924291,0.20374153161687885705 0.17105013787934753022,0.19132718334235701563 0.15051695507548853992,-0.0096843236605278597284 0.023622419454189733101,-0.21559404761196140909 0.038528617593098744842,-0.32585531220942764996 0.10106399061145349139,-0.42439095973644697102 0.24139988633097284043,-0.47920829349910465389 0.32246972292520065251,-0.52435028053601595577 0.43858463141520631634,-0.53284135619910655279 0.49132258575213111351,-0.52349388902201487994 0.52397443981313795991,-0.50514436169634047147 0.54718968449708194068,-0.44054978387368282089 0.57338012080228972778,-0.10446613755754380337 0.54481760127034406516,-0.011667474467576960384 0.53655544587272929746,-0.011667474467576944772 0.53655544587272929746,0.12099636451700621076 0.52865
126676837492781,0.23178724915138210205 0.50350391657282878022,0.22514675084861790477 0.47424808342717111875,0.11675563548299378036 0.49885073323162493208,-0.013451725532423056478 0.5066085541272706827,-0.10706586244245619444 0.51493039872965584713,-0.44309021612631716014 0.54348787919771024413,-0.48626763830365943297 0.52269231550291805899,-0.49995811097798520395 0.50537156018686213432,-0.50226064380089341377 0.49011541424786891907,-0.4947317194639840876 0.44335336858479368338,-0.45249170650089531875 0.33651627707479930818,-0.39953904026355308021 0.25820411366902712436,-0.28690268779057237492 0.14795000938854652173,-0.18599395238803856367 0.090718982406901238491,0.026071163660527859468 0.081671780545810271357,0.17531281665764300581 0.17588504492451148553,0.17309246838312114525 0.17654186212065248185,0.17166293360601125872 0.19173813098480077532,0.13084864841054613671 0.24238043838052572565,0.12284584246626920057 0.2762994994439921248))"
And indeed, creating a polygon from this WKT and running bg::unique will not drop the duplicate point (see points in bold).
Is there any way of specifying some kind of epsilon for the unique algorithm ? 1e-10 would be more than enough in my case.
Thanks!
-V
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/ggl/attachments/20111012/837da6b6/attachment.html
Geometry list run by mateusz at loskot.net