GEOS 3.9.1
geomgraph/NodeMap.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2005-2006 Refractions Research Inc.
7 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: geomgraph/NodeMap.java rev. 1.3 (JTS-1.10)
17 *
18 **********************************************************************/
19
20
21#ifndef GEOS_GEOMGRAPH_NODEMAP_H
22#define GEOS_GEOMGRAPH_NODEMAP_H
23
24#include <geos/export.h>
25#include <map>
26#include <vector>
27#include <string>
28
29#include <geos/geom/Coordinate.h> // for CoordinateLessThen
30#include <geos/geomgraph/Node.h> // for testInvariant
31
32#include <geos/inline.h>
33
34#ifdef _MSC_VER
35#pragma warning(push)
36#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
37#endif
38
39// Forward declarations
40namespace geos {
41namespace geomgraph {
42class Node;
43class EdgeEnd;
44class NodeFactory;
45}
46}
47
48namespace geos {
49namespace geomgraph { // geos.geomgraph
50
51class GEOS_DLL NodeMap {
52public:
53
54 typedef std::map<geom::Coordinate*, Node*, geom::CoordinateLessThen> container;
55
56 typedef container::iterator iterator;
57
58 typedef container::const_iterator const_iterator;
59
60 typedef std::pair<geom::Coordinate*, Node*> pair;
61
62 container nodeMap;
63
64 const NodeFactory& nodeFact;
65
69 NodeMap(const NodeFactory& newNodeFact);
70
71 virtual ~NodeMap();
72
73 Node* addNode(const geom::Coordinate& coord);
74
75 Node* addNode(Node* n);
76
77 void add(EdgeEnd* e);
78
79 Node* find(const geom::Coordinate& coord) const;
80
81 const_iterator
82 begin() const
83 {
84 return nodeMap.begin();
85 }
86
87 const_iterator
88 end() const
89 {
90 return nodeMap.end();
91 }
92
93 iterator
94 begin()
95 {
96 return nodeMap.begin();
97 }
98
99 iterator
100 end()
101 {
102 return nodeMap.end();
103 }
104
105 void getBoundaryNodes(int geomIndex,
106 std::vector<Node*>& bdyNodes) const;
107
108 std::string print() const;
109
110 void
111 testInvariant()
112 {
113#ifndef NDEBUG
114 // Each Coordinate key is a pointer inside the Node value
115 for(iterator it = begin(), itEnd = end(); it != itEnd; ++it) {
116 pair p = *it;
117 geomgraph::Node* n = p.second;
118 geom::Coordinate* c = const_cast<geom::Coordinate*>(
119 &(n->getCoordinate())
120 );
121 assert(p.first == c);
122 }
123#endif
124 }
125
126private:
127
128 // Declare type as noncopyable
129 NodeMap(const NodeMap& other) = delete;
130 NodeMap& operator=(const NodeMap& rhs) = delete;
131};
132
133} // namespace geos.geomgraph
134} // namespace geos
135
136#ifdef _MSC_VER
137#pragma warning(pop)
138#endif
139
140#endif // ifndef GEOS_GEOMGRAPH_NODEMAP_H
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26