GEOS  3.8.0dev
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/noding/SinglePassNoder.h> // for inheritance
28 #include <geos/index/strtree/STRtree.h> // for composition
29 #include <geos/util.h>
30 
31 #include <vector>
32 #include <iostream>
33 
34 #ifdef _MSC_VER
35 #pragma warning(push)
36 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
37 #endif
38 
39 // Forward declarations
40 namespace geos {
41 namespace geom {
42 class LineSegment;
43 }
44 namespace noding {
45 class SegmentString;
46 class SegmentIntersector;
47 }
48 }
49 
50 namespace geos {
51 namespace noding { // geos.noding
52 
63 class GEOS_DLL MCIndexNoder : public SinglePassNoder {
64 
65 private:
66  std::vector<index::chain::MonotoneChain*> monoChains;
68  int idCounter;
69  std::vector<SegmentString*>* nodedSegStrings;
70  // statistics
71  int nOverlaps;
72 
73  void intersectChains();
74 
75  void add(SegmentString* segStr);
76 
77 public:
78 
79  MCIndexNoder(SegmentIntersector* nSegInt = nullptr)
80  :
81  SinglePassNoder(nSegInt),
82  idCounter(0),
83  nodedSegStrings(nullptr),
84  nOverlaps(0)
85  {}
86 
87  ~MCIndexNoder() override;
88 
90  std::vector<index::chain::MonotoneChain*>&
92  {
93  return monoChains;
94  }
95 
96  index::SpatialIndex& getIndex();
97 
98  std::vector<SegmentString*>* getNodedSubstrings() const override;
99 
100  void computeNodes(std::vector<SegmentString*>* inputSegmentStrings) override;
101 
102  class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
103  public:
104  SegmentOverlapAction(SegmentIntersector& newSi)
105  :
106  index::chain::MonotoneChainOverlapAction(),
107  si(newSi)
108  {}
109 
110  void overlap(index::chain::MonotoneChain& mc1, std::size_t start1,
111  index::chain::MonotoneChain& mc2, std::size_t start2) override;
112  private:
113  SegmentIntersector& si;
114 
115  // Declare type as noncopyable
116  SegmentOverlapAction(const SegmentOverlapAction& other) = delete;
117  SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs) = delete;
118  };
119 
120 };
121 
122 } // namespace geos.noding
123 } // namespace geos
124 
125 #ifdef _MSC_VER
126 #pragma warning(pop)
127 #endif
128 
129 #ifdef GEOS_INLINE
130 # include <geos/noding/MCIndexNoder.inl>
131 #endif
132 
133 #endif // GEOS_NODING_MCINDEXNODER_H
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:46
A query-only R-tree created using the Sort-Tile-Recursive (STR) algorithm. For two-dimensional spatia...
Definition: STRtree.h:64
Definition: MonotoneChainOverlapAction.h:43
Abstract class defines basic insertion and query operations supported by classes implementing spatial...
Definition: SpatialIndex.h:47
Definition: SinglePassNoder.h:50
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Processes possible intersections detected by a Noder.
Definition: noding/SegmentIntersector.h:48
Monotone Chains are a way of partitioning the segments of a linestring to allow for fast searching of...
Definition: index/chain/MonotoneChain.h:85
Nodes a set of SegmentString using a index based on index::chain::MonotoneChain and a index::SpatialI...
Definition: MCIndexNoder.h:63
std::vector< index::chain::MonotoneChain * > & getMonotoneChains()
Return a reference to this instance's std::vector of MonotoneChains.
Definition: MCIndexNoder.h:91