[Boost-bugs] [Boost C++ Libraries] #10835: difference of multilinestring and polygon yields wrong result

Subject: [Boost-bugs] [Boost C++ Libraries] #10835: difference of multilinestring and polygon yields wrong result
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-12-02 12:50:05


#10835: difference of multilinestring and polygon yields wrong result
-------------------------------------------------+-------------------------
 Reporter: Philipp Müller <pmueller@…> | Owner:
     Type: Bugs | barendgehrels
Milestone: To Be Determined | Status: new
  Version: Boost 1.57.0 | Component: geometry
 Keywords: geometry difference | Severity: Problem
  multi_linestring polygon |
-------------------------------------------------+-------------------------
 I am using the following typedefs to simplify reading:

 {{{
 typedef
 boost::geometry::model::point<int,2,boost::geometry::cs::cartesian>
 TPoint;
 typedef boost::geometry::model::linestring<TPoint> TLinestring;
 typedef boost::geometry::model::multi_linestring<TLinestring>
 TMultiLinestring;
 typedef boost::geometry::model::polygon<TPoint, /*ClockWise*/false,
 /*Closed*/false> TPolygon;
 }}}

 I have a multilinestring from which I want to subtract two polygons.
 The multilinestring and polygons are as follows

 {{{
 TMultiLinestring multilinestring;
 boost::geometry::read_wkt("MULTILINESTRING((5239 2113,1020 2986))",
 multilinestring);
 TPolygon polygon1;
 boost::geometry::read_wkt("POLYGON((5233 2113,5200 2205,1020 2205,1020
 2022,5200 2022))", polygon1);
 TPolygon polygon2;
 boost::geometry::read_wkt("POLYGON((5233 2986,5200 3078,1020 3078,1020
 2895,5200 2895))", polygon2);
 }}}

 First, I subtract polygon1 from multilinestring, which works fine:

 {{{
 TMultiLinestring multilinestringOut1;
 boost::geometry::difference(multilinestring, polygon1,
 multilinestringOut1);
 // works as expected: multilinestringOut1 holds MULTILINESTRING((5239
 2113,5233 2114)(4795 2205, 1020 2986))
 }}}

 Now I want to subtract polygon2 from multilinestringOut1 (the intermediate
 result from the previous calculation), which yields a wrong result.


 {{{
 TMultiLinestring multilinestringOut2;
 boost::geometry::difference(multilinestringOut1, polygon2,
 multilinestringOut2);
 // not as expected: multilinestringOut2 holds MULTILINESTRING((5239
 2113,5233,2114)(4795 2205, 5406 1580))
 }}}

 I would expect multilinestringOut2 to hold

 {{{
 MULTILINESTRING((5239 2113,5233,2114)(4795 2205, 1460 2895))
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10835>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC