summaryrefslogtreecommitdiff
path: root/libs/geometry/doc/src/examples/geometries/adapted/boost_array.cpp
blob: 846c0be7bd95b3039e0f350122650bea993b934b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example

// Copyright (c) 2011-2012 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)

//[boost_array
//` Shows how to use a Boost.Array using Boost.Geometry's distance, set and assign_values algorithms

#include <iostream>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/adapted/boost_array.hpp>

BOOST_GEOMETRY_REGISTER_BOOST_ARRAY_CS(cs::cartesian)

int main()
{
    boost::array<float, 2> a = { {1, 2} };
    boost::array<double, 2> b = { {2, 3} };
    std::cout << boost::geometry::distance(a, b) << std::endl;
    
    boost::geometry::set<0>(a, 1.1);
    boost::geometry::set<1>(a, 2.2);
    std::cout << boost::geometry::distance(a, b) << std::endl;

    boost::geometry::assign_values(b, 2.2, 3.3);
    std::cout << boost::geometry::distance(a, b) << std::endl;
    
    boost::geometry::model::linestring<boost::array<double, 2> > line;
    line.push_back(b);

    return 0;
}

//]

//[boost_array_output
/*`
Output:
[pre
1.41421
1.20416
1.55563
]
*/
//]