GEOS 3.15.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#pragma once
20
21#include <geos/export.h>
22
23#include <geos/index/chain/MonotoneChainOverlapAction.h> // for inheritance
24#include <geos/index/chain/MonotoneChain.h>
25#include <geos/index/strtree/TemplateSTRtree.h> // for composition
26#include <geos/noding/NodedSegmentString.h>
27#include <geos/noding/SegmentString.h>
28#include <geos/noding/SinglePassNoder.h> // for inheritance
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
40namespace geos {
41namespace geom {
42class LineSegment;
43class Envelope;
44}
45namespace noding {
46class SegmentString;
47class SegmentIntersector;
48}
49}
50
51namespace geos {
52namespace noding { // geos.noding
53
65class GEOS_DLL MCIndexNoder : public SinglePassNoder {
66
67private:
68 std::vector<index::chain::MonotoneChain> monoChains;
69 index::strtree::TemplateSTRtree<const index::chain::MonotoneChain*> index;
70 std::vector<SegmentString*> nodedSegStrings;
71 // statistics
72 int nOverlaps;
73 double overlapTolerance;
74 bool indexBuilt;
75
76 void intersectChains();
77
78 void add(SegmentString* segStr);
79
80public:
81
82 MCIndexNoder(SegmentIntersector* nSegInt = nullptr, double p_overlapTolerance = 0.0)
83 : SinglePassNoder(nSegInt)
84 , nOverlaps(0)
85 , overlapTolerance(p_overlapTolerance)
86 , indexBuilt(false)
87 {}
88
89 ~MCIndexNoder() override {};
90
91
93 std::vector<index::chain::MonotoneChain>&
95 {
96 return monoChains;
97 }
98
99 index::SpatialIndex& getIndex()
100 {
101 return index;
102 }
103
104 std::vector<std::unique_ptr<SegmentString>> getNodedSubstrings() override
105 {
106 //assert(nodedSegStrings); // must have called computeNodes before!
107 return NodedSegmentString::getNodedSubstrings(nodedSegStrings);
108 }
109
110 void computeNodes(const std::vector<SegmentString*>& inputSegmentStrings) override;
111
112 class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
113 public:
114 SegmentOverlapAction(SegmentIntersector& newSi)
115 :
116 index::chain::MonotoneChainOverlapAction(),
117 si(newSi)
118 {}
119
120 void overlap(const index::chain::MonotoneChain& mc1, std::size_t start1,
121 const index::chain::MonotoneChain& mc2, std::size_t start2) override;
122 private:
124
125 // Declare type as noncopyable
126 SegmentOverlapAction(const SegmentOverlapAction& other) = delete;
127 SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs) = delete;
128 };
129
130};
131
132} // namespace geos.noding
133} // namespace geos
134
135#ifdef _MSC_VER
136#pragma warning(pop)
137#endif
138
139
140
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
Nodes a set of SegmentString using a index based on MonotoneChain and a SpatialIndex.
Definition MCIndexNoder.h:65
std::vector< std::unique_ptr< SegmentString > > getNodedSubstrings() override
Returns a Collection of fully noded SegmentStrings.
Definition MCIndexNoder.h:104
void computeNodes(const 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:94
Processes possible intersections detected by a Noder.
Definition noding/SegmentIntersector.h:45
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
Base class for Noders which make a single pass to find intersections.
Definition SinglePassNoder.h:48
Basic namespace for all GEOS functionalities.
Definition geos.h:38