]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/intersection_ls_ls_point.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 //[intersection_ls_ls_point
11 //` Calculate the intersection of two linestrings
16 #include <boost/geometry.hpp>
17 #include <boost/geometry/geometries/point_xy.hpp>
18 #include <boost/geometry/geometries/register/linestring.hpp>
20 #include <boost/foreach.hpp>
22 BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector
)
27 typedef boost::geometry::model::d2::point_xy
<double> P
;
28 std::vector
<P
> line1
, line2
;
29 boost::geometry::read_wkt("linestring(1 1,2 2,3 1)", line1
);
30 boost::geometry::read_wkt("linestring(1 2,2 1,3 2)", line2
);
32 std::deque
<P
> intersection_points
;
33 boost::geometry::intersection(line1
, line2
, intersection_points
);
35 BOOST_FOREACH(P
const& p
, intersection_points
)
37 std::cout
<< " " << boost::geometry::wkt(p
);
39 std::cout
<< std::endl
;
47 //[intersection_ls_ls_point_output
51 POINT(1.5 1.5) POINT(2.5 1.5)