GEOS  3.8.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  *
16  * Last port: noding/MCIndexSegmentSetMutualIntersector.java r388 (JTS-1.12)
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_NODING_MCINDEXSEGMENTSETMUTUALINTERSECTOR_H
21 #define GEOS_NODING_MCINDEXSEGMENTSETMUTUALINTERSECTOR_H
22 
23 #include <geos/noding/SegmentSetMutualIntersector.h> // inherited
24 #include <geos/index/chain/MonotoneChainOverlapAction.h> // inherited
25 
26 namespace geos {
27 namespace index {
28 class SpatialIndex;
29 
30 namespace chain {
31 class MonotoneChain;
32 }
33 namespace strtree {
34 //class STRtree;
35 }
36 }
37 namespace noding {
38 class SegmentString;
39 class SegmentIntersector;
40 }
41 }
42 
43 //using namespace geos::index::strtree;
44 
45 namespace geos {
46 namespace noding { // geos::noding
47 
55 public:
56 
58 
60 
62  getIndex()
63  {
64  return index;
65  }
66 
67  void setBaseSegments(SegmentString::ConstVect* segStrings) override;
68 
69  // NOTE: re-populates the MonotoneChain vector with newly created chains
70  void process(SegmentString::ConstVect* segStrings) override;
71 
72  class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
73  private:
75 
76  // Declare type as noncopyable
77  SegmentOverlapAction(const SegmentOverlapAction& other) = delete;
78  SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs) = delete;
79 
80  public:
81  SegmentOverlapAction(SegmentIntersector& p_si) :
83  {}
84 
85  void overlap(index::chain::MonotoneChain& mc1, std::size_t start1,
86  index::chain::MonotoneChain& mc2, std::size_t start2) override;
87  };
88 
95 
96 private:
97 
98  typedef std::vector<std::unique_ptr<index::chain::MonotoneChain>> MonoChains;
99  MonoChains monoChains;
100 
101  /*
102  * The {@link SpatialIndex} used should be something that supports
103  * envelope (range) queries efficiently (such as a {@link Quadtree}
104  * or {@link STRtree}.
105  */
106  index::SpatialIndex* index;
107  int indexCounter;
108  int processCounter;
109  // statistics
110  int nOverlaps;
111 
112  /* memory management helper, holds MonotoneChain objects used
113  * in the SpatialIndex. It's cleared when the SpatialIndex is
114  */
115  MonoChains chainStore;
116 
117  void addToIndex(SegmentString* segStr);
118 
119  void intersectChains();
120 
121  void addToMonoChains(SegmentString* segStr);
122 
123 };
124 
125 } // namespace geos::noding
126 } // namespace geos
127 
128 #endif // GEOS_NODING_MCINDEXSEGMENTSETMUTUALINTERSECTOR_H
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:46
Definition: MonotoneChainOverlapAction.h:43
Abstract class defines basic insertion and query operations supported by classes implementing spatial...
Definition: SpatialIndex.h:47
Intersects two sets of SegmentStrings using a index based on MonotoneChains and a SpatialIndex...
Definition: MCIndexSegmentSetMutualIntersector.h:54
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Processes possible intersections detected by a Noder.
Definition: noding/SegmentIntersector.h:48
An intersector for the red-blue intersection problem.
Definition: SegmentSetMutualIntersector.h:37
Monotone Chains are a way of partitioning the segments of a linestring to allow for fast searching of...
Definition: index/chain/MonotoneChain.h:85
void process(SegmentString::ConstVect *segStrings) override
void setBaseSegments(SegmentString::ConstVect *segStrings) override