• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry
2 // QuickBook Example
3 
4 // Copyright (c) 2018, Oracle and/or its affiliates
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6 
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 
11 //[densify_strategy
12 //` Shows how to densify a linestring in geographic coordinate system
13 
14 #include <iostream>
15 
16 #include <boost/geometry.hpp>
17 #include <boost/geometry/geometries/point.hpp>
18 #include <boost/geometry/geometries/linestring.hpp>
19 
main()20 int main()
21 {
22     namespace bg = boost::geometry;
23     typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > point_type;
24     typedef bg::model::linestring<point_type> linestring_type;
25 
26     linestring_type ls;
27     bg::read_wkt("LINESTRING(0 0,1 1)", ls);
28 
29     linestring_type res;
30 
31     bg::srs::spheroid<double> spheroid(6378137.0, 6356752.3142451793);
32     bg::strategy::densify::geographic<> strategy(spheroid);
33 
34     boost::geometry::densify(ls, res, 50000.0, strategy);
35 
36     std::cout << "densified: " << boost::geometry::wkt(res) << std::endl;
37 
38     return 0;
39 }
40 
41 //]
42 
43 //[densify_strategy_output
44 /*`
45 Output:
46 [pre
47 densified: LINESTRING(0 0,0.249972 0.250011,0.499954 0.500017,0.749954 0.750013,1 1)
48 ]
49 */
50 //]
51