mirror of
https://github.com/boostorg/geometry.git
synced 2026-01-19 04:12:11 +00:00
fixed dissolve linestring->ring
[SVN r61039]
This commit is contained in:
@@ -145,6 +145,10 @@ struct dissolve<ring_tag, ring_tag, Ring, RingOut>
|
||||
(e.g. vector of "intersection/turn point"'s)
|
||||
\param geometry first geometry
|
||||
\param output container which will contain dissolved geometry
|
||||
\note Currently dissolve with a (multi)linestring does NOT remove internal
|
||||
overlap, it only tries to connect multiple line end-points.
|
||||
TODO: we should change this behaviour and add a separate "connect"
|
||||
algorithm, and let dissolve work like polygon.
|
||||
*/
|
||||
template
|
||||
<
|
||||
|
||||
@@ -108,19 +108,27 @@ struct dissolve_multi_linestring
|
||||
}
|
||||
|
||||
static inline map_iterator_type find_start(map_type const& map,
|
||||
std::map<int, bool>& included)
|
||||
std::map<int, bool>& included, int expected_count = 1)
|
||||
{
|
||||
for (map_iterator_type it = map.begin();
|
||||
it != map.end();
|
||||
++it)
|
||||
{
|
||||
int count = map.count(it->first);
|
||||
if (count == 1 && ! included[it->second.index])
|
||||
if (count == expected_count && ! included[it->second.index])
|
||||
{
|
||||
included[it->second.index] = true;
|
||||
return it;
|
||||
}
|
||||
}
|
||||
|
||||
// Not found with one point, try one with two points
|
||||
// to find rings
|
||||
if (expected_count == 1)
|
||||
{
|
||||
return find_start(map, included, 2);
|
||||
}
|
||||
|
||||
return map.end();
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,12 @@ void test_all()
|
||||
test_one<multi_linestring, linestring>("ls_simplex_two",
|
||||
"MULTILINESTRING((0 0,1 1),(1 1,2 2),(3 3,4 4),(4 4,5 5))",
|
||||
0, 6, 4 * std::sqrt(2.0));
|
||||
|
||||
// Linestrings forming a ring
|
||||
test_one<multi_linestring, linestring>("ls_simplex_ring",
|
||||
"MULTILINESTRING((0 0,0 1),(1 1,1 0),(0 1,1 1),(1 0,0 0))",
|
||||
0, 5, 4.0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user