]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/intersection_ls_ls_point.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / algorithms / intersection_ls_ls_point.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // QuickBook Example
3
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
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)
9
10 //[intersection_ls_ls_point
11 //` Calculate the intersection of two linestrings
12
13 #include <iostream>
14 #include <deque>
15
16 #include <boost/geometry.hpp>
17 #include <boost/geometry/geometries/point_xy.hpp>
18 #include <boost/geometry/geometries/register/linestring.hpp>
19
20 #include <boost/foreach.hpp>
21
22 BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
23
24
25 int main()
26 {
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);
31
32 std::deque<P> intersection_points;
33 boost::geometry::intersection(line1, line2, intersection_points);
34
35 BOOST_FOREACH(P const& p, intersection_points)
36 {
37 std::cout << " " << boost::geometry::wkt(p);
38 }
39 std::cout << std::endl;
40
41 return 0;
42 }
43
44 //]
45
46
47 //[intersection_ls_ls_point_output
48 /*`
49 Output:
50 [pre
51 POINT(1.5 1.5) POINT(2.5 1.5)
52 ]
53 */
54 //]