PageRenderTime 6ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/geometry/doc/src/examples/geometries/register/multi_linestring.cpp

http://hadesmem.googlecode.com/
C++ | 51 lines | 19 code | 13 blank | 19 comment | 0 complexity | a0877a5fae8b25d420077386d6746781 MD5 | raw file
 1// Boost.Geometry (aka GGL, Generic Geometry Library)
 2// QuickBook Example
 3
 4// Copyright (c) 2011 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/multi/geometries/register/multi_linestring.hpp>
19
20typedef boost::geometry::model::linestring
21    <
22        boost::tuple<float, float> 
23    > linestring_type;
24
25BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
26BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING(std::deque<linestring_type>)
27
28int 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/*`
46Output:
47[pre
48LENGTH: 2.82843
49]
50*/
51//]