GEOS  3.10.1
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 #include <geos/index/chain/MonotoneChain.h> // inherited
26 #include <geos/index/strtree/TemplateSTRtree.h> // inherited
27 
28 namespace geos {
29 namespace index {
30 class SpatialIndex;
31 
32 namespace chain {
33 }
34 namespace strtree {
35 //class STRtree;
36 }
37 }
38 namespace noding {
39 class SegmentString;
40 class SegmentIntersector;
41 }
42 }
43 
44 //using namespace geos::index::strtree;
45 
46 namespace geos {
47 namespace noding { // geos::noding
48 
57 public:
58 
60  : monoChains()
61  , indexCounter(0)
62  , processCounter(0)
63  , nOverlaps(0)
64  , indexBuilt(false)
65  {}
66 
68  {};
69 
71  getIndex()
72  {
73  return &index;
74  }
75 
76  void setBaseSegments(SegmentString::ConstVect* segStrings) override;
77 
78  // NOTE: re-populates the MonotoneChain vector with newly created chains
79  void process(SegmentString::ConstVect* segStrings) override;
80 
81  class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
82  private:
84 
85  // Declare type as noncopyable
86  SegmentOverlapAction(const SegmentOverlapAction& other) = delete;
87  SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs) = delete;
88 
89  public:
90  SegmentOverlapAction(SegmentIntersector& p_si) :
91  index::chain::MonotoneChainOverlapAction(), si(p_si)
92  {}
93 
94  void overlap(const index::chain::MonotoneChain& mc1, std::size_t start1,
95  const index::chain::MonotoneChain& mc2, std::size_t start2) override;
96  };
97 
104 
105 private:
106 
107  typedef std::vector<index::chain::MonotoneChain> MonoChains;
108  MonoChains monoChains;
109 
110  /*
111  * The index::SpatialIndex used should be something that supports
112  * envelope (range) queries efficiently (such as a index::quadtree::Quadtree
113  * or index::strtree::STRtree).
114  */
115  index::strtree::TemplateSTRtree<const index::chain::MonotoneChain*> index;
116  int indexCounter;
117  int processCounter;
118  // statistics
119  int nOverlaps;
120 
121  /* memory management helper, holds MonotoneChain objects used
122  * in the SpatialIndex. It's cleared when the SpatialIndex is
123  */
124  bool indexBuilt;
125  MonoChains indexChains;
126 
127  void addToIndex(SegmentString* segStr);
128 
129  void intersectChains();
130 
131  void addToMonoChains(SegmentString* segStr);
132 
133 };
134 
135 } // namespace geos::noding
136 } // namespace geos
137 
138 #endif // GEOS_NODING_MCINDEXSEGMENTSETMUTUALINTERSECTOR_H
Abstract class defines basic insertion and query operations supported by classes implementing spatial...
Definition: SpatialIndex.h:47
The action for the internal iterator for performing overlap queries on a MonotoneChain.
Definition: MonotoneChainOverlapAction.h:43
Monotone Chains are a way of partitioning the segments of a linestring to allow for fast searching of...
Definition: index/chain/MonotoneChain.h:86
Intersects two sets of SegmentStrings using a index based on MonotoneChains and a SpatialIndex.
Definition: MCIndexSegmentSetMutualIntersector.h:56
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:48
An intersector for the red-blue intersection problem.
Definition: SegmentSetMutualIntersector.h:37
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:46
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26