Files
geometry/doc/src/examples/algorithms/intersection_ls_ls_point.cpp
Barend Gehrels 26f5b75935 Small change in comment location
[SVN r70714]
2011-03-29 21:29:32 +00:00

53 lines
1.3 KiB
C++

// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example
// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//[intersection_ls_ls_point
//` Calculate the intersection of two linestrings
#include <iostream>
#include <deque>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
#include <boost/geometry/geometries/adapted/std_as_linestring.hpp> /*< Adapts std::vector to linestring concept >*/
#include <boost/foreach.hpp>
int main()
{
typedef boost::geometry::model::d2::point_xy<double> P;
std::vector<P> line1, line2;
boost::geometry::read_wkt("linestring(1 1,2 2,3 1)", line1);
boost::geometry::read_wkt("linestring(1 2,2 1,3 2)", line2);
std::deque<P> intersection_points;
boost::geometry::intersection(line1, line2, intersection_points);
BOOST_FOREACH(P const& p, intersection_points)
{
std::cout << " " << boost::geometry::wkt(p);
}
std::cout << std::endl;
return 0;
}
//]
//[intersection_ls_ls_point_output
/*`
Output:
[pre
POINT(1.5 1.5) POINT(2.5 1.5)
]
*/
//]