|
Geometry : |
Subject: [geometry] Wrong results for dissolve Polygon
From: Wimmer, Andreas (andreas.wimmer_at_[hidden])
Date: 2015-06-18 03:06:33
Dear Boost Geometry Contributors,
I am testing the boost::geometry::dissolve function upon some invalid polygons that are produced by a certain in-house segmentation alg.
The fact that the algorithm is producing possibly invalid polygons cannot be changed easily so I thought I will fix them afterwards using dissolve from "geometry/extensions/algorithms/dissolve.hpp" for the latest boost 1.58 version.
Unfortunately I stumbled over the following polygons for which dissolve produces wrong results.
The following code illustrates the result
using namespace boost::geometry;
using namespace boost::geometry::model;
using namespace boost::geometry::model::d2;
int main(int argc, _TCHAR* argv[])
{
polygon< point_xy<float> > Poly;
read_wkt("POLYGON((10 10, 10 20, 20 20, 15 12, 15 18, 20 10, 10 10))",
Poly);
multi_polygon< polygon< point_xy< float > > > Dissolved;
boost::geometry::dissolve(Poly, Dissolved);
}
Which results in a polygon including the small intersection part which should be excluded from the polygon
And even more problematic the following example (same polygon with and additional self-touching outer ring) results in missing the entire main part of the polygon
int main(int argc, _TCHAR* argv[])
{
polygon< point_xy<float> > Poly;
read_wkt("POLYGON((10 10, 10 20, 20 20, 20 25, 22 25, 20 20, 15 12, 15 18, 20 10, 10 10))",
Poly);
multi_polygon< polygon< point_xy< float > > > Dissolved;
boost::geometry::dissolve(Poly, Dissolved);
}
I hope somebody can show me what I did wrong or what I can to too work around this problem.
Best regards,
Andreas Wimmer
Geometry list run by mateusz at loskot.net