feat: add cmake support to examples

- replace BOOST_FOREACH

- replace Boost.Assign

- replace typedef with using

- other minor changes
This commit is contained in:
Barend Gehrels 2024-09-26 22:13:00 +02:00
parent 966567ff2e
commit 38adce676e
144 changed files with 671 additions and 564 deletions

View File

@ -0,0 +1,40 @@
# Boost.Geometry
# Copyright (c) 2024 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)
function(boost_geometry_add_example prefix item)
set(example_name "boost_geometry_example_${prefix}_${item}")
add_executable(${example_name} ${item}.cpp)
# Add a dependency to Boost.Geometry
target_link_libraries(${example_name}
PRIVATE
Boost::geometry
)
# Include the main Geometry test folder and the current folder
target_include_directories(${example_name}
PRIVATE
.)
# To compile with C++14
target_compile_features(${example_name} PRIVATE cxx_std_14)
endfunction()
foreach(item IN ITEMS
quick_start
)
boost_geometry_add_example("example" ${item})
endforeach()
add_subdirectory(algorithms)
add_subdirectory(core)
add_subdirectory(geometries)
add_subdirectory(io)
add_subdirectory(strategies)
add_subdirectory(views)

View File

@ -0,0 +1,73 @@
# Boost.Geometry
# Copyright (c) 2024 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)
foreach(item IN ITEMS
append
area
area_with_strategy
assign
assign_2d_point
assign_3d_point
assign_inverse
assign_points
buffer_with_strategies
centroid
clear
closest_points
closest_points_strategy
comparable_distance
convert
convex_hull
correct
densify
densify_strategy
discrete_frechet_distance
discrete_frechet_distance_strategy
discrete_hausdorff_distance
discrete_hausdorff_distance_strategy
difference
distance
envelope
equals
expand
for_each_point
for_each_point_const
for_each_segment_const
intersection_ls_ls_point
intersection_segment
intersects_linestring
is_simple
is_valid
is_valid_failure
is_valid_message
length
length_with_strategy
line_interpolate
line_interpolate_strategy
make_2d_point
make_3d_point
make_inverse
num_geometries
num_interior_rings
num_points
num_segments
return_envelope
relate
relation
reverse
simplify
sym_difference
transform
transform_with_strategy
union
unique
within
)
boost_geometry_add_example("algorithms" ${item})
endforeach()

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -16,32 +16,30 @@
#include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp> #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#include <boost/assign.hpp> /*< At the end to avoid conflicts with Boost.QVM >*/
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
int main() int main()
{ {
using boost::assign::tuple_list_of;
using boost::make_tuple;
using boost::geometry::append; using boost::geometry::append;
typedef boost::geometry::model::polygon<boost::tuple<int, int> > polygon; using vector = std::vector<boost::tuple<int, int>>;
using polygon = boost::geometry::model::polygon<boost::tuple<int, int>>;
polygon poly; polygon poly;
// Append a range // Append a range
append(poly, tuple_list_of(0, 0)(0, 10)(11, 11)(10, 0)); /*< tuple_list_of delivers a range and can therefore be used in boost::geometry::append >*/ append(poly, vector{{0.0, 0.0}, {0.0, 10.0}, {11.0, 11.0}, {10.0, 0.0}}); /*< vector models a range and can therefore be used in boost::geometry::append >*/
// Append a point (in this case the closing point) // Append a point (in this case the closing point)
append(poly, make_tuple(0, 0)); append(poly, boost::make_tuple(0, 0));
// Create an interior ring (append does not do this automatically) // Create an interior ring (append does not do this automatically)
boost::geometry::interior_rings(poly).resize(1); boost::geometry::interior_rings(poly).resize(1);
// Append a range to the interior ring // Append a range to the interior ring
append(poly, tuple_list_of(2, 2)(2, 5)(6, 6)(5, 2), 0); /*< The last parameter ring_index 0 denotes the first interior ring >*/ append(poly, vector{{2, 2}, {2, 5}, {6, 6}, {5, 2}}, 0); /*< The last parameter ring_index 0 denotes the first interior ring >*/
// Append a point to the first interior ring // Append a point to the first interior ring
append(poly, make_tuple(2, 2), 0); append(poly, boost::make_tuple(2, 2), 0);
std::cout << boost::geometry::dsv(poly) << std::endl; std::cout << boost::geometry::dsv(poly) << std::endl;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -22,9 +22,9 @@ BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point; using point = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::box<point> box; using box = boost::geometry::model::box<point>;
typedef boost::geometry::model::polygon<point> polygon; using polygon = boost::geometry::model::polygon<point>;
point p1; point p1;
box b; box b;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -20,8 +20,8 @@ using namespace boost::geometry;
int main() int main()
{ {
typedef model::d2::point_xy<double> point; using point = model::d2::point_xy<double>;
typedef model::box<point> box; using box = model::box<point>;
box b; box b;
assign_values(b, 2, 2, 5, 5); assign_values(b, 2, 2, 5, 5);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -20,8 +20,8 @@ using namespace boost::geometry;
int main() int main()
{ {
typedef model::point<float, 3, cs::cartesian> point; using point = model::point<float, 3, cs::cartesian>;
typedef model::box<point> box; using box = model::box<point>;
box all; box all;
assign_inverse(all); assign_inverse(all);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -20,8 +20,8 @@ using namespace boost::geometry;
int main() int main()
{ {
typedef model::d2::point_xy<double> point; using point = model::d2::point_xy<double>;
typedef model::segment<point> segment; using segment = model::segment<point>;
segment s; segment s;
assign_values(s, 1, 1, 2, 2); assign_values(s, 1, 1, 2, 2);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -20,8 +20,8 @@ using namespace boost::geometry;
int main() int main()
{ {
typedef model::d2::point_xy<int> point; using point = model::d2::point_xy<int>;
typedef model::box<point> box; using box = model::box<point>;
point lower_left(0, 0), upper_right(2, 2); point lower_left(0, 0), upper_right(2, 2);

View File

@ -1,14 +1,14 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
//[assign_points //[assign_points
//` Shows usage of Boost.Geometry's assign, Boost.Assign, and Boost.Range to assign ranges of a linestring //` Shows usage of Boost.Geometry's assign, and Boost.Range to assign ranges of a linestring
#include <iostream> #include <iostream>
@ -16,7 +16,6 @@
#include <boost/geometry/geometries/linestring.hpp> #include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp> #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#include <boost/assign.hpp>
#include <boost/geometry/geometries/adapted/boost_range/filtered.hpp> #include <boost/geometry/geometries/adapted/boost_range/filtered.hpp>
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
@ -41,14 +40,12 @@ private :
int main() int main()
{ {
using namespace boost::assign; using ls = boost::geometry::model::linestring<boost::tuple<int, int>>;
typedef boost::geometry::model::linestring<boost::tuple<int, int> > ls;
ls line1, line2, line3; ls line1, line2, line3;
line1 = tuple_list_of(0, 0)(2, 3)(4, 0)(6, 3)(8, 0)(10, 3)(12, 0); /*< tuple_list_of is part of Boost.Assign and can be used for Boost.Geometry if points are tuples >*/ line1 = {{0, 0}, {2, 3}, {4, 0}, {6, 3}, {8, 0}, {10, 3}, {12, 0}};
boost::geometry::assign_points(line2, tuple_list_of(0, 0)(2, 2)(4, 0)(6, 2)(8, 0)); /*< tuple_list_of delivers a range and can therefore be used in boost::geometry::assign >*/ boost::geometry::assign_points(line2, ls({{0, 0}, {2, 2}, {4, 0}, {6, 2}, {8, 0}}));
boost::geometry::assign_points(line3, line1 | boost::adaptors::filtered(x_between<int>(4, 8))); /*< Boost.Range adaptors can also be used in boost::geometry::assign >*/ boost::geometry::assign_points(line3, line1 | boost::adaptors::filtered(x_between<int>(4, 8))); /*< Boost.Range adaptors can also be used in boost::geometry::assign >*/
std::cout << "line 1: " << boost::geometry::dsv(line1) << std::endl; std::cout << "line 1: " << boost::geometry::dsv(line1) << std::endl;

View File

@ -18,7 +18,7 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
point_type p1(0, 0); point_type p1(0, 0);
point_type p2(1, 1); point_type p2(1, 1);

View File

@ -19,7 +19,7 @@
int main() int main()
{ {
namespace bg = boost::geometry; namespace bg = boost::geometry;
typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > point_type; using point_type = bg::model::point<double, 2, bg::cs::geographic<bg::degree>>;
point_type p1(0, 0); point_type p1(0, 0);
point_type p2(1, 1); point_type p2(1, 1);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2013, 2014 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2013, 2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,9 +17,9 @@
int main() int main()
{ {
typedef double coordinate_type; using coordinate_type = double;
typedef boost::geometry::model::d2::point_xy<coordinate_type> point; using point = boost::geometry::model::d2::point_xy<coordinate_type>;
typedef boost::geometry::model::polygon<point> polygon; using polygon = boost::geometry::model::polygon<point>;
// Declare strategies // Declare strategies
const double buffer_distance = 1.0; const double buffer_distance = 1.0;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -20,8 +20,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
polygon_type poly; polygon_type poly;
boost::geometry::read_wkt( boost::geometry::read_wkt(

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -19,28 +19,21 @@
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
#include <boost/assign.hpp>
int main() int main()
{ {
using boost::assign::tuple_list_of; using point = boost::tuple<float, float>;
using polygon = boost::geometry::model::polygon<point>;
using ring = boost::geometry::model::ring<point>;
typedef boost::tuple<float, float> point; // Create a square as exterior ring, with a triangle as interior ring
typedef boost::geometry::model::polygon<point> polygon; polygon poly{{{0, 0}, {0, 10}, {10, 10}, {10, 0}, {0, 0}}, {{{1, 2}, {8, 2}, {4, 6}, {1, 2}}}};
typedef boost::geometry::model::ring<point> ring;
polygon poly;
// Fill the polygon (using its own methods + Boost.Assign)
poly.outer() = tuple_list_of(0, 0)(0, 9)(10, 10)(0, 0);
poly.inners().push_back(tuple_list_of(1, 2)(4, 6)(2, 8)(1, 2));
std::cout << boost::geometry::dsv(poly) << std::endl; std::cout << boost::geometry::dsv(poly) << std::endl;
boost::geometry::clear(poly); boost::geometry::clear(poly);
std::cout << boost::geometry::dsv(poly) << std::endl; std::cout << boost::geometry::dsv(poly) << std::endl;
// Create a ring using Boost.Assign // Create a triangle
ring r = tuple_list_of(0, 0)(0, 9)(8, 8)(0, 0); ring r{{0, 0}, {0, 9}, {8, 8}, {0, 0}};
std::cout << boost::geometry::dsv(r) << std::endl; std::cout << boost::geometry::dsv(r) << std::endl;
boost::geometry::clear(r); boost::geometry::clear(r);
@ -56,7 +49,7 @@ int main()
/*` /*`
Output: Output:
[pre [pre
(((0, 0), (0, 10), (11, 11), (0, 0)), ((0, 0), (0, 10), (11, 11), (0, 0))) (((0, 0), (0, 10), (10, 10), (10, 0), (0, 0)), ((1, 2), (8, 2), (4, 6), (1, 2)))
(()) (())
((0, 0), (0, 9), (8, 8), (0, 0)) ((0, 0), (0, 9), (8, 8), (0, 0))
() ()

View File

@ -23,10 +23,10 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
typedef boost::geometry::model::linestring<point_type> linestring_type; using linestring_type = boost::geometry::model::linestring<point_type>;
typedef boost::geometry::model::multi_point<point_type> multi_point_type; using multi_point_type = boost::geometry::model::multi_point<point_type>;
point_type p(4.3,1.9); point_type p(4.3,1.9);
point_type p0(0,0); point_type p0(0,0);

View File

@ -21,14 +21,14 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy using point_type = boost::geometry::model::d2::point_xy
< <
double, double,
boost::geometry::cs::geographic<boost::geometry::degree> boost::geometry::cs::geographic<boost::geometry::degree>
> point_type; >;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
typedef boost::geometry::model::linestring<point_type> linestring_type; using linestring_type = boost::geometry::model::linestring<point_type>;
typedef boost::geometry::model::multi_point<point_type> multi_point_type; using multi_point_type = boost::geometry::model::multi_point<point_type>;
point_type p(4.3,1.9); point_type p(4.3,1.9);
polygon_type poly; polygon_type poly;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -16,11 +16,10 @@
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/numeric/conversion/bounds.hpp> #include <boost/numeric/conversion/bounds.hpp>
#include <boost/foreach.hpp>
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
point_type p(1.4, 2.6); point_type p(1.4, 2.6);
@ -35,7 +34,7 @@ int main()
point_type min_p; point_type min_p;
double min_d = boost::numeric::bounds<double>::highest(); double min_d = boost::numeric::bounds<double>::highest();
BOOST_FOREACH(point_type const& pv, v) for (point_type const& pv : v)
{ {
double d = boost::geometry::comparable_distance(p, pv); double d = boost::geometry::comparable_distance(p, pv);
if (d < min_d) if (d < min_d)

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -22,9 +22,9 @@ BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point; using point = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::box<point> box; using box = boost::geometry::model::box<point>;
typedef boost::geometry::model::polygon<point> polygon; using polygon = boost::geometry::model::polygon<point>;
point p1(1, 1); point p1(1, 1);
box bx = boost::geometry::make<box>(1, 1, 2, 2); box bx = boost::geometry::make<box>(1, 1, 2, 2);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -21,8 +21,8 @@ BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
/*<-*/ #include "create_svg_two.hpp" /*->*/ /*<-*/ #include "create_svg_two.hpp" /*->*/
int main() int main()
{ {
typedef boost::tuple<double, double> point; using point = boost::tuple<double, double>;
typedef boost::geometry::model::polygon<point> polygon; using polygon = boost::geometry::model::polygon<point>;
polygon poly; polygon poly;
boost::geometry::read_wkt("polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0" boost::geometry::read_wkt("polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0"

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -18,38 +18,37 @@
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
#include <boost/assign.hpp>
int main() int main()
{ {
using boost::assign::tuple_list_of; using clockwise_closed_polygon = boost::geometry::model::polygon
typedef boost::geometry::model::polygon
< <
boost::tuple<int, int> boost::tuple<int, int>
> clockwise_closed_polygon; >;
clockwise_closed_polygon cwcp; clockwise_closed_polygon cwcp;
// Fill it counterclockwise (so wrongly), forgetting the closing point // Fill it counterclockwise (so wrongly), forgetting the closing point
boost::geometry::exterior_ring(cwcp) = tuple_list_of(0, 0)(10, 10)(0, 9); boost::geometry::exterior_ring(cwcp) = {{0, 0}, {10, 10}, {0, 9}};
// Add a counterclockwise closed inner ring (this is correct) // Add a counterclockwise closed inner ring (this is correct)
boost::geometry::interior_rings(cwcp).push_back(tuple_list_of(1, 2)(4, 6)(2, 8)(1, 2)); boost::geometry::interior_rings(cwcp).push_back({{1, 2}, {4, 6}, {2, 8}, {1, 2}});
// Its area should be negative (because of wrong orientation) // Its area should be negative (because of wrong orientation)
// and wrong (because of omitted closing point) // and wrong (because of omitted closing point)
double area_before = boost::geometry::area(cwcp); const auto area_before = boost::geometry::area(cwcp);
const auto count_before = boost::geometry::num_points(cwcp);
// Correct it! // Correct it!
boost::geometry::correct(cwcp); boost::geometry::correct(cwcp);
// Check its new area // Check its new area
double area_after = boost::geometry::area(cwcp); const auto area_after = boost::geometry::area(cwcp);
const auto count_after = boost::geometry::num_points(cwcp);
// And output it // And output it
std::cout << boost::geometry::dsv(cwcp) << std::endl; std::cout << boost::geometry::dsv(cwcp) << std::endl;
std::cout << area_before << " -> " << area_after << std::endl; std::cout << area_before << " -> " << area_after << std::endl;
std::cout << count_before << " -> " << count_after << std::endl;
return 0; return 0;
} }
@ -63,6 +62,7 @@ Output:
[pre [pre
(((0, 0), (0, 9), (10, 10), (0, 0)), ((1, 2), (4, 6), (2, 8), (1, 2))) (((0, 0), (0, 9), (10, 10), (0, 0)), ((1, 2), (4, 6), (2, 8), (1, 2)))
-7 -> 38 -7 -> 38
7 -> 8
] ]
*/ */
//] //]

View File

@ -1,6 +1,6 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2011-2014 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2014. // This file was modified by Oracle on 2014.
// Modifications copyright (c) 2014, Oracle and/or its affiliates. // Modifications copyright (c) 2014, Oracle and/or its affiliates.
@ -29,7 +29,7 @@ void create_svg(std::string const& filename, Geometry const& g)
#if defined(HAVE_SVG) #if defined(HAVE_SVG)
std::cout << std::endl << "[$img/algorithms/" << boost::replace_all_copy(filename, ".svg", ".png") << "]" << std::endl << std::endl; std::cout << std::endl << "[$img/algorithms/" << boost::replace_all_copy(filename, ".svg", ".png") << "]" << std::endl << std::endl;
typedef typename boost::geometry::point_type<Geometry>::type point_type; using point_type = typename boost::geometry::point_type<Geometry>::type;
std::ofstream svg(filename.c_str()); std::ofstream svg(filename.c_str());
boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400); boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400);

View File

@ -1,6 +1,6 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -13,7 +13,6 @@
#include <fstream> #include <fstream>
#include <boost/foreach.hpp>
#include <boost/core/ignore_unused.hpp> #include <boost/core/ignore_unused.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
@ -27,7 +26,7 @@ void create_svg(std::string const& filename, Geometry const& a, Geometry const&
#if defined(HAVE_SVG) #if defined(HAVE_SVG)
std::cout << std::endl << "[$img/algorithms/" << boost::replace_all_copy(filename, ".svg", ".png") << "]" << std::endl << std::endl; std::cout << std::endl << "[$img/algorithms/" << boost::replace_all_copy(filename, ".svg", ".png") << "]" << std::endl << std::endl;
typedef typename boost::geometry::point_type<Geometry>::type point_type; using point_type = typename boost::geometry::point_type<Geometry>::type;
std::ofstream svg(filename.c_str()); std::ofstream svg(filename.c_str());
boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400); boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400);
@ -37,7 +36,7 @@ void create_svg(std::string const& filename, Geometry const& a, Geometry const&
mapper.map(a, "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:2"); mapper.map(a, "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:2");
mapper.map(b, "fill-opacity:0.3;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:2"); mapper.map(b, "fill-opacity:0.3;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:2");
int i = 0; int i = 0;
BOOST_FOREACH(typename boost::range_value<Range>::type const& g, range) for (typename boost::range_value<Range>::type const& g : range)
{ {
mapper.map(g, "opacity:0.8;fill:none;stroke:rgb(255,128,0);stroke-width:4;stroke-dasharray:1,7;stroke-linecap:round"); mapper.map(g, "opacity:0.8;fill:none;stroke:rgb(255,128,0);stroke-width:4;stroke-dasharray:1,7;stroke-linecap:round");
std::ostringstream out; std::ostringstream out;

View File

@ -1,6 +1,6 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -24,7 +24,7 @@ void create_svg(std::string const& filename, Geometry1 const& a, Geometry2 const
#if defined(HAVE_SVG) #if defined(HAVE_SVG)
std::cout << std::endl << "[$img/algorithms/" << boost::replace_all_copy(filename, ".svg", ".png") << "]" << std::endl << std::endl; std::cout << std::endl << "[$img/algorithms/" << boost::replace_all_copy(filename, ".svg", ".png") << "]" << std::endl << std::endl;
typedef typename boost::geometry::point_type<Geometry1>::type point_type; using point_type = typename boost::geometry::point_type<Geometry1>::type;
std::ofstream svg(filename.c_str()); std::ofstream svg(filename.c_str());
boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400); boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400);

View File

@ -19,8 +19,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
polygon_type poly; polygon_type poly;
boost::geometry::read_wkt( boost::geometry::read_wkt(

View File

@ -20,8 +20,8 @@
int main() int main()
{ {
namespace bg = boost::geometry; namespace bg = boost::geometry;
typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > point_type; using point_type = bg::model::point<double, 2, bg::cs::geographic<bg::degree>>;
typedef bg::model::linestring<point_type> linestring_type; using linestring_type = bg::model::linestring<point_type>;
linestring_type ls; linestring_type ls;
bg::read_wkt("LINESTRING(0 0,1 1)", ls); bg::read_wkt("LINESTRING(0 0,1 1)", ls);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -16,13 +16,11 @@
#include <boost/geometry.hpp> #include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/geometries/polygon.hpp>
#include <boost/foreach.hpp>
/*<-*/ #include "create_svg_overlay.hpp" /*->*/ /*<-*/ #include "create_svg_overlay.hpp" /*->*/
int main() int main()
{ {
typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon; using polygon = boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>>;
polygon green, blue; polygon green, blue;
@ -38,7 +36,7 @@ int main()
int i = 0; int i = 0;
std::cout << "green - blue:" << std::endl; std::cout << "green - blue:" << std::endl;
BOOST_FOREACH(polygon const& p, output) for (polygon const& p : output)
{ {
std::cout << i++ << ": " << boost::geometry::area(p) << std::endl; std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
} }
@ -49,7 +47,7 @@ int main()
i = 0; i = 0;
std::cout << "blue - green:" << std::endl; std::cout << "blue - green:" << std::endl;
BOOST_FOREACH(polygon const& p, output) for (polygon const& p : output)
{ {
std::cout << i++ << ": " << boost::geometry::area(p) << std::endl; std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,12 +17,11 @@
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/geometries/polygon.hpp>
#include <boost/foreach.hpp>
/*<-*/ #include "create_svg_overlay.hpp" /*->*/ /*<-*/ #include "create_svg_overlay.hpp" /*->*/
int main() int main()
{ {
typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon; using polygon = boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>>;
polygon green, blue; polygon green, blue;
@ -51,7 +50,7 @@ int main()
int i = 0; int i = 0;
std::cout << "(blue \ green) u (green \ blue):" << std::endl; std::cout << "(blue \ green) u (green \ blue):" << std::endl;
BOOST_FOREACH(polygon const& p, output) for (polygon const& p : output)
{ {
std::cout << i++ << ": " << boost::geometry::area(p) << std::endl; std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
} }

View File

@ -17,8 +17,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::linestring<point_type> linestring_type; using linestring_type = boost::geometry::model::linestring<point_type>;
linestring_type ls1, ls2; linestring_type ls1, ls2;
boost::geometry::read_wkt("LINESTRING(0 0,1 1,1 2,2 1,2 2)", ls1); boost::geometry::read_wkt("LINESTRING(0 0,1 1,1 2,2 1,2 2)", ls1);

View File

@ -18,8 +18,8 @@
int main() int main()
{ {
namespace bg = boost::geometry; namespace bg = boost::geometry;
typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > point_type; using point_type = bg::model::point<double, 2, bg::cs::geographic<bg::degree>>;
typedef bg::model::linestring<point_type> linestring_type; using linestring_type = bg::model::linestring<point_type>;
linestring_type ls1, ls2; linestring_type ls1, ls2;
bg::read_wkt("LINESTRING(0 0,1 1,1 2,2 1,2 2)", ls1); bg::read_wkt("LINESTRING(0 0,1 1,1 2,2 1,2 2)", ls1);

View File

@ -17,8 +17,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::linestring<point_type> linestring_type; using linestring_type = boost::geometry::model::linestring<point_type>;
linestring_type ls1, ls2; linestring_type ls1, ls2;
boost::geometry::read_wkt("LINESTRING(0 0,1 1,1 2,2 1,2 2)", ls1); boost::geometry::read_wkt("LINESTRING(0 0,1 1,1 2,2 1,2 2)", ls1);

View File

@ -18,8 +18,8 @@
int main() int main()
{ {
namespace bg = boost::geometry; namespace bg = boost::geometry;
typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > point_type; using point_type = bg::model::point<double, 2, bg::cs::geographic<bg::degree>>;
typedef bg::model::linestring<point_type> linestring_type; using linestring_type = bg::model::linestring<point_type>;
linestring_type ls1, ls2; linestring_type ls1, ls2;
bg::read_wkt("LINESTRING(0 0,1 1,1 2,2 1,2 2)", ls1); bg::read_wkt("LINESTRING(0 0,1 1,1 2,2 1,2 2)", ls1);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -20,14 +20,12 @@
#include <boost/geometry/geometries/multi_point.hpp> #include <boost/geometry/geometries/multi_point.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp> #include <boost/geometry/geometries/multi_polygon.hpp>
#include <boost/foreach.hpp>
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
typedef boost::geometry::model::linestring<point_type> linestring_type; using linestring_type = boost::geometry::model::linestring<point_type>;
typedef boost::geometry::model::multi_point<point_type> multi_point_type; using multi_point_type = boost::geometry::model::multi_point<point_type>;
point_type p(1,2); point_type p(1,2);
polygon_type poly; polygon_type poly;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -20,7 +20,7 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point; using point = boost::geometry::model::d2::point_xy<double>;
boost::geometry::model::polygon<point> polygon; boost::geometry::model::polygon<point> polygon;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -18,17 +18,13 @@
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
#include <boost/assign.hpp>
int main() int main()
{ {
using boost::assign::tuple_list_of; using point = boost::tuple<int, int>;
typedef boost::tuple<int, int> point;
boost::geometry::model::polygon<point> poly1, poly2; boost::geometry::model::polygon<point> poly1, poly2;
boost::geometry::exterior_ring(poly1) = tuple_list_of(0, 0)(0, 5)(5, 5)(5, 0)(0, 0); boost::geometry::exterior_ring(poly1) = {{0, 0}, {0, 5}, {5, 5}, {5, 0}, {0, 0}};
boost::geometry::exterior_ring(poly2) = tuple_list_of(5, 0)(0, 0)(0, 5)(5, 5)(5, 0); boost::geometry::exterior_ring(poly2) = {{5, 0}, {0, 0}, {0, 5}, {5, 5}, {5, 0}};
std::cout std::cout
<< "polygons are spatially " << "polygons are spatially "
@ -43,7 +39,6 @@ int main()
<< (boost::geometry::equals(box, poly2) ? "equal" : "not equal") << (boost::geometry::equals(box, poly2) ? "equal" : "not equal")
<< std::endl; << std::endl;
return 0; return 0;
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -19,8 +19,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<short int> point_type; using point_type = boost::geometry::model::d2::point_xy<short int>;
typedef boost::geometry::model::box<point_type> box_type; using box_type = boost::geometry::model::box<point_type>;
using boost::geometry::expand; using boost::geometry::expand;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -16,41 +16,27 @@
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/geometries/polygon.hpp>
int main()
template <typename Point>
class round_coordinates
{ {
private : using point = boost::geometry::model::d2::point_xy<double>;
typedef typename boost::geometry::coordinate_type<Point>::type coordinate_type;
coordinate_type factor;
inline coordinate_type round(coordinate_type value) constexpr auto factor = 0.1;
auto round = [&](auto value)
{ {
return floor(0.5 + (value / factor)) * factor; return floor(0.5 + (value / factor)) * factor;
} };
public : boost::geometry::model::polygon<point> poly;
round_coordinates(coordinate_type f) boost::geometry::read_wkt("POLYGON((0 0,1.123 9.987,8.876 2.234,0 0),(3.345 4.456,7.654 8.765,9.123 5.432,3.345 4.456))", poly);
: factor(f) boost::geometry::for_each_point(poly,
{} [&round](auto& p)
inline void operator()(Point& p)
{ {
using boost::geometry::get; using boost::geometry::get;
using boost::geometry::set; using boost::geometry::set;
set<0>(p, round(get<0>(p))); set<0>(p, round(get<0>(p)));
set<1>(p, round(get<1>(p))); set<1>(p, round(get<1>(p)));
} }
}; );
int main()
{
typedef boost::geometry::model::d2::point_xy<double> point;
boost::geometry::model::polygon<point> poly;
boost::geometry::read_wkt("POLYGON((0 0,1.123 9.987,8.876 2.234,0 0),(3.345 4.456,7.654 8.765,9.123 5.432,3.345 4.456))", poly);
boost::geometry::for_each_point(poly, round_coordinates<point>(0.1));
std::cout << "Rounded: " << boost::geometry::wkt(poly) << std::endl; std::cout << "Rounded: " << boost::geometry::wkt(poly) << std::endl;
return 0; return 0;
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -26,7 +26,7 @@ void list_coordinates(Point const& p)
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point; using point = boost::geometry::model::d2::point_xy<double>;
boost::geometry::model::polygon<point> poly; boost::geometry::model::polygon<point> poly;
boost::geometry::read_wkt("POLYGON((0 0,0 4,4 0,0 0))", poly); boost::geometry::read_wkt("POLYGON((0 0,0 4,4 0,0 0))", poly);
boost::geometry::for_each_point(poly, list_coordinates<point>); boost::geometry::for_each_point(poly, list_coordinates<point>);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -11,72 +11,37 @@
//` Sample using for_each_segment, using a functor to get the minimum and maximum length of a segment in a linestring //` Sample using for_each_segment, using a functor to get the minimum and maximum length of a segment in a linestring
#include <iostream> #include <iostream>
#include <limits>
#include <boost/geometry.hpp> #include <boost/geometry.hpp>
#include <boost/geometry/geometries/linestring.hpp> #include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/assign.hpp>
template <typename Segment>
struct gather_segment_statistics
{
// Remember that if coordinates are integer, the length might be floating point
// So use "double" for integers. In other cases, use coordinate type
typedef typename boost::geometry::select_most_precise
<
typename boost::geometry::coordinate_type<Segment>::type,
double
>::type type;
type min_length, max_length;
// Initialize min and max
gather_segment_statistics()
: min_length(1e38)
, max_length(-1)
{}
// This operator is called for each segment
inline void operator()(Segment const& s)
{
type length = boost::geometry::length(s);
if (length < min_length) min_length = length;
if (length > max_length) max_length = length;
}
};
int main() int main()
{ {
// Bring "+=" for a vector into scope
using namespace boost::assign;
// Define a type // Define a type
typedef boost::geometry::model::d2::point_xy<double> point; using point = boost::geometry::model::d2::point_xy<double>;
// Declare a linestring // Create a linestring
boost::geometry::model::linestring<point> polyline; const boost::geometry::model::linestring<point> polyline =
{{0, 0}, {3, 3}, {5, 1}, {6, 2}, {8, 0}, {4, -4}, {1, -1}, {3, 2}};
// Use Boost.Assign to initialize a linestring // Iterate over its segments to find the minimum and maximum length
polyline += point(0, 0), point(3, 3), point(5, 1), point(6, 2), double min_length = std::numeric_limits<double>::max();
point(8, 0), point(4, -4), point(1, -1), point(3, 2); double max_length = -std::numeric_limits<double>::max();
boost::geometry::for_each_segment(polyline,
// Declare the gathering class... [&](auto const& s)
gather_segment_statistics {
< const auto length = boost::geometry::length(s);
boost::geometry::model::referring_segment<point> min_length = std::min(min_length, length);
> functor; max_length = std::max(max_length, length);
});
// ... and use it, the essention.
// As also in std::for_each it is a const value, so retrieve it as a return value.
functor = boost::geometry::for_each_segment(polyline, functor);
// Output the results // Output the results
std::cout std::cout
<< "Min segment length: " << functor.min_length << std::endl << "Min segment length: " << min_length << std::endl
<< "Max segment length: " << functor.max_length << std::endl; << "Max segment length: " << max_length << std::endl;
return 0; return 0;
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,14 +17,12 @@
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/register/linestring.hpp> #include <boost/geometry/geometries/register/linestring.hpp>
#include <boost/foreach.hpp>
BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector) BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> P; using P = boost::geometry::model::d2::point_xy<double>;
std::vector<P> line1, line2; std::vector<P> line1, line2;
boost::geometry::read_wkt("linestring(1 1,2 2,3 1)", line1); boost::geometry::read_wkt("linestring(1 1,2 2,3 1)", line1);
boost::geometry::read_wkt("linestring(1 2,2 1,3 2)", line2); boost::geometry::read_wkt("linestring(1 2,2 1,3 2)", line2);
@ -32,7 +30,7 @@ int main()
std::deque<P> intersection_points; std::deque<P> intersection_points;
boost::geometry::intersection(line1, line2, intersection_points); boost::geometry::intersection(line1, line2, intersection_points);
BOOST_FOREACH(P const& p, intersection_points) for (P const& p : intersection_points)
{ {
std::cout << " " << boost::geometry::wkt(p); std::cout << " " << boost::geometry::wkt(p);
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,12 +17,11 @@
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/geometries/polygon.hpp>
#include <boost/foreach.hpp>
/*<-*/ #include "create_svg_overlay.hpp" /*->*/ /*<-*/ #include "create_svg_overlay.hpp" /*->*/
int main() int main()
{ {
typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon; using polygon = boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>> ;
polygon green, blue; polygon green, blue;
@ -38,7 +37,7 @@ int main()
int i = 0; int i = 0;
std::cout << "green && blue:" << std::endl; std::cout << "green && blue:" << std::endl;
BOOST_FOREACH(polygon const& p, output) for (polygon const& p : output)
{ {
std::cout << i++ << ": " << boost::geometry::area(p) << std::endl; std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -15,12 +15,9 @@
#include <boost/geometry.hpp> #include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/foreach.hpp>
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> P; using P = boost::geometry::model::d2::point_xy<double>;
boost::geometry::model::segment<P> segment1, segment2; boost::geometry::model::segment<P> segment1, segment2;
boost::geometry::read_wkt("linestring(1 1,2 2)", segment1); boost::geometry::read_wkt("linestring(1 1,2 2)", segment1);
boost::geometry::read_wkt("linestring(2 1,1 2)", segment2); boost::geometry::read_wkt("linestring(2 1,1 2)", segment2);
@ -28,7 +25,7 @@ int main()
std::vector<P> intersections; std::vector<P> intersections;
boost::geometry::intersection(segment1, segment2, intersections); boost::geometry::intersection(segment1, segment2, intersections);
BOOST_FOREACH(P const& p, intersections) for (P const& p : intersections)
{ {
std::cout << " " << boost::geometry::wkt(p); std::cout << " " << boost::geometry::wkt(p);
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -19,7 +19,7 @@
int main() int main()
{ {
// Calculate the intersects of a cartesian polygon // Calculate the intersects of a cartesian polygon
typedef boost::geometry::model::d2::point_xy<double> P; using P = boost::geometry::model::d2::point_xy<double>;
boost::geometry::model::linestring<P> line1, line2; boost::geometry::model::linestring<P> line1, line2;
boost::geometry::read_wkt("linestring(1 1,2 2,3 3)", line1); boost::geometry::read_wkt("linestring(1 1,2 2,3 3)", line1);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -19,7 +19,7 @@
int main() int main()
{ {
// Calculate the intersects of a cartesian polygon // Calculate the intersects of a cartesian polygon
typedef boost::geometry::model::d2::point_xy<double> P; using P = boost::geometry::model::d2::point_xy<double>;
bg::model::linestring<P> line1, line2; bg::model::linestring<P> line1, line2;
boost::geometry::read_wkt("linestring(1 1,2 2)", line1); boost::geometry::read_wkt("linestring(1 1,2 2)", line1);

View File

@ -21,9 +21,9 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::linestring<point_type> linestring_type; using linestring_type = boost::geometry::model::linestring<point_type>;
typedef boost::geometry::model::multi_linestring<linestring_type> multi_linestring_type; using multi_linestring_type = boost::geometry::model::multi_linestring<linestring_type>;
multi_linestring_type multi_linestring; multi_linestring_type multi_linestring;
boost::geometry::read_wkt("MULTILINESTRING((0 0,0 10,10 10,10 0,0 0),(10 10,20 20))", multi_linestring); boost::geometry::read_wkt("MULTILINESTRING((0 0,0 10,10 10,10 0,0 0),(10 10,20 20))", multi_linestring);

View File

@ -20,8 +20,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
polygon_type poly; polygon_type poly;
boost::geometry::read_wkt("POLYGON((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 2,0 0),(0 0,2 9,1 9,0 0),(2 9,9 2,9 9,2 9))", poly); boost::geometry::read_wkt("POLYGON((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 2,0 0),(0 0,2 9,1 9,0 0),(2 9,9 2,9 9,2 9))", poly);

View File

@ -20,8 +20,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
polygon_type poly; polygon_type poly;
boost::geometry::read_wkt("POLYGON((0 0,0 10,10 10,10 0),(0 0,9 2,9 1,0 0),(0 0,2 9,1 9,0 0))", poly); boost::geometry::read_wkt("POLYGON((0 0,0 10,10 10,10 0),(0 0,9 2,9 1,0 0),(0 0,2 9,1 9,0 0))", poly);

View File

@ -21,8 +21,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
polygon_type poly; polygon_type poly;
boost::geometry::read_wkt("POLYGON((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 2,0 0),(0 0,2 9,1 9,0 0),(2 9,9 2,9 9,2 9))", poly); boost::geometry::read_wkt("POLYGON((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 2,0 0),(0 0,2 9,1 9,0 0),(2 9,9 2,9 9,2 9))", poly);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,7 +17,7 @@
int main() int main()
{ {
using namespace boost::geometry; using namespace boost::geometry;
typedef model::point<float, 2, cs::spherical_equatorial<degree> > P; using P = model::point<float, 2, cs::spherical_equatorial<degree>>;
model::linestring<P> line; model::linestring<P> line;
line.push_back(P(2, 41)); line.push_back(P(2, 41));
line.push_back(P(2, 48)); line.push_back(P(2, 48));

View File

@ -20,7 +20,7 @@ using namespace boost::geometry;
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
using segment_type = model::segment<point_type>; using segment_type = model::segment<point_type>;
using linestring_type = model::linestring<point_type>; using linestring_type = model::linestring<point_type>;
using multipoint_type = model::multi_point<point_type>; using multipoint_type = model::multi_point<point_type>;

View File

@ -20,7 +20,7 @@ using namespace boost::geometry;
int main() int main()
{ {
typedef model::d2::point_xy<double,cs::geographic<degree> > point_type; using point_type = model::d2::point_xy<double,cs::geographic<degree>>;
using segment_type = model::segment<point_type>; using segment_type = model::segment<point_type>;
using linestring_type = model::linestring<point_type>; using linestring_type = model::linestring<point_type>;
using multipoint_type = model::multi_point<point_type>; using multipoint_type = model::multi_point<point_type>;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -16,7 +16,6 @@
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/register/point.hpp> #include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp> #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon/point.hpp>
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
@ -42,7 +41,6 @@ int main()
construct_and_display<boost::geometry::model::d2::point_xy<double>>(); construct_and_display<boost::geometry::model::d2::point_xy<double>>();
construct_and_display<boost::geometry::model::d2::point_xy<int>>(); construct_and_display<boost::geometry::model::d2::point_xy<int>>();
construct_and_display<boost::tuple<double, double>>(); construct_and_display<boost::tuple<double, double>>();
construct_and_display<boost::polygon::point_data<int> >();
construct_and_display<mypoint>(); construct_and_display<mypoint>();
return 0; return 0;
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,8 +17,8 @@
int main() int main()
{ {
typedef boost::geometry::model::point<double, 3, boost::geometry::cs::cartesian> point_type; using point_type = boost::geometry::model::point<double, 3, boost::geometry::cs::cartesian>;
point_type p = boost::geometry::make<point_type>(1, 2, 3); const auto p = boost::geometry::make<point_type>(1, 2, 3);
std::cout << boost::geometry::dsv(p) << std::endl; std::cout << boost::geometry::dsv(p) << std::endl;
return 0; return 0;
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -21,8 +21,8 @@ using namespace boost::geometry;
int main() int main()
{ {
typedef model::d2::point_xy<double> point; using point = model::d2::point_xy<double>;
typedef model::box<point> box; using box = model::box<point>;
box all = make_inverse<box>(); box all = make_inverse<box>();
std::cout << dsv(all) << std::endl; std::cout << dsv(all) << std::endl;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -24,8 +24,8 @@ int main()
using boost::geometry::make; using boost::geometry::make;
using boost::geometry::detail::make::make_points; using boost::geometry::detail::make::make_points;
typedef boost::geometry::model::d2::point_xy<double> point; using point = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::linestring<point> linestring; using linestring = boost::geometry::model::linestring<point>;
double coordinates[][2] = {{1,2}, {3,4}, {5, 6}}; /*< Initialize with C array points >*/ double coordinates[][2] = {{1,2}, {3,4}, {5, 6}}; /*< Initialize with C array points >*/
linestring ls = make_points<linestring>(coordinates); linestring ls = make_points<linestring>(coordinates);

View File

@ -24,8 +24,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
polygon_type poly; polygon_type poly;
boost::geometry::read_wkt( boost::geometry::read_wkt(

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2015. // This file was modified by Oracle on 2015.
// Modifications copyright (c) 2015 Oracle and/or its affiliates. // Modifications copyright (c) 2015 Oracle and/or its affiliates.
@ -25,8 +25,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
polygon_type poly; polygon_type poly;
boost::geometry::read_wkt( boost::geometry::read_wkt(

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -12,31 +12,23 @@
#include <iostream> #include <iostream>
#include <boost/geometry.hpp> #include <boost/geometry.hpp>
#include <boost/geometry/geometries/box.hpp> #include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/ring.hpp> #include <boost/geometry/geometries/ring.hpp>
#include <boost/assign.hpp>
/*<-*/ #include "create_svg_two.hpp" /*->*/ /*<-*/ #include "create_svg_two.hpp" /*->*/
int main() int main()
{ {
using namespace boost::assign; using point = boost::geometry::model::d2::point_xy<double>;
using box = boost::geometry::model::box<point>;
typedef boost::geometry::model::d2::point_xy<double> point; const boost::geometry::model::ring<point> ring {
{4.0, -0.5}, {3.5, 1.0}, {2.0, 1.5}, {3.5, 2.0},
boost::geometry::model::ring<point> ring; {4.0, 3.5}, {4.5, 2.0}, {6.0, 1.5}, {4.5, 1.0},
ring += {4.0, -0.5}
point(4.0, -0.5), point(3.5, 1.0), };
point(2.0, 1.5), point(3.5, 2.0),
point(4.0, 3.5), point(4.5, 2.0),
point(6.0, 1.5), point(4.5, 1.0),
point(4.0, -0.5);
typedef boost::geometry::model::box<point> box;
std::cout std::cout
<< "return_envelope:" << "return_envelope:"
@ -49,7 +41,6 @@ int main()
//] //]
//[return_envelope_output //[return_envelope_output
/*` /*`
Output: Output:

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -19,20 +19,15 @@
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
#include <boost/assign.hpp>
int main() int main()
{ {
using boost::assign::tuple_list_of; using point = boost::tuple<int, int>;
using polygon = boost::geometry::model::polygon<point>;
typedef boost::tuple<int, int> point; using ring = boost::geometry::model::ring<point>;
typedef boost::geometry::model::polygon<point> polygon;
typedef boost::geometry::model::ring<point> ring;
polygon poly; polygon poly;
boost::geometry::exterior_ring(poly) = tuple_list_of(0, 0)(0, 9)(10, 10)(0, 0); boost::geometry::exterior_ring(poly) = {{0, 0}, {0, 9}, {10, 10}, {0, 0}};
boost::geometry::interior_rings(poly).push_back(tuple_list_of(1, 2)(4, 6)(2, 8)(1, 2)); boost::geometry::interior_rings(poly).push_back({{1, 2}, {4, 6}, {2, 8}, {1, 2}});
double area_before = boost::geometry::area(poly); double area_before = boost::geometry::area(poly);
boost::geometry::reverse(poly); boost::geometry::reverse(poly);
@ -40,7 +35,7 @@ int main()
std::cout << boost::geometry::dsv(poly) << std::endl; std::cout << boost::geometry::dsv(poly) << std::endl;
std::cout << area_before << " -> " << area_after << std::endl; std::cout << area_before << " -> " << area_after << std::endl;
ring r = tuple_list_of(0, 0)(0, 9)(8, 8)(0, 0); ring r = {{0, 0}, {0, 9}, {8, 8}, {0, 0}};
area_before = boost::geometry::area(r); area_before = boost::geometry::area(r);
boost::geometry::reverse(r); boost::geometry::reverse(r);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -16,18 +16,12 @@
#include <boost/geometry/geometries/linestring.hpp> #include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
/*< For this example we use Boost.Assign to add points >*/
#include <boost/assign.hpp>
using namespace boost::assign;
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> xy; using xy = boost::geometry::model::d2::point_xy<double>;
boost::geometry::model::linestring<xy> line; const boost::geometry::model::linestring<xy> line
line += xy(1.1, 1.1), xy(2.5, 2.1), xy(3.1, 3.1), xy(4.9, 1.1), xy(3.1, 1.9); /*< With Boost.Assign >*/ {{1.1, 1.1}, {2.5, 2.1}, {3.1, 3.1}, {4.9, 1.1}, {3.1, 1.9}};
// Simplify it, using distance of 0.5 units // Simplify it, using distance of 0.5 units
boost::geometry::model::linestring<xy> simplified; boost::geometry::model::linestring<xy> simplified;
@ -36,7 +30,6 @@ int main()
<< " original: " << boost::geometry::dsv(line) << std::endl << " original: " << boost::geometry::dsv(line) << std::endl
<< "simplified: " << boost::geometry::dsv(simplified) << std::endl; << "simplified: " << boost::geometry::dsv(simplified) << std::endl;
return 0; return 0;
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -18,8 +18,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> P; using P = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::linestring<P> L; using L = boost::geometry::model::linestring<P>;
L line; L line;
line.push_back(P(1.1, 1.1)); line.push_back(P(1.1, 1.1));

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -18,14 +18,14 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> P; using P = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::linestring<P> L; using L = boost::geometry::model::linestring<P>;
L line; L line;
boost::geometry::read_wkt("linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", line); boost::geometry::read_wkt("linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", line);
typedef boost::geometry::strategy::distance::projected_point<P, P> DS; using DS = boost::geometry::strategy::distance::projected_point<P, P>;
typedef boost::geometry::strategy::simplify::douglas_peucker<P, DS> simplification; using simplification = boost::geometry::strategy::simplify::douglas_peucker<P, DS>;
L simplified; L simplified;
boost::geometry::simplify_inserter(line, std::back_inserter(simplified), 0.5, simplification()); //std::ostream_iterator<P>(std::cout, "\n"), 0.5);//); boost::geometry::simplify_inserter(line, std::back_inserter(simplified), 0.5, simplification()); //std::ostream_iterator<P>(std::cout, "\n"), 0.5);//);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,12 +17,11 @@
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp> #include <boost/geometry/geometries/multi_polygon.hpp>
#include <boost/foreach.hpp>
/*<-*/ #include "create_svg_overlay.hpp" /*->*/ /*<-*/ #include "create_svg_overlay.hpp" /*->*/
int main() int main()
{ {
typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon; using polygon = boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>>;
polygon green, blue; polygon green, blue;
@ -41,7 +40,7 @@ int main()
<< "green XOR blue:" << std::endl << "green XOR blue:" << std::endl
<< "total: " << boost::geometry::area(multi) << std::endl; << "total: " << boost::geometry::area(multi) << std::endl;
int i = 0; int i = 0;
BOOST_FOREACH(polygon const& p, multi) for (polygon const& p : multi)
{ {
std::cout << i++ << ": " << boost::geometry::area(p) << std::endl; std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -13,13 +13,12 @@
#include <iostream> #include <iostream>
#include <boost/geometry.hpp> #include <boost/geometry.hpp>
int main() int main()
{ {
namespace trans = boost::geometry::strategy::transform; namespace trans = boost::geometry::strategy::transform;
using boost::geometry::dsv; using boost::geometry::dsv;
typedef boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian> point_type; using point_type = boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>;
point_type p1(1.0, 1.0); point_type p1(1.0, 1.0);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,12 +17,11 @@
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/geometries/polygon.hpp>
#include <boost/foreach.hpp>
/*<-*/ #include "create_svg_overlay.hpp" /*->*/ /*<-*/ #include "create_svg_overlay.hpp" /*->*/
int main() int main()
{ {
typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon; using polygon = boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>>;
polygon green, blue; polygon green, blue;
@ -38,7 +37,7 @@ int main()
int i = 0; int i = 0;
std::cout << "green || blue:" << std::endl; std::cout << "green || blue:" << std::endl;
BOOST_FOREACH(polygon const& p, output) for(polygon const& p : output)
{ {
std::cout << i++ << ": " << boost::geometry::area(p) << std::endl; std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
} }

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -20,8 +20,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
polygon_type poly; polygon_type poly;
boost::geometry::read_wkt( boost::geometry::read_wkt(

View File

@ -0,0 +1,29 @@
# Boost.Geometry
# Copyright (c) 2024 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)
foreach(item IN ITEMS
get_point
get_box
set_point
set_box
degree_radian
coordinate_type
coordinate_system
coordinate_dimension
point_order
closure
interior_type
point_type
ring_type
rings
tag
tag_cast
)
boost_geometry_add_example("core" ${item})
endforeach()

View File

@ -1,6 +1,6 @@
# Boost.Geometry (aka GGL, Generic Geometry Library) # Boost.Geometry (aka GGL, Generic Geometry Library)
# #
# Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. # Copyright (c) 2007-2024 Barend Gehrels, Amsterdam, the Netherlands.
# Copyright (c) 2008-2012 Bruno Lalande, Paris, France. # Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
# Copyright (c) 2009-2012 Mateusz Loskot, London, UK. # Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
@ -29,5 +29,5 @@ exe interior_type : interior_type.cpp ;
exe point_type : point_type.cpp ; exe point_type : point_type.cpp ;
exe ring_type : ring_type.cpp ; exe ring_type : ring_type.cpp ;
exe rings : rings.cpp ; exe rings : rings.cpp ;
exe tag : tag.cpp : <library>/boost/assign//boost_assign ; exe tag : tag.cpp ;
exe tag_cast : tag_cast.cpp ; exe tag_cast : tag_cast.cpp ;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -18,8 +18,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
boost::geometry::closure_selector clos = boost::geometry::closure<polygon_type>::value; boost::geometry::closure_selector clos = boost::geometry::closure<polygon_type>::value;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -19,10 +19,10 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
typedef boost::geometry::coordinate_system<polygon_type>::type system; using system = boost::geometry::coordinate_system<polygon_type>::type;
std::cout << "system: " << typeid(system).name() << std::endl; std::cout << "system: " << typeid(system).name() << std::endl;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -19,10 +19,10 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
typedef boost::geometry::coordinate_type<polygon_type>::type ctype; using ctype = boost::geometry::coordinate_type<polygon_type>::type;
std::cout << "type: " << typeid(ctype).name() << std::endl; std::cout << "type: " << typeid(ctype).name() << std::endl;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,8 +17,8 @@ using namespace boost::geometry;
int main() int main()
{ {
typedef model::point<double, 2, cs::spherical_equatorial<degree> > degree_point; using degree_point = model::point<double, 2, cs::spherical_equatorial<degree>>;
typedef model::point<double, 2, cs::spherical_equatorial<radian> > radian_point; using radian_point = model::point<double, 2, cs::spherical_equatorial<radian>>;
degree_point d(4.893, 52.373); degree_point d(4.893, 52.373);
radian_point r(0.041, 0.8527); radian_point r(0.041, 0.8527);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
@ -28,12 +28,12 @@ int main()
// Define a polygon storing points in a deque and storing interior rings // Define a polygon storing points in a deque and storing interior rings
// in a list (note that std::list is not supported by most algorithms // in a list (note that std::list is not supported by most algorithms
// because not supporting a random access iterator) // because not supporting a random access iterator)
typedef boost::geometry::model::polygon using polygon = boost::geometry::model::polygon
< <
boost::array<short, 3>, boost::array<short, 3>,
true, true, true, true,
std::deque, std::list std::deque, std::list
> polygon; >;
std::cout << typeid(boost::geometry::interior_type<polygon>::type).name() << std::endl; std::cout << typeid(boost::geometry::interior_type<polygon>::type).name() << std::endl;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -18,8 +18,8 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type, false> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type, false>;
boost::geometry::order_selector order = boost::geometry::point_order<polygon_type>::value; boost::geometry::order_selector order = boost::geometry::point_order<polygon_type>::value;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -20,11 +20,10 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point_type; using point_type = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point_type> polygon_type; using polygon_type = boost::geometry::model::polygon<point_type>;
typedef boost::geometry::model::multi_polygon<polygon_type> mp_type; using mp_type = boost::geometry::model::multi_polygon<polygon_type>;
using ptype = boost::geometry::point_type<mp_type>::type;
typedef boost::geometry::point_type<mp_type>::type ptype;
std::cout << "point type: " << typeid(ptype).name() << std::endl; std::cout << "point type: " << typeid(ptype).name() << std::endl;

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -19,11 +19,11 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point; using point = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point> polygon; using polygon = boost::geometry::model::polygon<point>;
typedef boost::geometry::ring_type<polygon>::type ring_type; using ring_type = boost::geometry::ring_type<polygon>::type;
typedef boost::geometry::interior_type<polygon>::type int_type; using int_type = boost::geometry::interior_type<polygon>::type;
std::cout << typeid(ring_type).name() << std::endl; std::cout << typeid(ring_type).name() << std::endl;
std::cout << typeid(int_type).name() << std::endl; std::cout << typeid(int_type).name() << std::endl;
@ -32,7 +32,7 @@ int main()
// which is a Boost.Range compatible range // which is a Boost.Range compatible range
// The type of an element of the collection is the very same ring type again. // The type of an element of the collection is the very same ring type again.
// We show that. // We show that.
typedef boost::range_value<int_type>::type int_ring_type; using int_ring_type = boost::range_value<int_type>::type;
std::cout std::cout
<< std::boolalpha << std::boolalpha

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -23,12 +23,12 @@ Also shows the related ring_type and interior_type.
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<double> point; using point = boost::geometry::model::d2::point_xy<double>;
typedef boost::geometry::model::polygon<point> polygon_type; using polygon_type = boost::geometry::model::polygon<point>;
polygon_type poly; polygon_type poly;
typedef boost::geometry::ring_type<polygon_type>::type ring_type; using ring_type = boost::geometry::ring_type<polygon_type>::type;
ring_type& ring = boost::geometry::exterior_ring(poly); ring_type& ring = boost::geometry::exterior_ring(poly);
// For a ring of model::polygon, you can call "push_back". // For a ring of model::polygon, you can call "push_back".
@ -44,17 +44,18 @@ int main()
inner.push_back(point(2, 2)); inner.push_back(point(2, 2));
inner.push_back(point(1, 1)); inner.push_back(point(1, 1));
typedef boost::geometry::interior_type<polygon_type>::type int_type; auto& interiors = boost::geometry::interior_rings(poly);
int_type& interiors = boost::geometry::interior_rings(poly);
interiors.push_back(inner); interiors.push_back(inner);
std::cout << boost::geometry::dsv(poly) << std::endl; std::cout << boost::geometry::dsv(poly) << std::endl;
// So int_type defines a collection of rings, // Let int_type define a collection of rings,
// which is a Boost.Range compatible range // which is a Boost.Range compatible range
using int_type = boost::geometry::interior_type<polygon_type>::type;
// The type of an element of the collection is the very same ring type again. // The type of an element of the collection is the very same ring type again.
// We show that. // We show that.
typedef boost::range_value<int_type>::type int_ring_type; using int_ring_type = boost::range_value<int_type>::type;
std::cout std::cout
<< std::boolalpha << std::boolalpha

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,8 +17,6 @@
#include <boost/geometry/geometries/multi_polygon.hpp> #include <boost/geometry/geometries/multi_polygon.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp> #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#include <boost/assign.hpp> /*< At the end to avoid conflicts with Boost.QVM >*/
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
template <typename Tag> struct dispatch {}; template <typename Tag> struct dispatch {};
@ -79,11 +77,11 @@ inline void hello(Geometry const& geometry)
int main() int main()
{ {
// Define polygon type (here: based on a Boost.Tuple) // Define polygon type (here: based on a Boost.Tuple)
typedef boost::geometry::model::polygon<boost::tuple<int, int> > polygon_type; using polygon_type = boost::geometry::model::polygon<boost::tuple<int, int>>;
// Declare and fill a polygon and a multipolygon // Declare and fill a polygon and a multipolygon
polygon_type poly; polygon_type poly;
boost::geometry::exterior_ring(poly) = boost::assign::tuple_list_of(0, 0)(0, 10)(10, 5)(0, 0); boost::geometry::exterior_ring(poly) = {{0, 0}, {0, 10}, {10, 5}, {0, 0}};
boost::geometry::model::multi_polygon<polygon_type> multi; boost::geometry::model::multi_polygon<polygon_type> multi;
multi.push_back(poly); multi.push_back(poly);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -20,11 +20,11 @@
namespace geo = boost::geometry; namespace geo = boost::geometry;
int main() int main()
{ {
typedef geo::model::d2::point_xy<double> point_type; using point_type = geo::model::d2::point_xy<double>;
typedef geo::model::polygon<point_type> polygon_type; using polygon_type = geo::model::polygon<point_type>;
typedef geo::tag<polygon_type>::type tag; using tag = geo::tag<polygon_type>::type;
typedef geo::tag_cast<tag, geo::linear_tag, geo::areal_tag>::type base_tag; using base_tag = geo::tag_cast<tag, geo::linear_tag, geo::areal_tag>::type;
std::cout << "tag: " << typeid(tag).name() << std::endl std::cout << "tag: " << typeid(tag).name() << std::endl
<< "base tag: " << typeid(base_tag).name() << std::endl; << "base tag: " << typeid(base_tag).name() << std::endl;

View File

@ -21,7 +21,7 @@ template <typename Geometry1, typename Geometry2>
void create_svg_buffer(std::string const& filename, Geometry1 const& original, Geometry2 const& buffer) void create_svg_buffer(std::string const& filename, Geometry1 const& original, Geometry2 const& buffer)
{ {
#if defined(HAVE_SVG) #if defined(HAVE_SVG)
typedef typename boost::geometry::point_type<Geometry1>::type point_type; using point_type = typename boost::geometry::point_type<Geometry1>::type;
std::ofstream svg(filename.c_str()); std::ofstream svg(filename.c_str());
boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400); boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400);

View File

@ -0,0 +1,24 @@
# Boost.Geometry
# Copyright (c) 2024 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)
foreach(item IN ITEMS
box
linestring
point
point_xy
point_xyz
polygon
multi_linestring
multi_point
multi_polygon
ring
segment
)
boost_geometry_add_example("geometries" ${item})
endforeach()

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
@ -17,7 +17,7 @@
int main() int main()
{ {
typedef boost::polygon::rectangle_data<int> rect; using rect = boost::polygon::rectangle_data<int>;
rect b = boost::polygon::construct<rect>(1, 2, 3, 4); rect b = boost::polygon::construct<rect>(1, 2, 3, 4);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
@ -17,9 +17,9 @@
int main() int main()
{ {
typedef boost::polygon::polygon_with_holes_data<int> polygon; using polygon = boost::polygon::polygon_with_holes_data<int>;
typedef boost::polygon::polygon_traits<polygon>::point_type point; using point = boost::polygon::polygon_traits<polygon>::point_type;
typedef boost::polygon::polygon_with_holes_traits<polygon>::hole_type hole; using hole = boost::polygon::polygon_with_holes_traits<polygon>::hole_type;
point pts[5] = { point pts[5] = {
boost::polygon::construct<point>(0, 0), boost::polygon::construct<point>(0, 0),

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
@ -17,8 +17,8 @@
int main() int main()
{ {
typedef boost::polygon::polygon_data<int> polygon; using polygon = boost::polygon::polygon_data<int>;
typedef boost::polygon::polygon_traits<polygon>::point_type point; using point = boost::polygon::polygon_traits<polygon>::point_type;
point pts[5] = { point pts[5] = {
boost::polygon::construct<point>(0, 0), boost::polygon::construct<point>(0, 0),

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -29,7 +29,7 @@ struct not_two
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<int> xy; using xy = boost::geometry::model::d2::point_xy<int>;
boost::geometry::model::linestring<xy> line; boost::geometry::model::linestring<xy> line;
line.push_back(xy(0, 0)); line.push_back(xy(0, 0));
line.push_back(xy(1, 1)); line.push_back(xy(1, 1));

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -19,7 +19,7 @@
int main() int main()
{ {
typedef boost::geometry::model::d2::point_xy<int> xy; using xy = boost::geometry::model::d2::point_xy<int>;
boost::geometry::model::linestring<xy> line; boost::geometry::model::linestring<xy> line;
line.push_back(xy(0, 0)); line.push_back(xy(0, 0));
line.push_back(xy(1, 1)); line.push_back(xy(1, 1));

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,14 +17,11 @@
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/adapted/boost_range/sliced.hpp> #include <boost/geometry/geometries/adapted/boost_range/sliced.hpp>
#include <boost/assign.hpp> /*< At the end to avoid conflicts with Boost.QVM >*/
int main() int main()
{ {
using namespace boost::assign; using namespace boost::assign;
typedef boost::geometry::model::d2::point_xy<int> xy; using xy = boost::geometry::model::d2::point_xy<int>;
boost::geometry::model::linestring<xy> line; boost::geometry::model::linestring<xy> line;
line += xy(0, 0); line += xy(0, 0);
line += xy(1, 1); line += xy(1, 1);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -17,15 +17,12 @@
#include <boost/geometry/geometries/ring.hpp> #include <boost/geometry/geometries/ring.hpp>
#include <boost/geometry/geometries/adapted/boost_range/strided.hpp> #include <boost/geometry/geometries/adapted/boost_range/strided.hpp>
#include <boost/assign.hpp> /*< At the end to avoid conflicts with Boost.QVM >*/
int main() int main()
{ {
using namespace boost::assign; using namespace boost::assign;
using boost::adaptors::strided; using boost::adaptors::strided;
typedef boost::geometry::model::d2::point_xy<int> xy; using xy = boost::geometry::model::d2::point_xy<int>;
boost::geometry::model::ring<xy> ring; boost::geometry::model::ring<xy> ring;
ring += xy(0, 0); ring += xy(0, 0);
ring += xy(0, 1); ring += xy(0, 1);

View File

@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) // Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -12,14 +12,12 @@
#include <iostream> #include <iostream>
#include <boost/assign.hpp>
#include <boost/geometry.hpp> #include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/ring.hpp> #include <boost/geometry/geometries/ring.hpp>
#include <boost/geometry/geometries/adapted/boost_range/uniqued.hpp> #include <boost/geometry/geometries/adapted/boost_range/uniqued.hpp>
typedef boost::geometry::model::d2::point_xy<int> xy; using xy = boost::geometry::model::d2::point_xy<int>;
inline bool operator==(xy const& left, xy const& right) inline bool operator==(xy const& left, xy const& right)
{ {

View File

@ -1,7 +1,7 @@
// Boost.Geometry // Boost.Geometry
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
@ -18,8 +18,8 @@ namespace bg = boost::geometry;
int main() int main()
{ {
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t; using point_t = bg::model::point<double, 2, bg::cs::cartesian>;
typedef bg::model::box<point_t> box_t; using box_t = bg::model::box<point_t>;
box_t box1; /*< Default-construct a box. >*/ box_t box1; /*< Default-construct a box. >*/
box_t box2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning min and max corner point. >*/ box_t box2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning min and max corner point. >*/

View File

@ -1,7 +1,7 @@
// Boost.Geometry // Boost.Geometry
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
@ -19,8 +19,8 @@ namespace bg = boost::geometry;
int main() int main()
{ {
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t; using point_t = bg::model::point<double, 2, bg::cs::cartesian>;
typedef bg::model::linestring<point_t> linestring_t; using linestring_t = bg::model::linestring<point_t>;
linestring_t ls1; /*< Default-construct a linestring. >*/ linestring_t ls1; /*< Default-construct a linestring. >*/
linestring_t ls2{{0.0, 0.0}, {1.0, 0.0}, {1.0, 2.0}}; /*< Construct a linestring containing three points, using C++11 unified initialization syntax. >*/ linestring_t ls2{{0.0, 0.0}, {1.0, 0.0}, {1.0, 2.0}}; /*< Construct a linestring containing three points, using C++11 unified initialization syntax. >*/

View File

@ -1,7 +1,7 @@
// Boost.Geometry // Boost.Geometry
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
@ -19,9 +19,9 @@ namespace bg = boost::geometry;
int main() int main()
{ {
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t; using point_t = bg::model::point<double, 2, bg::cs::cartesian>;
typedef bg::model::linestring<point_t> linestring_t; using linestring_t = bg::model::linestring<point_t>;
typedef bg::model::multi_linestring<linestring_t> mlinestring_t; using mlinestring_t = bg::model::multi_linestring<linestring_t>;
mlinestring_t mls1; /*< Default-construct a multi_linestring. >*/ mlinestring_t mls1; /*< Default-construct a multi_linestring. >*/
mlinestring_t mls2{{{0.0, 0.0}, {0.0, 1.0}, {2.0, 1.0}}, mlinestring_t mls2{{{0.0, 0.0}, {0.0, 1.0}, {2.0, 1.0}},

View File

@ -1,7 +1,7 @@
// Boost.Geometry // Boost.Geometry
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
@ -19,8 +19,8 @@ namespace bg = boost::geometry;
int main() int main()
{ {
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t; using point_t = bg::model::point<double, 2, bg::cs::cartesian>;
typedef bg::model::multi_point<point_t> mpoint_t; using mpoint_t = bg::model::multi_point<point_t>;
mpoint_t mpt1; /*< Default-construct a multi_point. >*/ mpoint_t mpt1; /*< Default-construct a multi_point. >*/
mpoint_t mpt2{{{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}}}; /*< Construct a multi_point containing three points, using C++11 unified initialization syntax. >*/ mpoint_t mpt2{{{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}}}; /*< Construct a multi_point containing three points, using C++11 unified initialization syntax. >*/

View File

@ -1,7 +1,7 @@
// Boost.Geometry // Boost.Geometry
// QuickBook Example // QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2011-2024 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland.
// Use, modification and distribution is subject to the Boost Software License, // Use, modification and distribution is subject to the Boost Software License,
@ -19,9 +19,9 @@ namespace bg = boost::geometry;
int main() int main()
{ {
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t; using point_t = bg::model::point<double, 2, bg::cs::cartesian>;
typedef bg::model::polygon<point_t> polygon_t; /*< Default parameters, clockwise, closed polygon. >*/ using polygon_t = bg::model::polygon<point_t>; /*< Default parameters, clockwise, closed polygon. >*/
typedef bg::model::multi_polygon<polygon_t> mpolygon_t; /*< Clockwise, closed multi_polygon. >*/ using mpolygon_t = bg::model::multi_polygon<polygon_t>; /*< Clockwise, closed multi_polygon. >*/
mpolygon_t mpoly1; /*< Default-construct a multi_polygon. >*/ mpolygon_t mpoly1; /*< Default-construct a multi_polygon. >*/
mpolygon_t mpoly2{{{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}, mpolygon_t mpoly2{{{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}},

Some files were not shown because too many files have changed in this diff Show More