Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61039 - in sandbox/geometry: boost/geometry/algorithms boost/geometry/multi/algorithms libs/geometry/test/multi/algorithms
From: barend.gehrels_at_[hidden]
Date: 2010-04-04 08:29:36


Author: barendgehrels
Date: 2010-04-04 08:29:35 EDT (Sun, 04 Apr 2010)
New Revision: 61039
URL: http://svn.boost.org/trac/boost/changeset/61039

Log:
fixed dissolve linestring->ring
Text files modified:
   sandbox/geometry/boost/geometry/algorithms/dissolve.hpp | 4 ++++
   sandbox/geometry/boost/geometry/multi/algorithms/dissolve.hpp | 12 ++++++++++--
   sandbox/geometry/libs/geometry/test/multi/algorithms/multi_dissolve.cpp | 6 ++++++
   3 files changed, 20 insertions(+), 2 deletions(-)

Modified: sandbox/geometry/boost/geometry/algorithms/dissolve.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/dissolve.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/dissolve.hpp 2010-04-04 08:29:35 EDT (Sun, 04 Apr 2010)
@@ -145,6 +145,10 @@
         (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
 <

Modified: sandbox/geometry/boost/geometry/multi/algorithms/dissolve.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/multi/algorithms/dissolve.hpp (original)
+++ sandbox/geometry/boost/geometry/multi/algorithms/dissolve.hpp 2010-04-04 08:29:35 EDT (Sun, 04 Apr 2010)
@@ -108,19 +108,27 @@
     }
 
     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();
     }
 

Modified: sandbox/geometry/libs/geometry/test/multi/algorithms/multi_dissolve.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/multi/algorithms/multi_dissolve.cpp (original)
+++ sandbox/geometry/libs/geometry/test/multi/algorithms/multi_dissolve.cpp 2010-04-04 08:29:35 EDT (Sun, 04 Apr 2010)
@@ -78,6 +78,12 @@
     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);
+
 }
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk