Subject: [Boost-bugs] [Boost C++ Libraries] #10019: Difference of Linestring and Box returns their intersection
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-05-07 22:47:49
#10019: Difference of Linestring and Box returns their intersection
-----------------------------------------+---------------------------
Reporter: brandonesbox@⦠| Owner: barendgehrels
Type: Bugs | Status: new
Milestone: To Be Determined | Component: geometry
Version: Boost 1.55.0 | Severity: Problem
Keywords: difference, linestring, box |
-----------------------------------------+---------------------------
Taking the difference of a linestring and a box returns their
intersection. This is demonstrated by the program below:
---------------
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/multi/geometries/multi_linestring.hpp>
#include <boost/geometry/geometries/register/box.hpp>
#include <iostream>
namespace bg = boost::geometry;
int main()
{
typedef bg::model::point<double, 2, bg::cs::cartesian> Point;
typedef bg::model::linestring<Point> Linestring;
typedef bg::model::multi_linestring<Linestring> MultiLinestring;
typedef bg::model::box<Point> Box;
Linestring ls;
bg::read_wkt("LINESTRING (20 20, 20 45, 30 30, 50 50)", ls);
Point min_corner;
bg::read_wkt("POINT(25 25)", min_corner);
Point max_corner;
bg::read_wkt("POINT(42 42)", max_corner);
Box box(min_corner, max_corner);
MultiLinestring ml_diff;
bg::difference(ls, box, ml_diff);
std::cout << "line box difference: " << bg::wkt(ml_diff) << std::endl;
}
----------------
Which outputs
line box difference: MULTILINESTRING((25 37.5,30 30,42 42))
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10019> 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:16 UTC