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

Method to_geometry

generative/noding/geometry-noder.cpp:172–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172std::unique_ptr<geos::geom::Geometry>
173GeometryNoder::to_geometry(geos::noding::SegmentString::NonConstVect& noded_edges)
174{
175 const auto* geom_factory = m_geometry.getFactory();
176 std::set<geos::noding::OrientedCoordinateArray> ocas;
177
178 std::vector<std::unique_ptr<geos::geom::Geometry>> lines;
179 lines.reserve(noded_edges.size());
180 for (auto& ss : noded_edges)
181 {
182 auto* coords = ss->getCoordinates();
183
184 // Check if an equivalent edge is known
185 geos::noding::OrientedCoordinateArray oca(*coords);
186 // NOTE: Each coordinate sequence is expected to be exactly two coordinates.
187 if (ocas.insert(oca).second)
188 {
189 if (coords->front() == coords->back())
190 {
191 lines.push_back(geom_factory->createPoint(coords->front()));
192 } else
193 {
194 lines.push_back(geom_factory->createLineString(coords->clone()));
195 }
196 }
197 }
198
199 return geom_factory->createGeometryCollection(std::move(lines));
200}
201
202} // namespace generative::noding

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected