GEOS 3.14.0dev
MCIndexSegmentSetMutualIntersector.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2006 Refractions Research Inc.
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************/
14
15#pragma once
16
17#include <geos/noding/SegmentSetMutualIntersector.h> // inherited
18#include <geos/index/chain/MonotoneChainOverlapAction.h> // inherited
19#include <geos/index/chain/MonotoneChain.h> // inherited
20#include <geos/index/strtree/TemplateSTRtree.h> // inherited
21
22namespace geos {
23namespace geom {
24 class Envelope;
25}
26namespace index {
27 class SpatialIndex;
28}
29namespace noding {
30 class SegmentString;
31 class SegmentIntersector;
32}
33}
34
35//using namespace geos::index::strtree;
36
37namespace geos {
38namespace noding { // geos::noding
39
48public:
49
50 MCIndexSegmentSetMutualIntersector(double p_tolerance)
51 : monoChains()
52 , indexCounter(0)
53 , processCounter(0)
54 , nOverlaps(0)
55 , overlapTolerance(p_tolerance)
56 , indexBuilt(false)
57 , envelope(nullptr)
58 {}
59
61 : monoChains()
62 , indexCounter(0)
63 , processCounter(0)
64 , nOverlaps(0)
65 , overlapTolerance(0.0)
66 , indexBuilt(false)
67 , envelope(p_envelope)
68 {}
69
72 {}
73
75 {};
76
78 getIndex()
79 {
80 return &index;
81 }
82
83 void setBaseSegments(SegmentString::ConstVect* segStrings) override;
84
85 // NOTE: re-populates the MonotoneChain vector with newly created chains
86 void process(SegmentString::ConstVect* segStrings) override;
87
88 class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
89 private:
91
92 // Declare type as noncopyable
93 SegmentOverlapAction(const SegmentOverlapAction& other) = delete;
94 SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs) = delete;
95
96 public:
97 SegmentOverlapAction(SegmentIntersector& p_si) :
98 index::chain::MonotoneChainOverlapAction(), si(p_si)
99 {}
100
101 void overlap(const index::chain::MonotoneChain& mc1, std::size_t start1,
102 const index::chain::MonotoneChain& mc2, std::size_t start2) override;
103 };
104
111
112private:
113
114 typedef std::vector<index::chain::MonotoneChain> MonoChains;
115 MonoChains monoChains;
116
117 /*
118 * The index::SpatialIndex used should be something that supports
119 * envelope (range) queries efficiently (such as a index::quadtree::Quadtree
120 * or index::strtree::STRtree).
121 */
122 index::strtree::TemplateSTRtree<const index::chain::MonotoneChain*> index;
123 int indexCounter;
124 int processCounter;
125 // statistics
126 int nOverlaps;
127 double overlapTolerance;
128
129 /* memory management helper, holds MonotoneChain objects used
130 * in the SpatialIndex. It's cleared when the SpatialIndex is
131 */
132 bool indexBuilt;
133 MonoChains indexChains;
134 const geom::Envelope* envelope;
135
136 void addToIndex(SegmentString* segStr);
137
138 void intersectChains();
139
140 void addToMonoChains(SegmentString* segStr);
141
142};
143
144} // namespace geos::noding
145} // namespace geos
146
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
Abstract class defines basic insertion and query operations supported by classes implementing spatial...
Definition SpatialIndex.h:46
The action for the internal iterator for performing overlap queries on a MonotoneChain.
Definition MonotoneChainOverlapAction.h:42
Monotone Chains are a way of partitioning the segments of a linestring to allow for fast searching of...
Definition index/chain/MonotoneChain.h:85
Intersects two sets of SegmentStrings using a index based on MonotoneChains and a SpatialIndex.
Definition MCIndexSegmentSetMutualIntersector.h:47
MCIndexSegmentSetMutualIntersector(const MCIndexSegmentSetMutualIntersector &)=delete
void setBaseSegments(SegmentString::ConstVect *segStrings) override
void process(SegmentString::ConstVect *segStrings) override
Processes possible intersections detected by a Noder.
Definition noding/SegmentIntersector.h:45
An intersector for the red-blue intersection problem.
Definition SegmentSetMutualIntersector.h:36
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
Basic namespace for all GEOS functionalities.
Definition geos.h:39