]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/length_with_strategy.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
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)
10 //[length_with_strategy
11 //`The following example shows the length measured over a sphere, expressed in kilometers. To do that the radius of the sphere must be specified in the constructor of the strategy.
14 #include <boost/geometry.hpp>
15 #include <boost/geometry/geometries/linestring.hpp>
19 using namespace boost :: geometry
;
20 typedef model :: point
< float , 2 , cs :: spherical_equatorial
< degree
> > P
;
21 model :: linestring
< P
> line
;
22 line
. push_back ( P ( 2 , 41 ));
23 line
. push_back ( P ( 2 , 48 ));
24 line
. push_back ( P ( 5 , 52 ));
25 double const mean_radius
= 6371.0 ; /*< [@http://en.wikipedia.org/wiki/Earth_radius Wiki] >*/
26 std :: cout
<< "length is "
27 << length ( line
, strategy :: distance :: haversine
< float >( mean_radius
) )
28 << " kilometers " << std :: endl
;
36 //[length_with_strategy_output
40 length is 1272.03 kilometers