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

Method get_noded

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

Source from the content-addressed store, hash-verified

98}
99
100std::unique_ptr<geos::geom::Geometry> GeometryNoder::get_noded()
101{
102 geos::noding::SegmentString::NonConstVect lines;
103 extract_segment_strings(m_geometry, lines);
104
105 geos::noding::Noder& noder = get_noder();
106 geos::noding::SegmentString::NonConstVect* noded_edges = nullptr;
107
108 try
109 {
110 noder.computeNodes(&lines);
111 noded_edges = noder.getNodedSubstrings();
112 //! @todo Is there a more specific exception I can catch?
113 } catch (const std::exception&)
114 {
115 for (size_t i = 0, n = lines.size(); i < n; ++i)
116 {
117 delete lines[i];
118 }
119 //! @todo what if I just return a nullptr?
120 throw;
121 }
122
123 std::unique_ptr<geos::geom::Geometry> noded = to_geometry(*noded_edges);
124
125 //! @todo Is there a way to do this automatically?
126 //! @todo Is there a way to avoid these allocations in the first place?
127 for (auto& edge : *noded_edges)
128 {
129 delete edge;
130 }
131 for (auto& line : lines)
132 {
133 delete line;
134 }
135
136 return noded;
137}
138
139std::unique_ptr<geos::geom::Geometry>
140GeometryNoder::node(const geos::geom::Geometry& geometry,

Callers 1

nodeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected