]>
Commit | Line | Data |
---|---|---|
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_multi_linestring | |
11 | //` Show the use of the macro BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING | |
12 | ||
13 | #include <iostream> | |
14 | ||
15 | #include <boost/geometry.hpp> | |
16 | #include <boost/geometry/geometries/linestring.hpp> | |
17 | #include <boost/geometry/geometries/adapted/boost_tuple.hpp> | |
18 | #include <boost/geometry/geometries/register/multi_linestring.hpp> | |
19 | ||
20 | typedef boost::geometry::model::linestring | |
21 | < | |
22 | boost::tuple<float, float> | |
23 | > linestring_type; | |
24 | ||
25 | BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) | |
26 | BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING(std::deque<linestring_type>) | |
27 | ||
28 | int main() | |
29 | { | |
30 | // Normal usage of std:: | |
31 | std::deque<linestring_type> lines(2); | |
32 | boost::geometry::read_wkt("LINESTRING(0 0,1 1)", lines[0]); | |
33 | boost::geometry::read_wkt("LINESTRING(2 2,3 3)", lines[1]); | |
34 | ||
35 | // Usage of Boost.Geometry | |
36 | std::cout << "LENGTH: " << boost::geometry::length(lines) << std::endl; | |
37 | ||
38 | return 0; | |
39 | } | |
40 | ||
41 | //] | |
42 | ||
43 | ||
44 | //[register_multi_linestring_output | |
45 | /*` | |
46 | Output: | |
47 | [pre | |
48 | LENGTH: 2.82843 | |
49 | ] | |
50 | */ | |
51 | //] |