]>
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 | //[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. | |
12 | ||
13 | #include <iostream> | |
14 | #include <boost/geometry.hpp> | |
15 | #include <boost/geometry/geometries/linestring.hpp> | |
16 | ||
17 | int main() | |
18 | { | |
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; | |
29 | ||
30 | return 0; | |
31 | } | |
32 | ||
33 | //] | |
34 | ||
35 | ||
36 | //[length_with_strategy_output | |
37 | /*` | |
38 | Output: | |
39 | [pre | |
40 | length is 1272.03 kilometers | |
41 | ] | |
42 | */ | |
43 | //] |