From 310498b4b49a077b9904eeb11d566aaca157298a Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 28 Sep 2024 09:49:12 +0200 Subject: [PATCH] feat: add remaining examples to cmake --- .../algorithms/difference_inserter.qbk | 22 ----- doc/src/examples/CMakeLists.txt | 1 + doc/src/examples/algorithms/CMakeLists.txt | 21 ++++- doc/src/examples/algorithms/append.cpp | 2 +- .../algorithms/assign_box_corners.cpp | 2 +- .../algorithms/assign_point_from_index.cpp | 4 +- .../algorithms/assign_point_to_index.cpp | 4 +- .../algorithms/difference_inserter.cpp | 86 ------------------- .../algorithms/for_each_segment_const.cpp | 2 +- .../algorithms/intersects_segment.cpp | 6 +- doc/src/examples/algorithms/is_empty.cpp | 1 - .../examples/algorithms/simplify_insert.cpp | 14 +-- .../simplify_insert_with_strategy.cpp | 71 --------------- doc/src/examples/arithmetic/CMakeLists.txt | 15 ++++ doc/src/examples/geometries/CMakeLists.txt | 2 + .../geometries/adapted/CMakeLists.txt | 20 +++++ .../adapted/boost_range/CMakeLists.txt | 18 ++++ .../geometries/adapted/boost_range/sliced.cpp | 9 +- .../adapted/boost_range/strided.cpp | 9 +- .../adapted/boost_range/uniqued.cpp | 13 +-- .../geometries/register/CMakeLists.txt | 24 ++++++ 21 files changed, 117 insertions(+), 229 deletions(-) delete mode 100644 doc/reference/algorithms/difference_inserter.qbk delete mode 100644 doc/src/examples/algorithms/difference_inserter.cpp delete mode 100644 doc/src/examples/algorithms/simplify_insert_with_strategy.cpp create mode 100644 doc/src/examples/arithmetic/CMakeLists.txt create mode 100644 doc/src/examples/geometries/adapted/CMakeLists.txt create mode 100644 doc/src/examples/geometries/adapted/boost_range/CMakeLists.txt create mode 100644 doc/src/examples/geometries/register/CMakeLists.txt diff --git a/doc/reference/algorithms/difference_inserter.qbk b/doc/reference/algorithms/difference_inserter.qbk deleted file mode 100644 index 89e309488b..0000000000 --- a/doc/reference/algorithms/difference_inserter.qbk +++ /dev/null @@ -1,22 +0,0 @@ -[/============================================================================ - Boost.Geometry (aka GGL, Generic Geometry Library) - - Copyright (c) 2011-2012 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) -=============================================================================/] - -[include reference/algorithms/difference_behavior.qbk] - -[include reference/algorithms/geometry_rules.qbk] - -[heading Example] -[difference_inserter] [difference_inserter_output] - -[heading See also] -* [link geometry.reference.algorithms.sym_difference.sym_difference_inserter_3 sym_difference_inserter (symmetric difference)] -* [link geometry.reference.algorithms.intersection.intersection_inserter_3 intersection_inserter] -* [link geometry.reference.algorithms.union.union_inserter_3 union_inserter] - diff --git a/doc/src/examples/CMakeLists.txt b/doc/src/examples/CMakeLists.txt index da51662450..5d1699dac8 100644 --- a/doc/src/examples/CMakeLists.txt +++ b/doc/src/examples/CMakeLists.txt @@ -33,6 +33,7 @@ foreach(item IN ITEMS endforeach() add_subdirectory(algorithms) +add_subdirectory(arithmetic) add_subdirectory(core) add_subdirectory(geometries) add_subdirectory(io) diff --git a/doc/src/examples/algorithms/CMakeLists.txt b/doc/src/examples/algorithms/CMakeLists.txt index c184aac335..15583b1a53 100644 --- a/doc/src/examples/algorithms/CMakeLists.txt +++ b/doc/src/examples/algorithms/CMakeLists.txt @@ -65,9 +65,28 @@ foreach(item IN ITEMS union unique within + + # Entries not present in Jamfile + # Some of them are used in the documentation, but not all of them. + assign_box_corners # uses detail, not used in documentation + assign_point_from_index # uses detail, not used in documentation + assign_point_to_index # uses detail, not used in documentation + azimuth + azimuth_strategy + covered_by + crosses + disjoint + intersection_poly_poly + intersects_segment + is_empty + make_with_range # uses detail, not used in documentation + overlaps + perimeter + simplify_insert # uses detail, not used in documentation + touches_one_geometry + touches_two_geometries ) boost_geometry_add_example("algorithms" ${item}) endforeach() - diff --git a/doc/src/examples/algorithms/append.cpp b/doc/src/examples/algorithms/append.cpp index 93b703133f..3addb6dec8 100644 --- a/doc/src/examples/algorithms/append.cpp +++ b/doc/src/examples/algorithms/append.cpp @@ -28,7 +28,7 @@ int main() polygon poly; // Append a range - 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(poly, vector{{0, 0}, {0, 10}, {11, 11}, {10, 0}}); /*< vector models a range and can therefore be used in boost::geometry::append >*/ // Append a point (in this case the closing point) append(poly, boost::make_tuple(0, 0)); diff --git a/doc/src/examples/algorithms/assign_box_corners.cpp b/doc/src/examples/algorithms/assign_box_corners.cpp index 52087a7411..27862b2ab9 100644 --- a/doc/src/examples/algorithms/assign_box_corners.cpp +++ b/doc/src/examples/algorithms/assign_box_corners.cpp @@ -27,7 +27,7 @@ int main() assign_values(b, 2, 2, 5, 5); point ll, lr, ul, ur; - assign_box_corners(b, ll, lr, ul, ur); + detail::assign_box_corners(b, ll, lr, ul, ur); std::cout << "box: " << dsv(b) << std::endl << std::endl; diff --git a/doc/src/examples/algorithms/assign_point_from_index.cpp b/doc/src/examples/algorithms/assign_point_from_index.cpp index 836b6b39f5..6fa3c4b341 100644 --- a/doc/src/examples/algorithms/assign_point_from_index.cpp +++ b/doc/src/examples/algorithms/assign_point_from_index.cpp @@ -27,8 +27,8 @@ int main() assign_values(s, 1, 1, 2, 2); point first, second; - assign_point_from_index<0>(s, first); - assign_point_from_index<1>(s, second); + detail::assign_point_from_index<0>(s, first); + detail::assign_point_from_index<1>(s, second); std::cout << "segment: " << dsv(s) << std::endl << "first: " << dsv(first) << std::endl diff --git a/doc/src/examples/algorithms/assign_point_to_index.cpp b/doc/src/examples/algorithms/assign_point_to_index.cpp index 1742d42304..c777d3cd5c 100644 --- a/doc/src/examples/algorithms/assign_point_to_index.cpp +++ b/doc/src/examples/algorithms/assign_point_to_index.cpp @@ -26,8 +26,8 @@ int main() point lower_left(0, 0), upper_right(2, 2); box b; - assign_point_to_index<0>(lower_left, b); - assign_point_to_index<1>(upper_right, b); + detail::assign_point_to_index<0>(lower_left, b); + detail::assign_point_to_index<1>(upper_right, b); std::cout << "box: " << dsv(b) << std::endl; return 0; diff --git a/doc/src/examples/algorithms/difference_inserter.cpp b/doc/src/examples/algorithms/difference_inserter.cpp deleted file mode 100644 index 27ee7e3f9a..0000000000 --- a/doc/src/examples/algorithms/difference_inserter.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// QuickBook Example - -// Copyright (c) 2011-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) - -//[difference_inserter -//` Shows how the difference_inserter function can be used - -#include -#include - -#include -#include -#include - -/*<-*/ #include "create_svg_overlay.hpp" /*->*/ - -int main() -{ - using polygon = boost::geometry::model::polygon>; - - polygon green, blue; - - boost::geometry::read_wkt( - "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)" - "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", green); - - boost::geometry::read_wkt( - "POLYGON((4.0 -0.5 , 3.5 1.0 , 2.0 1.5 , 3.5 2.0 , 4.0 3.5 , 4.5 2.0 , 6.0 1.5 , 4.5 1.0 , 4.0 -0.5))", blue); - - std::vector output; - - // Note that this sample simulates the symmetric difference, - // which is also available as a separate algorithm. - // It chains the output iterator returned by the function to the second instance. - boost::geometry::difference_inserter - ( - green, blue, - boost::geometry::difference_inserter - ( - blue, green, - std::back_inserter(output) - ) - ); - - - int i = 0; - std::cout << "(blue \ green) u (green \ blue):" << std::endl; - for (polygon const& p : output) - { - std::cout << i++ << ": " << boost::geometry::area(p) << std::endl; - } - - /*<-*/ create_svg("difference_inserter.svg", green, blue, output); /*->*/ - return 0; -} - -//] - - -//[difference_inserter_output -/*` -Output: -[pre -(blue \\ green) u (green \\ blue): -0: 0.525154 -1: 0.015 -2: 0.181136 -3: 0.128798 -4: 0.340083 -5: 0.307778 -6: 0.02375 -7: 0.542951 -8: 0.0149697 -9: 0.226855 -10: 0.839424 - -[$img/algorithms/sym_difference.png] - -] -*/ -//] diff --git a/doc/src/examples/algorithms/for_each_segment_const.cpp b/doc/src/examples/algorithms/for_each_segment_const.cpp index e4c8eb4e9f..ab97b8c4bf 100644 --- a/doc/src/examples/algorithms/for_each_segment_const.cpp +++ b/doc/src/examples/algorithms/for_each_segment_const.cpp @@ -33,7 +33,7 @@ int main() boost::geometry::for_each_segment(polyline, [&](auto const& s) { - const auto length = boost::geometry::length(s); + const auto length = static_cast(boost::geometry::length(s)); min_length = std::min(min_length, length); max_length = std::max(max_length, length); }); diff --git a/doc/src/examples/algorithms/intersects_segment.cpp b/doc/src/examples/algorithms/intersects_segment.cpp index 5428f3b62f..a70e6a30a6 100644 --- a/doc/src/examples/algorithms/intersects_segment.cpp +++ b/doc/src/examples/algorithms/intersects_segment.cpp @@ -20,14 +20,14 @@ int main() { // Calculate the intersects of a cartesian polygon using P = boost::geometry::model::d2::point_xy; - bg::model::linestring

line1, line2; + boost::geometry::model::linestring

line1, line2; boost::geometry::read_wkt("linestring(1 1,2 2)", line1); boost::geometry::read_wkt("linestring(2 1,1 2)", line2); - bool b = boost::geometry::intersects(line1, line2); + bool intersects = boost::geometry::intersects(line1, line2); - std::cout << "Intersects: " << (b ? "YES" : "NO") << std::endl; + std::cout << "Intersects: " << (intersects ? "YES" : "NO") << std::endl; return 0; } diff --git a/doc/src/examples/algorithms/is_empty.cpp b/doc/src/examples/algorithms/is_empty.cpp index 3f62db7f52..4dd5b6a2f6 100644 --- a/doc/src/examples/algorithms/is_empty.cpp +++ b/doc/src/examples/algorithms/is_empty.cpp @@ -16,7 +16,6 @@ #include #include - int main() { boost::geometry::model::multi_linestring diff --git a/doc/src/examples/algorithms/simplify_insert.cpp b/doc/src/examples/algorithms/simplify_insert.cpp index 457fd6b7ef..c4566e1afd 100644 --- a/doc/src/examples/algorithms/simplify_insert.cpp +++ b/doc/src/examples/algorithms/simplify_insert.cpp @@ -18,18 +18,12 @@ int main() { - using P = boost::geometry::model::d2::point_xy; - using L = boost::geometry::model::linestring

; - - L line; - line.push_back(P(1.1, 1.1)); - line.push_back(P(2.5, 2.1)); - line.push_back(P(3.1, 3.1)); - line.push_back(P(4.9, 1.1)); - line.push_back(P(3.1, 1.9)); + using L = boost::geometry::model::linestring>; + L const line{{1.1, 1.1}, {2.5, 2.1}, {3.1, 3.1}, {4.9, 1.1}, {3.1, 1.9}}; L simplified; - boost::geometry::simplify_inserter(line, std::back_inserter(simplified), 0.5); + + boost::geometry::detail::simplify::simplify_insert(line, std::back_inserter(simplified), 0.5); std::cout << " original: " << boost::geometry::dsv(line) << std::endl diff --git a/doc/src/examples/algorithms/simplify_insert_with_strategy.cpp b/doc/src/examples/algorithms/simplify_insert_with_strategy.cpp deleted file mode 100644 index 4580fff970..0000000000 --- a/doc/src/examples/algorithms/simplify_insert_with_strategy.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// QuickBook Example - -// Copyright (c) 2011-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) - -//[simplify_inserter -//` Simplify a linestring using an output iterator - -#include - -#include -#include -#include - -int main() -{ - using P = boost::geometry::model::d2::point_xy; - using L = boost::geometry::model::linestring

; - - 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); - - using DS = boost::geometry::strategy::distance::projected_point; - using simplification = boost::geometry::strategy::simplify::douglas_peucker; - - L simplified; - boost::geometry::simplify_inserter(line, std::back_inserter(simplified), 0.5, simplification()); //std::ostream_iterator

