Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/operation/overlayng/PolygonBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,21 @@ PolygonBuilder::assignHoles(OverlayEdgeRing* shell, const std::vector<OverlayEdg
void
PolygonBuilder::placeFreeHoles(const std::vector<OverlayEdgeRing*>& shells, const std::vector<OverlayEdgeRing*> & freeHoles) const
{
// TODO: use a spatial index to improve performance
// build spatial index
index::strtree::TemplateSTRtree<OverlayEdgeRing*> index;
for (auto& shell : shells) {
index.insert(*shell->getRingPtr()->getEnvelopeInternal(), shell);
}

std::vector<OverlayEdgeRing*> shellListOverlaps;
for (OverlayEdgeRing* hole : freeHoles) {
// only place this hole if it doesn't yet have a shell
if (hole->getShell() == nullptr) {
OverlayEdgeRing* shell = hole->findEdgeRingContaining(shells);
// get list of overlapping shells
shellListOverlaps.clear();
index.query(*hole->getRingPtr()->getEnvelopeInternal(), shellListOverlaps);

OverlayEdgeRing* shell = hole->findEdgeRingContaining(shellListOverlaps);
// only when building a polygon-valid result
if (isEnforcePolygonal && shell == nullptr) {
throw util::TopologyException("unable to assign free hole to a shell", hole->getCoordinate());
Expand Down
Loading