Skip to content

Commit

Permalink
feat: add remaining examples to cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
barendgehrels committed Sep 30, 2024
1 parent 38adce6 commit 310498b
Show file tree
Hide file tree
Showing 21 changed files with 117 additions and 229 deletions.
22 changes: 0 additions & 22 deletions doc/reference/algorithms/difference_inserter.qbk

This file was deleted.

1 change: 1 addition & 0 deletions doc/src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ foreach(item IN ITEMS
endforeach()

add_subdirectory(algorithms)
add_subdirectory(arithmetic)
add_subdirectory(core)
add_subdirectory(geometries)
add_subdirectory(io)
Expand Down
21 changes: 20 additions & 1 deletion doc/src/examples/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

2 changes: 1 addition & 1 deletion doc/src/examples/algorithms/append.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion doc/src/examples/algorithms/assign_box_corners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions doc/src/examples/algorithms/assign_point_from_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions doc/src/examples/algorithms/assign_point_to_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
86 changes: 0 additions & 86 deletions doc/src/examples/algorithms/difference_inserter.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion doc/src/examples/algorithms/for_each_segment_const.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(boost::geometry::length(s));
min_length = std::min(min_length, length);
max_length = std::max(max_length, length);
});
Expand Down
6 changes: 3 additions & 3 deletions doc/src/examples/algorithms/intersects_segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ int main()
{
// Calculate the intersects of a cartesian polygon
using P = boost::geometry::model::d2::point_xy<double>;
bg::model::linestring<P> line1, line2;
boost::geometry::model::linestring<P> 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;
}
Expand Down
1 change: 0 additions & 1 deletion doc/src/examples/algorithms/is_empty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>


int main()
{
boost::geometry::model::multi_linestring
Expand Down
14 changes: 4 additions & 10 deletions doc/src/examples/algorithms/simplify_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@

int main()
{
using P = boost::geometry::model::d2::point_xy<double>;
using L = boost::geometry::model::linestring<P>;

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<boost::geometry::model::d2::point_xy<double>>;

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
Expand Down
71 changes: 0 additions & 71 deletions doc/src/examples/algorithms/simplify_insert_with_strategy.cpp

This file was deleted.

15 changes: 15 additions & 0 deletions doc/src/examples/arithmetic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()

2 changes: 2 additions & 0 deletions doc/src/examples/geometries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ foreach(item IN ITEMS

endforeach()

add_subdirectory(adapted)
add_subdirectory(register)
20 changes: 20 additions & 0 deletions doc/src/examples/geometries/adapted/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

18 changes: 18 additions & 0 deletions doc/src/examples/geometries/adapted/boost_range/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()

9 changes: 1 addition & 8 deletions doc/src/examples/geometries/adapted/boost_range/sliced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@

int main()
{
using namespace boost::assign;

using xy = boost::geometry::model::d2::point_xy<int>;
boost::geometry::model::linestring<xy> 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<xy> line = {{0, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}};

std::cout
<< boost::geometry::dsv(line | boost::adaptors::sliced(1, 3)) << std::endl;
Expand Down
Loading

0 comments on commit 310498b

Please sign in to comment.