GEOS  3.9.0dev
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
28 namespace geos {
29 namespace geom {
30 class LineSegment;
31 class CoordinateSequence;
32 }
33 namespace index {
34 namespace chain {
37 }
38 }
39 }
40 
41 namespace geos {
42 namespace index { // geos::index
43 namespace chain { // geos::index::chain
44 
84 class GEOS_DLL MonotoneChain {
85 public:
86 
98  std::size_t start, std::size_t end, void* context);
99 
100  ~MonotoneChain() = default;
101 
103  const geom::Envelope& getEnvelope() const;
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 
158 private:
159 
160  void computeSelect(const geom::Envelope& searchEnv,
161  size_t start0,
162  size_t end0,
164 
165  void computeOverlaps(std::size_t start0, std::size_t end0, MonotoneChain& mc,
166  std::size_t start1, std::size_t end1,
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 
Definition: LineSegment.h:59
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
The action for the internal iterator for performing overlap queries on a MonotoneChain.
Definition: MonotoneChainOverlapAction.h:43
Definition: MonotoneChainSelectAction.h:45
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26
Monotone Chains are a way of partitioning the segments of a linestring to allow for fast searching of...
Definition: index/chain/MonotoneChain.h:84
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58