GEOS 3.9.1
index/chain/MonotoneChain.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2001-2002 Vivid Solutions 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: index/chain/MonotoneChain.java rev. 1.15 (JTS-1.10)
16 *
17 **********************************************************************/
18
19#ifndef GEOS_IDX_CHAIN_MONOTONECHAIN_H
20#define GEOS_IDX_CHAIN_MONOTONECHAIN_H
21
22#include <geos/export.h>
23#include <geos/geom/Envelope.h> // for inline
24
25#include <memory> // for unique_ptr
26
27// Forward declarations
28namespace geos {
29namespace geom {
30class LineSegment;
31class CoordinateSequence;
32}
33namespace index {
34namespace chain {
37}
38}
39}
40
41namespace geos {
42namespace index { // geos::index
43namespace chain { // geos::index::chain
44
84class GEOS_DLL MonotoneChain {
85public:
86
98 std::size_t start, std::size_t end, void* context);
99
100 ~MonotoneChain() = default;
101
104 const geom::Envelope& getEnvelope(double expansionDistance);
105
106 size_t
107 getStartIndex() const
108 {
109 return start;
110 }
111
112 size_t
113 getEndIndex() const
114 {
115 return end;
116 }
117
122 void getLineSegment(std::size_t index, geom::LineSegment& ls) const;
123
129 std::unique_ptr<geom::CoordinateSequence> getCoordinates() const;
130
135 void select(const geom::Envelope& searchEnv,
137
138 void computeOverlaps(MonotoneChain* mc,
140
141 void computeOverlaps(MonotoneChain* mc, double overlapTolerance,
143
144 void
145 setId(int nId)
146 {
147 id = nId;
148 }
149
150 inline int
151 getId() const
152 {
153 return id;
154 }
155
156 void*
157 getContext()
158 {
159 return context;
160 }
161
162private:
163
164 void computeSelect(const geom::Envelope& searchEnv,
165 size_t start0,
166 size_t end0,
167 MonotoneChainSelectAction& mcs);
168
169 void computeOverlaps(std::size_t start0, std::size_t end0, MonotoneChain& mc,
170 std::size_t start1, std::size_t end1,
171 double overlapTolerance,
172 MonotoneChainOverlapAction& mco);
173
174 bool overlaps(size_t start0, size_t end0,
175 const MonotoneChain& mc, size_t start1, size_t end1,
176 double overlapTolerance) const;
177
178 bool overlaps(const geom::Coordinate& p1, const geom::Coordinate& p2,
179 const geom::Coordinate& q1, const geom::Coordinate& q2,
180 double overlapTolerance) const;
181
183 const geom::CoordinateSequence& pts;
184
186 void* context;
187
189 size_t start;
190
192 size_t end;
193
195 geom::Envelope env;
196 bool envIsSet;
197
199 int id;
200
201
202 // Declare type as noncopyable
203 MonotoneChain(const MonotoneChain& other) = delete;
204 MonotoneChain& operator=(const MonotoneChain& rhs) = delete;
205};
206
207} // namespace geos::index::chain
208} // namespace geos::index
209} // namespace geos
210
211#endif // GEOS_IDX_CHAIN_MONOTONECHAIN_H
212
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:58
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:58
Definition LineSegment.h:59
The action for the internal iterator for performing overlap queries on a MonotoneChain.
Definition MonotoneChainOverlapAction.h:43
Definition MonotoneChainSelectAction.h:45
Monotone Chains are a way of partitioning the segments of a linestring to allow for fast searching of...
Definition index/chain/MonotoneChain.h:84
MonotoneChain(const geom::CoordinateSequence &pts, std::size_t start, std::size_t end, void *context)
const geom::Envelope & getEnvelope()
Returned envelope is owned by this class.
void getLineSegment(std::size_t index, geom::LineSegment &ls) const
Set given LineSegment with points of the segment starting at the given index.
std::unique_ptr< geom::CoordinateSequence > getCoordinates() const
void select(const geom::Envelope &searchEnv, MonotoneChainSelectAction &mcs)
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26