MCIndexSegmentSetMutualIntersector.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#pragma once
#include <geos/noding/SegmentSetMutualIntersector.h> // inherited
#include <geos/index/chain/MonotoneChainOverlapAction.h> // inherited
#include <geos/index/chain/MonotoneChain.h> // inherited
#include <geos/index/strtree/TemplateSTRtree.h> // inherited
namespace geos {
namespace geom {
class Envelope;
}
namespace index {
class SpatialIndex;
}
namespace noding {
class SegmentString;
class SegmentIntersector;
}
}
//using namespace geos::index::strtree;
namespace geos {
namespace noding { // geos::noding
class GEOS_DLL MCIndexSegmentSetMutualIntersector : public SegmentSetMutualIntersector {
public:
MCIndexSegmentSetMutualIntersector(double p_tolerance)
: monoChains()
, indexCounter(0)
, processCounter(0)
, 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()
: MCIndexSegmentSetMutualIntersector(0.0)
{}
~MCIndexSegmentSetMutualIntersector() override
{};
index::SpatialIndex*
getIndex()
{
return &index;
}
void setBaseSegments(SegmentString::ConstVect* segStrings) override;
// NOTE: re-populates the MonotoneChain vector with newly created chains
void process(SegmentString::ConstVect* segStrings) override;
class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
private:
SegmentIntersector& si;
// Declare type as noncopyable
SegmentOverlapAction(const SegmentOverlapAction& other) = delete;
SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs) = delete;
public:
SegmentOverlapAction(SegmentIntersector& p_si) :
index::chain::MonotoneChainOverlapAction(), si(p_si)
{}
void overlap(const index::chain::MonotoneChain& mc1, std::size_t start1,
const index::chain::MonotoneChain& mc2, std::size_t start2) override;
};
MCIndexSegmentSetMutualIntersector(const MCIndexSegmentSetMutualIntersector&) = delete;
MCIndexSegmentSetMutualIntersector& operator=(const MCIndexSegmentSetMutualIntersector&) = delete;
private:
typedef std::vector<index::chain::MonotoneChain> MonoChains;
MonoChains monoChains;
/*
* The index::SpatialIndex used should be something that supports
* envelope (range) queries efficiently (such as a index::quadtree::Quadtree
* or index::strtree::STRtree).
*/
index::strtree::TemplateSTRtree<const index::chain::MonotoneChain*> index;
int indexCounter;
int processCounter;
// statistics
int nOverlaps;
double overlapTolerance;
/* memory management helper, holds MonotoneChain objects used
* in the SpatialIndex. It's cleared when the SpatialIndex is
*/
bool indexBuilt;
MonoChains indexChains;
const geom::Envelope* envelope;
void addToIndex(SegmentString* segStr);
void intersectChains();
void addToMonoChains(SegmentString* segStr);
};
} // namespace geos::noding
} // namespace geos
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::index::SpatialIndex
Abstract class defines basic insertion and query operations supported by classes implementing spatial...
Definition SpatialIndex.h:46
geos::index::chain::MonotoneChainOverlapAction
The action for the internal iterator for performing overlap queries on a MonotoneChain.
Definition MonotoneChainOverlapAction.h:42
geos::index::chain::MonotoneChain
Monotone Chains are a way of partitioning the segments of a linestring to allow for fast searching of...
Definition index/chain/MonotoneChain.h:85
geos::noding::MCIndexSegmentSetMutualIntersector::MCIndexSegmentSetMutualIntersector
MCIndexSegmentSetMutualIntersector(const MCIndexSegmentSetMutualIntersector &)=delete
geos::noding::MCIndexSegmentSetMutualIntersector::setBaseSegments
void setBaseSegments(SegmentString::ConstVect *segStrings) override
geos::noding::MCIndexSegmentSetMutualIntersector::process
void process(SegmentString::ConstVect *segStrings) override
geos::noding::SegmentIntersector
Processes possible intersections detected by a Noder.
Definition noding/SegmentIntersector.h:45
geos::noding::SegmentString
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
geos::geom
Definition Angle.h:26
geos::index
Provides classes for various kinds of spatial indexes.
Definition CleanCoverage.h:39
geos::noding
Classes to compute nodings for arrangements of line segments and line segment sequences.
Definition CoverageCleaner.h:42
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38