Skip to content

Commit

Permalink
Add envelope condition in support of RelateNG
Browse files Browse the repository at this point in the history
  • Loading branch information
pramsey committed Jul 25, 2024
1 parent 6201229 commit 4907d59
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
21 changes: 18 additions & 3 deletions include/geos/noding/MCIndexSegmentSetMutualIntersector.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
#include <geos/index/strtree/TemplateSTRtree.h> // inherited

namespace geos {
namespace geom {
class Envelope;
}
namespace index {
class SpatialIndex;
class SpatialIndex;
}
namespace noding {
class SegmentString;
class SegmentIntersector;
class SegmentString;
class SegmentIntersector;
}
}

Expand All @@ -51,6 +54,17 @@ class MCIndexSegmentSetMutualIntersector : public SegmentSetMutualIntersector {
, nOverlaps(0)
, overlapTolerance(p_tolerance)
, indexBuilt(false)
, envelope(nullptr)
{}

MCIndexSegmentSetMutualIntersector(const geom::Envelope* p_envelope)
: monoChains()
, indexCounter(0)
, processCounter(0)
, nOverlaps(0)
, overlapTolerance(0.0)
, indexBuilt(false)
, envelope(p_envelope)
{}

MCIndexSegmentSetMutualIntersector()
Expand Down Expand Up @@ -117,6 +131,7 @@ class MCIndexSegmentSetMutualIntersector : public SegmentSetMutualIntersector {
*/
bool indexBuilt;
MonoChains indexChains;
const geom::Envelope* envelope;

void addToIndex(SegmentString* segStr);

Expand Down
13 changes: 11 additions & 2 deletions src/noding/MCIndexSegmentSetMutualIntersector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*
**********************************************************************/

#include <geos/geom/Envelope.h>
#include <geos/noding/MCIndexSegmentSetMutualIntersector.h>
#include <geos/noding/SegmentSetMutualIntersector.h>
#include <geos/noding/SegmentString.h>
Expand Down Expand Up @@ -47,8 +48,14 @@ MCIndexSegmentSetMutualIntersector::addToMonoChains(SegmentString* segStr)
{
if (segStr->size() == 0)
return;
MonoChains segChains;
MonotoneChainBuilder::getChains(segStr->getCoordinates(),
segStr, monoChains);
segStr, segChains);
for (auto& mc : segChains) {
if (envelope == nullptr || envelope->intersects(mc.getEnvelope())) {
monoChains.push_back(mc);
}
}
}


Expand Down Expand Up @@ -89,7 +96,9 @@ MCIndexSegmentSetMutualIntersector::process(SegmentString::ConstVect* segStrings
{
if (!indexBuilt) {
for (auto& mc: indexChains) {
index.insert(&(mc.getEnvelope(overlapTolerance)), &mc);
if (envelope == nullptr || envelope->intersects(mc.getEnvelope())) {
index.insert(&(mc.getEnvelope(overlapTolerance)), &mc);
}
}
indexBuilt = true;
}
Expand Down

0 comments on commit 4907d59

Please sign in to comment.