GEOS  3.8.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 Envelope;
31 class LineSegment;
32 class CoordinateSequence;
33 }
34 namespace index {
35 namespace chain {
38 }
39 }
40 }
41 
42 namespace geos {
43 namespace index { // geos::index
44 namespace chain { // geos::index::chain
45 
85 class GEOS_DLL MonotoneChain {
86 public:
87 
99  std::size_t start, std::size_t end, void* context);
100 
101  ~MonotoneChain();
102 
104  const geom::Envelope& getEnvelope() const;
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
142  setId(int nId)
143  {
144  id = nId;
145  }
146 
147  inline int
148  getId() const
149  {
150  return id;
151  }
152 
153  void*
154  getContext()
155  {
156  return context;
157  }
158 
159 private:
160 
161  void computeSelect(const geom::Envelope& searchEnv,
162  size_t start0,
163  size_t end0,
165 
166  void computeOverlaps(std::size_t start0, std::size_t end0, MonotoneChain& mc,
167  std::size_t start1, std::size_t end1,
169 
170  bool overlaps(size_t start0, size_t end0, const MonotoneChain& mc, size_t start1, size_t end1);
171 
173  const geom::CoordinateSequence& pts;
174 
176  mutable geom::Envelope* env;
177 
179  void* context;
180 
182  size_t start;
183 
185  size_t end;
186 
188  int id;
189 
190  // Declare type as noncopyable
191  MonotoneChain(const MonotoneChain& other) = delete;
192  MonotoneChain& operator=(const MonotoneChain& rhs) = delete;
193 };
194 
195 } // namespace geos::index::chain
196 } // namespace geos::index
197 } // namespace geos
198 
199 #endif // GEOS_IDX_CHAIN_MONOTONECHAIN_H
200 
Definition: LineSegment.h:57
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:59
Definition: MonotoneChainOverlapAction.h:43
Definition: MonotoneChainSelectAction.h:45
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Monotone Chains are a way of partitioning the segments of a linestring to allow for fast searching of...
Definition: index/chain/MonotoneChain.h:85
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58