]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/doc/src/examples/geometries/register/linestring_templated.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / geometries / register / linestring_templated.cpp
CommitLineData
7c673cae
FG
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//[register_linestring_templated
11//` Show the use of the macro BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED
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// Adapt any deque to Boost.Geometry Linestring Concept
21BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque)
22
23int main()
24{
25 std::deque<boost::geometry::model::d2::point_xy<double> > line(2);
26 boost::geometry::assign_values(line[0], 1, 1);
27 boost::geometry::assign_values(line[1], 2, 2);
28
29 // Boost.Geometry algorithms work on any deque now
30 std::cout << "Length: " << boost::geometry::length(line) << std::endl;
31 std::cout << "Line: " << boost::geometry::dsv(line) << std::endl;
32
33 return 0;
34}
35
36//]
37
38
39//[register_linestring_templated_output
40/*`
41Output:
42[pre
43Length: 1.41421
44Line: ((1, 1), (2, 2))
45]
46*/
47//]