Clipper - fix PolyTree traversal
This commit is contained in:
parent
fb61a2bb90
commit
2ebc729cc8
1 changed files with 10 additions and 11 deletions
|
@ -512,26 +512,25 @@ public:
|
||||||
bool first = true;
|
bool first = true;
|
||||||
while (polynode)
|
while (polynode)
|
||||||
{
|
{
|
||||||
//do stuff with polynode here
|
|
||||||
if (first) first = false;
|
|
||||||
else mp.emplace_back();
|
|
||||||
if (!polynode->IsHole())
|
if (!polynode->IsHole())
|
||||||
{
|
{
|
||||||
|
if (first) first = false;
|
||||||
|
else mp.emplace_back(); // start new polygon
|
||||||
for (auto const& pt : polynode->Contour)
|
for (auto const& pt : polynode->Contour)
|
||||||
{
|
{
|
||||||
mp.back().exterior_ring.add_coord(pt.X, pt.Y);
|
mp.back().exterior_ring.add_coord(pt.X, pt.Y);
|
||||||
}
|
}
|
||||||
}
|
// childrens are interior rings
|
||||||
else
|
for (auto const* ring : polynode->Childs)
|
||||||
{
|
{
|
||||||
mapnik::geometry::linear_ring hole;
|
mapnik::geometry::linear_ring hole;
|
||||||
for (auto const& pt : polynode->Contour)
|
for (auto const& pt : ring->Contour)
|
||||||
{
|
{
|
||||||
hole.add_coord(pt.X, pt.Y);
|
hole.add_coord(pt.X, pt.Y);
|
||||||
}
|
}
|
||||||
mp.back().add_hole(std::move(hole));
|
mp.back().add_hole(std::move(hole));
|
||||||
}
|
}
|
||||||
std::cerr << "Is hole? " << polynode->IsHole() << std::endl;
|
}
|
||||||
polynode = polynode->GetNext();
|
polynode = polynode->GetNext();
|
||||||
}
|
}
|
||||||
std::string expect = expected_+".png";
|
std::string expect = expected_+".png";
|
||||||
|
|
Loading…
Reference in a new issue