GEOS 3.14.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 , nodedSegStrings(nullptr)
85 , nOverlaps(0)
86 , overlapTolerance(p_overlapTolerance)
87 , indexBuilt(false)
88 {}
89
90 ~MCIndexNoder() override {};
91
92
94 std::vector<index::chain::MonotoneChain>&
96 {
97 return monoChains;
98 }
99
100 index::SpatialIndex& getIndex()
101 {
102 return index;
103 }
104
105 std::vector<SegmentString*>* getNodedSubstrings() const override
106 {
107 assert(nodedSegStrings); // must have called computeNodes before!
108 return NodedSegmentString::getNodedSubstrings(*nodedSegStrings);
109 }
110
111 void computeNodes(std::vector<SegmentString*>* inputSegmentStrings) override;
112
113 class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
114 public:
115 SegmentOverlapAction(SegmentIntersector& newSi)
116 :
117 index::chain::MonotoneChainOverlapAction(),
118 si(newSi)
119 {}
120
121 void overlap(const index::chain::MonotoneChain& mc1, std::size_t start1,
122 const index::chain::MonotoneChain& mc2, std::size_t start2) override;
123 private:
125
126 // Declare type as noncopyable
127 SegmentOverlapAction(const SegmentOverlapAction& other) = delete;
128 SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs) = delete;
129 };
130
131};
132
133} // namespace geos.noding
134} // namespace geos
135
136#ifdef _MSC_VER
137#pragma warning(pop)
138#endif
139
140
141
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
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:95
std::vector< SegmentString * > * getNodedSubstrings() const override
Returns a Collection of fully noded SegmentStrings.
Definition MCIndexNoder.h:105
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:39