GEOS  3.9.1dev
SegmentNodeList.h
Go to the documentation of this file.
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/SegmentNodeList.java rev. 1.8 (JTS-1.10)
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/export.h>
22 
23 #include <geos/inline.h>
24 
25 #include <cassert>
26 #include <iostream>
27 #include <vector>
28 #include <set>
29 #include <memory>
30 
31 #include <geos/noding/SegmentNode.h> // for composition
32 
33 #ifdef _MSC_VER
34 #pragma warning(push)
35 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
36 #endif
37 
38 // Forward declarations
39 namespace geos {
40 namespace geom {
41 class CoordinateSequence;
42 }
43 namespace noding {
44 class SegmentString;
45 class NodedSegmentString;
46 }
47 }
48 
49 namespace geos {
50 namespace noding { // geos::noding
51 
57 private:
58  std::set<SegmentNode*, SegmentNodeLT> nodeMap;
59  std::deque<SegmentNode> nodeQue;
60 
61  // the parent edge
63 
70  void checkSplitEdgesCorrectness(const std::vector<SegmentString*>& splitEdges) const;
71 
80  std::unique_ptr<SegmentString> createSplitEdge(const SegmentNode* ei0, const SegmentNode* ei1) const;
81 
92  void createSplitEdgePts(const SegmentNode* ei0, const SegmentNode* ei1, std::vector<geom::Coordinate>& pts) const;
93 
102  void addCollapsedNodes();
103 
108  void findCollapsesFromExistingVertices(
109  std::vector<std::size_t>& collapsedVertexIndexes) const;
110 
118  void findCollapsesFromInsertedNodes(
119  std::vector<std::size_t>& collapsedVertexIndexes) const;
120 
121  bool findCollapseIndex(const SegmentNode& ei0, const SegmentNode& ei1,
122  size_t& collapsedVertexIndex) const;
123 
124  void addEdgeCoordinates(const SegmentNode* ei0, const SegmentNode* ei1, std::vector<geom::Coordinate>& coordList) const;
125 
126  // Declare type as noncopyable
127  SegmentNodeList(const SegmentNodeList& other) = delete;
128  SegmentNodeList& operator=(const SegmentNodeList& rhs) = delete;
129 
130 public:
131 
132  friend std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
133 
134  typedef std::set<SegmentNode*, SegmentNodeLT> container;
135  typedef container::iterator iterator;
136  typedef container::const_iterator const_iterator;
137 
138  SegmentNodeList(const NodedSegmentString* newEdge): edge(*newEdge) {}
139 
140  SegmentNodeList(const NodedSegmentString& newEdge): edge(newEdge) {}
141 
142  ~SegmentNodeList();
143 
144  const NodedSegmentString&
145  getEdge() const
146  {
147  return edge;
148  }
149 
160  SegmentNode* add(const geom::Coordinate& intPt, std::size_t segmentIndex);
161 
162  SegmentNode*
163  add(const geom::Coordinate* intPt, std::size_t segmentIndex)
164  {
165  return add(*intPt, segmentIndex);
166  }
167 
168  /*
169  * returns the set of SegmentNodes
170  */
171  //replaces iterator()
172  // TODO: obsolete this function
173  std::set<SegmentNode*, SegmentNodeLT>*
175  {
176  return &nodeMap;
177  }
178 
180  size_t
181  size() const
182  {
183  return nodeMap.size();
184  }
185 
186  container::iterator
188  {
189  return nodeMap.begin();
190  }
191  container::const_iterator
192  begin() const
193  {
194  return nodeMap.begin();
195  }
196  container::iterator
197  end()
198  {
199  return nodeMap.end();
200  }
201  container::const_iterator
202  end() const
203  {
204  return nodeMap.end();
205  }
206 
210  void addEndpoints();
211 
218  void addSplitEdges(std::vector<SegmentString*>& edgeList);
219 
220  void
221  addSplitEdges(std::vector<SegmentString*>* edgeList)
222  {
223  assert(edgeList);
224  addSplitEdges(*edgeList);
225  }
226 
236  std::unique_ptr<std::vector<geom::Coordinate>> getSplitCoordinates();
237 
238 
239 };
240 
241 std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
242 
243 } // namespace geos::noding
244 } // namespace geos
245 
246 #ifdef _MSC_VER
247 #pragma warning(pop)
248 #endif
249 
const NodedSegmentString & edge
#define GEOS_DLL
Definition: export.h:28
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
std::set< SegmentNode *, SegmentNodeLT > container
SegmentNodeList(const NodedSegmentString *newEdge)
SegmentNode * add(const geom::Coordinate *intPt, std::size_t segmentIndex)
Represents a list of contiguous line segments, and supports noding the segments.
container::const_iterator const_iterator
std::set< SegmentNode *, SegmentNodeLT > nodeMap
std::set< SegmentNode *, SegmentNodeLT > * getNodes()
std::deque< SegmentNode > nodeQue
container::iterator iterator
std::ostream & operator<<(std::ostream &os, const Coordinate &c)
Output function.
container::const_iterator begin() const
void addSplitEdges(std::vector< SegmentString * > *edgeList)
container::iterator end()
Basic namespace for all GEOS functionalities.
SegmentNodeList(const NodedSegmentString &newEdge)
size_t size() const
Return the number of nodes in this list.
container::const_iterator end() const
A list of the SegmentNode present along a NodedSegmentString.
const NodedSegmentString & getEdge() const
container::iterator begin()
Represents an intersection point between two NodedSegmentString.
Definition: SegmentNode.h:47