(std::cout, "\n"), 0.5);//); - //std::cout << simplified[0]; - //boost::geometry::simplify_inserter(line, std::ostream_iterator

(std::cout, "\n"), 0.5);//, simplification()); - - std::ostream_iterator

out(std::cout, "\n"); - std::copy(simplified.begin(), simplified.end(), out); - - std::cout - << " original: " << boost::geometry::dsv(line) << std::endl - << "simplified: " << boost::geometry::dsv(simplified) << std::endl; - - return 0; -} - -//] - - -//[simplify_inserter_output -/*` -Output: -[pre -simplify_inserter: 16 -simplify_inserter: 0.339837 -] -*/ -//] -/* -OUTPUT -POINT(1.1 1.1) original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) -simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) -*/ -/* -OUTPUT -POINT(1.1 1.1) original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) -simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) -*/ -/* -OUTPUT -POINT(1.1 1.1) original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) -simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9)) -*/ diff --git a/doc/src/examples/arithmetic/CMakeLists.txt b/doc/src/examples/arithmetic/CMakeLists.txt new file mode 100644 index 0000000000..77af2a754d --- /dev/null +++ b/doc/src/examples/arithmetic/CMakeLists.txt @@ -0,0 +1,15 @@ +# 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 + cross_product + dot_product + ) + + boost_geometry_add_example("arithmetic" ${item}) + +endforeach() + diff --git a/doc/src/examples/geometries/CMakeLists.txt b/doc/src/examples/geometries/CMakeLists.txt index db3a759739..95d24ea895 100644 --- a/doc/src/examples/geometries/CMakeLists.txt +++ b/doc/src/examples/geometries/CMakeLists.txt @@ -22,3 +22,5 @@ foreach(item IN ITEMS endforeach() +add_subdirectory(adapted) +add_subdirectory(register) diff --git a/doc/src/examples/geometries/adapted/CMakeLists.txt b/doc/src/examples/geometries/adapted/CMakeLists.txt new file mode 100644 index 0000000000..d1d4066936 --- /dev/null +++ b/doc/src/examples/geometries/adapted/CMakeLists.txt @@ -0,0 +1,20 @@ +# 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 + boost_array + boost_fusion + boost_tuple + c_array + std_array + ) + + boost_geometry_add_example("geometries_adapted" ${item}) + +endforeach() + +add_subdirectory(boost_range) + diff --git a/doc/src/examples/geometries/adapted/boost_range/CMakeLists.txt b/doc/src/examples/geometries/adapted/boost_range/CMakeLists.txt new file mode 100644 index 0000000000..7e536c1f6a --- /dev/null +++ b/doc/src/examples/geometries/adapted/boost_range/CMakeLists.txt @@ -0,0 +1,18 @@ +# 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 + filtered + reversed + sliced + strided + # uniqued Fails to compile, also commented in Jamfile + ) + + boost_geometry_add_example("geometries_adapted_range" ${item}) + +endforeach() + diff --git a/doc/src/examples/geometries/adapted/boost_range/sliced.cpp b/doc/src/examples/geometries/adapted/boost_range/sliced.cpp index 8d5ce4f9ed..319e6da82e 100644 --- a/doc/src/examples/geometries/adapted/boost_range/sliced.cpp +++ b/doc/src/examples/geometries/adapted/boost_range/sliced.cpp @@ -19,15 +19,8 @@ int main() { - using namespace boost::assign; - using xy = boost::geometry::model::d2::point_xy; - boost::geometry::model::linestring line; - line += xy(0, 0); - line += xy(1, 1); - line += xy(2, 2); - line += xy(3, 3); - line += xy(4, 4); + boost::geometry::model::linestring line = {{0, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}}; std::cout << boost::geometry::dsv(line | boost::adaptors::sliced(1, 3)) << std::endl; diff --git a/doc/src/examples/geometries/adapted/boost_range/strided.cpp b/doc/src/examples/geometries/adapted/boost_range/strided.cpp index 7642919553..6d18540979 100644 --- a/doc/src/examples/geometries/adapted/boost_range/strided.cpp +++ b/doc/src/examples/geometries/adapted/boost_range/strided.cpp @@ -19,17 +19,10 @@ int main() { - using namespace boost::assign; using boost::adaptors::strided; using xy = boost::geometry::model::d2::point_xy; - boost::geometry::model::ring ring; - ring += xy(0, 0); - ring += xy(0, 1); - ring += xy(0, 2); - ring += xy(1, 2); - ring += xy(2, 2); - ring += xy(2, 0); + boost::geometry::model::ring ring {{0, 0}, {0, 1}, {0, 2}, {1, 2}, {2, 2}, {2, 0}}; boost::geometry::correct(ring); diff --git a/doc/src/examples/geometries/adapted/boost_range/uniqued.cpp b/doc/src/examples/geometries/adapted/boost_range/uniqued.cpp index 99453cad0f..51512858b0 100644 --- a/doc/src/examples/geometries/adapted/boost_range/uniqued.cpp +++ b/doc/src/examples/geometries/adapted/boost_range/uniqued.cpp @@ -25,22 +25,11 @@ inline bool operator==(xy const& left, xy const& right) return eq(left, right); } - int main() { - using namespace boost::assign; using boost::adaptors::uniqued; - boost::geometry::model::ring ring; - ring += xy(0, 0); - ring += xy(0, 1); - ring += xy(0, 2); - ring += xy(1, 2); - ring += xy(2, 2); - ring += xy(2, 2); - ring += xy(2, 2); - ring += xy(2, 0); - ring += xy(0, 0); + const boost::geometry::model::ring ring = {{0, 0}, {0, 1}, {0, 2}, {1, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 0}, {0, 0}}; std::cout << "Normal: " << boost::geometry::dsv(ring) << std::endl diff --git a/doc/src/examples/geometries/register/CMakeLists.txt b/doc/src/examples/geometries/register/CMakeLists.txt new file mode 100644 index 0000000000..c41901c463 --- /dev/null +++ b/doc/src/examples/geometries/register/CMakeLists.txt @@ -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 + box_templated + box_2d_4values + point + linestring + linestring_templated + ring + ring_templated + multi_point + multi_point_templated + multi_linestring + multi_polygon + ) + + boost_geometry_add_example("geometries_register" ${item}) + +endforeach()