MCPcopy Create free account
hub / github.com/Notgnoshi/generative / build

Method build

generative/noding/geometry-graph.cpp:107–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107void GeometryGraph::build(const geos::geom::Geometry& geometry)
108{
109 m_nodes.reserve(geometry.getNumPoints());
110
111 // Need to look up a node's ID by it's coordinates, if it exists.
112 GeometryGraph::Nodes_t inserted_coords;
113
114 for (const auto& geom : generative::GeometryFlattener(geometry))
115 {
116 const auto coords = geom.getCoordinates();
117 if (coords->size() == 1)
118 {
119 find_or_insert(inserted_coords, coords->front());
120 } else
121 {
122 for (std::size_t i = 0, j = 1; j < coords->size(); i = j++)
123 {
124 const auto& curr = coords->getAt(i);
125 const auto& next = coords->getAt(j);
126
127 LOG4CPLUS_TRACE(s_logger,
128 "new edge " << curr.toString() << " -> " << next.toString());
129
130 // Add, or lookup the nodes in the graph.
131 auto& curr_node = find_or_insert(inserted_coords, curr);
132 auto& next_node = find_or_insert(inserted_coords, next);
133
134 add_edge(curr_node.index, next_node.index);
135 }
136 }
137 }
138}
139} // namespace generative::noding

Callers 4

mainFunction · 0.80
build_expressionFunction · 0.80

Calls 1

GeometryFlattenerClass · 0.50

Tested by

no test coverage detected