GEOS 3.8.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
105 size_t
106 getStartIndex() const
107 {
108 return start;
109 }
110
111 size_t
112 getEndIndex() const
113 {
114 return end;
115 }
116
121 void getLineSegment(std::size_t index, geom::LineSegment& ls) const;
122
128 std::unique_ptr<geom::CoordinateSequence> getCoordinates() const;
129
134 void select(const geom::Envelope& searchEnv,
136
137 void computeOverlaps(MonotoneChain* mc,
139
140 void
141 setId(int nId)
142 {
143 id = nId;
144 }
145
146 inline int
147 getId() const
148 {
149 return id;
150 }
151
152 void*
153 getContext()
154 {
155 return context;
156 }
157
158private:
159
160 void computeSelect(const geom::Envelope& searchEnv,
161 size_t start0,
162 size_t end0,
163 MonotoneChainSelectAction& mcs);
164
165 void computeOverlaps(std::size_t start0, std::size_t end0, MonotoneChain& mc,
166 std::size_t start1, std::size_t end1,
167 MonotoneChainOverlapAction& mco);
168
169 bool overlaps(size_t start0, size_t end0, const MonotoneChain& mc, size_t start1, size_t end1);
170
172 const geom::CoordinateSequence& pts;
173
175 geom::Envelope env;
176
178 void* context;
179
181 size_t start;
182
184 size_t end;
185
187 int id;
188
189 // Declare type as noncopyable
190 MonotoneChain(const MonotoneChain& other) = delete;
191 MonotoneChain& operator=(const MonotoneChain& rhs) = delete;
192};
193
194} // namespace geos::index::chain
195} // namespace geos::index
196} // namespace geos
197
198#endif // GEOS_IDX_CHAIN_MONOTONECHAIN_H
199
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
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() const
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:25