• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry
2 // QuickBook Example
3 
4 // Copyright (c) 2019 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 //[buffer_geographic_point_circle
11 //` Shows how the point_circle strategy, for the Earth, can be used as a PointStrategy to create circular buffers around points
12 
13 #include <boost/geometry.hpp>
14 #include <iostream>
15 
main()16 int main()
17 {
18     namespace bg = boost::geometry;
19 
20     typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > point;
21 
22     // Declare the geographic_point_circle strategy (with 36 points)
23     // Default template arguments (taking Andoyer strategy)
24     bg::strategy::buffer::geographic_point_circle<> point_strategy(36);
25 
26     // Declare the distance strategy (one kilometer, around the point, on Earth)
27     bg::strategy::buffer::distance_symmetric<double> distance_strategy(1000.0);
28 
29     // Declare other necessary strategies, unused for point
30     bg::strategy::buffer::join_round join_strategy;
31     bg::strategy::buffer::end_round end_strategy;
32     bg::strategy::buffer::side_straight side_strategy;
33 
34     // Declare/fill a point on Earth, near Amsterdam
35     point p;
36     bg::read_wkt("POINT(4.9 52.1)", p);
37 
38     // Create the buffer of a point on the Earth
39     bg::model::multi_polygon<bg::model::polygon<point> > result;
40     bg::buffer(p, result,
41                 distance_strategy, side_strategy,
42                 join_strategy, end_strategy, point_strategy);
43 
44     std::cout << "Area: " << bg::area(result) / (1000 * 1000) << " square kilometer" << std::endl;
45 
46     return 0;
47 }
48 
49 //]
50 
51 //[buffer_geographic_point_circle_output
52 /*`
53 Output:
54 [pre
55 Area: 3.12542 square kilometer
56 ]
57 */
58 //]
59