| 98 | } |
| 99 | |
| 100 | std::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 | |
| 139 | std::unique_ptr<geos::geom::Geometry> |
| 140 | GeometryNoder::node(const geos::geom::Geometry& geometry, |