GEOS  3.10.0
MCIndexNoder.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  * Last port: noding/MCIndexNoder.java rev. 1.6 (JTS-1.9)
16  *
17  **********************************************************************/
18 
19 #ifndef GEOS_NODING_MCINDEXNODER_H
20 #define GEOS_NODING_MCINDEXNODER_H
21 
22 #include <geos/export.h>
23 
24 #include <geos/inline.h>
25 
26 #include <geos/index/chain/MonotoneChainOverlapAction.h> // for inheritance
27 #include <geos/index/chain/MonotoneChain.h>
28 #include <geos/noding/SinglePassNoder.h> // for inheritance
29 #include <geos/index/strtree/TemplateSTRtree.h> // for composition
30 #include <geos/util.h>
31 
32 #include <vector>
33 #include <iostream>
34 
35 #ifdef _MSC_VER
36 #pragma warning(push)
37 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
38 #endif
39 
40 // Forward declarations
41 namespace geos {
42 namespace geom {
43 class LineSegment;
44 class Envelope;
45 }
46 namespace noding {
47 class SegmentString;
48 class SegmentIntersector;
49 }
50 }
51 
52 namespace geos {
53 namespace noding { // geos.noding
54 
66 class GEOS_DLL MCIndexNoder : public SinglePassNoder {
67 
68 private:
69  std::vector<index::chain::MonotoneChain> monoChains;
70  index::strtree::TemplateSTRtree<const index::chain::MonotoneChain*> index;
71  std::vector<SegmentString*>* nodedSegStrings;
72  // statistics
73  int nOverlaps;
74  double overlapTolerance;
75  bool indexBuilt;
76 
77  void intersectChains();
78 
79  void add(SegmentString* segStr);
80 
81 public:
82 
83  MCIndexNoder(SegmentIntersector* nSegInt = nullptr, double p_overlapTolerance = 0.0)
84  : SinglePassNoder(nSegInt)
85  , nodedSegStrings(nullptr)
86  , nOverlaps(0)
87  , overlapTolerance(p_overlapTolerance)
88  , indexBuilt(false)
89  {}
90 
91  ~MCIndexNoder() override {};
92 
93 
95  std::vector<index::chain::MonotoneChain>&
97  {
98  return monoChains;
99  }
100 
101  index::SpatialIndex& getIndex();
102 
103  std::vector<SegmentString*>* getNodedSubstrings() const override;
104 
105  void computeNodes(std::vector<SegmentString*>* inputSegmentStrings) override;
106 
107  class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
108  public:
109  SegmentOverlapAction(SegmentIntersector& newSi)
110  :
111  index::chain::MonotoneChainOverlapAction(),
112  si(newSi)
113  {}
114 
115  void overlap(const index::chain::MonotoneChain& mc1, std::size_t start1,
116  const index::chain::MonotoneChain& mc2, std::size_t start2) override;
117  private:
118  SegmentIntersector& si;
119 
120  // Declare type as noncopyable
121  SegmentOverlapAction(const SegmentOverlapAction& other) = delete;
122  SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs) = delete;
123  };
124 
125 };
126 
127 } // namespace geos.noding
128 } // namespace geos
129 
130 #ifdef _MSC_VER
131 #pragma warning(pop)
132 #endif
133 
134 #ifdef GEOS_INLINE
135 # include <geos/noding/MCIndexNoder.inl>
136 #endif
137 
138 #endif // GEOS_NODING_MCINDEXNODER_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
Nodes a set of SegmentString using a index based on MonotoneChain and a SpatialIndex.
Definition: MCIndexNoder.h:66
void computeNodes(std::vector< SegmentString * > *inputSegmentStrings) override
Computes the noding for a collection of SegmentStrings.
std::vector< index::chain::MonotoneChain > & getMonotoneChains()
Return a reference to this instance's std::vector of MonotoneChains.
Definition: MCIndexNoder.h:96
std::vector< SegmentString * > * getNodedSubstrings() const override
Returns a Collection of fully noded SegmentStrings.
Processes possible intersections detected by a Noder.
Definition: noding/SegmentIntersector.h:48
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:46
Base class for Noders which make a single pass to find intersections.
Definition: SinglePassNoder.h:51
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26