Clipper - fix PolyTree traversal

This commit is contained in:
artemp 2015-04-10 14:13:08 +02:00
parent fb61a2bb90
commit 2ebc729cc8

View file

@ -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";