From 9a8b7b46363a130400d203908e6e2666cd47e7e1 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 3 Oct 2021 18:03:35 +0200 Subject: [PATCH 01/16] [core] Specialize point_type for dynamic geometry and geometry collection. --- include/boost/geometry/core/point_type.hpp | 36 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/core/point_type.hpp b/include/boost/geometry/core/point_type.hpp index 696e1e56a..f5d282372 100644 --- a/include/boost/geometry/core/point_type.hpp +++ b/include/boost/geometry/core/point_type.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2020. -// Modifications copyright (c) 2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2020-2021. +// Modifications copyright (c) 2020-2021 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library @@ -21,10 +21,12 @@ #include +#include #include #include #include #include +#include #include @@ -137,6 +139,36 @@ struct point_type }; +template +struct point_type +{ + using geometry_t = typename util::sequence_front + < + typename traits::geometry_types::type + >::type; + using type = typename point_type + < + typename tag::type, + typename util::remove_cptrref::type + >::type; +}; + + +template +struct point_type +{ + using geometry_t = typename util::sequence_front + < + typename traits::geometry_types::type + >::type; + using type = typename point_type + < + typename tag::type, + typename util::remove_cptrref::type + >::type; +}; + + } // namespace core_dispatch #endif // DOXYGEN_NO_DISPATCH From 4c700f9cba068e24cd2c578cb75a29ab21b084a0 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 3 Oct 2021 18:05:44 +0200 Subject: [PATCH 02/16] [envelope][expand] Support dynamic geometry and geometry collection. --- .../detail/envelope/geometry_collection.hpp | 63 +++++++++++++++ .../detail/envelope/implementation.hpp | 3 +- .../algorithms/detail/envelope/interface.hpp | 53 +++++-------- .../algorithms/detail/expand/interface.hpp | 79 +++++-------------- .../strategies/envelope/cartesian.hpp | 7 ++ .../strategies/envelope/geographic.hpp | 10 +++ .../strategies/envelope/spherical.hpp | 7 ++ 7 files changed, 125 insertions(+), 97 deletions(-) create mode 100644 include/boost/geometry/algorithms/detail/envelope/geometry_collection.hpp diff --git a/include/boost/geometry/algorithms/detail/envelope/geometry_collection.hpp b/include/boost/geometry/algorithms/detail/envelope/geometry_collection.hpp new file mode 100644 index 000000000..cf3d044f3 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/envelope/geometry_collection.hpp @@ -0,0 +1,63 @@ +// Boost.Geometry + +// Copyright (c) 2021, Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Distributed under 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) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_GEOMETRY_COLLECTION_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_GEOMETRY_COLLECTION_HPP + + +#include +#include +#include + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +template +struct envelope +{ + template + static inline void apply(Geometry const& geometry, + Box& mbr, + Strategy const& strategy) + { + using strategy_t = decltype(strategy.envelope(geometry, mbr)); + using state_t = typename strategy_t::template multi_state; + + state_t state; + detail::visit_breadth_first([&](auto const& g) + { + if (! geometry::is_empty(g)) + { + Box b; + envelope>::apply(g, b, strategy); + state.apply(b); + } + return true; + }, geometry); + state.result(mbr); + } +}; + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_GEOMETRY_COLLECTION_HPP diff --git a/include/boost/geometry/algorithms/detail/envelope/implementation.hpp b/include/boost/geometry/algorithms/detail/envelope/implementation.hpp index 569c77b03..6e7907bb3 100644 --- a/include/boost/geometry/algorithms/detail/envelope/implementation.hpp +++ b/include/boost/geometry/algorithms/detail/envelope/implementation.hpp @@ -6,9 +6,9 @@ // This file was modified by Oracle on 2015-2021. // Modifications copyright (c) 2015-2021, Oracle and/or its affiliates. - // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -28,6 +28,7 @@ #include #include +#include .hpp> #include #include #include diff --git a/include/boost/geometry/algorithms/detail/envelope/interface.hpp b/include/boost/geometry/algorithms/detail/envelope/interface.hpp index 3f6dece38..70679dd91 100644 --- a/include/boost/geometry/algorithms/detail/envelope/interface.hpp +++ b/include/boost/geometry/algorithms/detail/envelope/interface.hpp @@ -22,16 +22,14 @@ #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_INTERFACE_HPP -#include -#include -#include - #include #include #include #include +#include +#include // For backward compatibility #include #include @@ -39,6 +37,7 @@ #include #include +#include namespace boost { namespace geometry @@ -98,10 +97,10 @@ struct envelope } // namespace resolve_strategy -namespace resolve_variant +namespace resolve_dynamic { -template +template ::type> struct envelope { template @@ -117,38 +116,22 @@ struct envelope }; -template -struct envelope > +template +struct envelope { template - struct visitor: boost::static_visitor + static inline void apply(Geometry const& geometry, + Box& box, + Strategy const& strategy) { - Box& m_box; - Strategy const& m_strategy; - - visitor(Box& box, Strategy const& strategy) - : m_box(box) - , m_strategy(strategy) - {} - - template - void operator()(Geometry const& geometry) const + traits::visit::apply([&](auto const& g) { - envelope::apply(geometry, m_box, m_strategy); - } - }; - - template - static inline void - apply(boost::variant const& geometry, - Box& box, - Strategy const& strategy) - { - boost::apply_visitor(visitor(box, strategy), geometry); + envelope>::apply(g, box, strategy); + }, geometry); } }; -} // namespace resolve_variant +} // namespace resolve_dynamic /*! @@ -172,7 +155,7 @@ struct envelope > template inline void envelope(Geometry const& geometry, Box& mbr, Strategy const& strategy) { - resolve_variant::envelope::apply(geometry, mbr, strategy); + resolve_dynamic::envelope::apply(geometry, mbr, strategy); } /*! @@ -193,7 +176,7 @@ inline void envelope(Geometry const& geometry, Box& mbr, Strategy const& strateg template inline void envelope(Geometry const& geometry, Box& mbr) { - resolve_variant::envelope::apply(geometry, mbr, default_strategy()); + resolve_dynamic::envelope::apply(geometry, mbr, default_strategy()); } @@ -219,7 +202,7 @@ template inline Box return_envelope(Geometry const& geometry, Strategy const& strategy) { Box mbr; - resolve_variant::envelope::apply(geometry, mbr, strategy); + resolve_dynamic::envelope::apply(geometry, mbr, strategy); return mbr; } @@ -242,7 +225,7 @@ template inline Box return_envelope(Geometry const& geometry) { Box mbr; - resolve_variant::envelope::apply(geometry, mbr, default_strategy()); + resolve_dynamic::envelope::apply(geometry, mbr, default_strategy()); return mbr; } diff --git a/include/boost/geometry/algorithms/detail/expand/interface.hpp b/include/boost/geometry/algorithms/detail/expand/interface.hpp index 442a4e011..d2cdf97e7 100644 --- a/include/boost/geometry/algorithms/detail/expand/interface.hpp +++ b/include/boost/geometry/algorithms/detail/expand/interface.hpp @@ -22,22 +22,23 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP -#include -#include -#include #include #include #include #include +#include +#include // For backward compatibility #include #include #include #include +#include + namespace boost { namespace geometry { @@ -97,10 +98,10 @@ struct expand } //namespace resolve_strategy -namespace resolve_variant +namespace resolve_dynamic { -template +template ::type> struct expand { template @@ -116,68 +117,24 @@ struct expand } }; -template -struct expand > +template +struct expand { - template - struct visitor: boost::static_visitor - { - Box& m_box; - Strategy const& m_strategy; - - visitor(Box& box, Strategy const& strategy) - : m_box(box) - , m_strategy(strategy) - {} - - template - void operator()(Geometry const& geometry) const - { - return expand::apply(m_box, geometry, m_strategy); - } - }; - template - static inline void - apply(Box& box, - boost::variant const& geometry, - Strategy const& strategy) + static inline void apply(Box& box, + Geometry const& geometry, + Strategy const& strategy) { - return boost::apply_visitor(visitor(box, strategy), - geometry); + traits::visit::apply([&](auto const& g) + { + expand>::apply(box, g, strategy); + }, geometry); } }; -} // namespace resolve_variant +} // namespace resolve_dynamic -/*** -*! -\brief Expands a box using the extend (envelope) of another geometry (box, point) -\ingroup expand -\tparam Box type of the box -\tparam Geometry of second geometry, to be expanded with the box -\param box box to expand another geometry with, might be changed -\param geometry other geometry -\param strategy_less -\param strategy_greater -\note Strategy is currently ignored - * -template -< - typename Box, typename Geometry, - typename StrategyLess, typename StrategyGreater -> -inline void expand(Box& box, Geometry const& geometry, - StrategyLess const& strategy_less, - StrategyGreater const& strategy_greater) -{ - concepts::check_concepts_and_equal_dimensions(); - - dispatch::expand::apply(box, geometry); -} -***/ - /*! \brief Expands (with strategy) \ingroup expand @@ -195,7 +152,7 @@ will be added to the box template inline void expand(Box& box, Geometry const& geometry, Strategy const& strategy) { - resolve_variant::expand::apply(box, geometry, strategy); + resolve_dynamic::expand::apply(box, geometry, strategy); } /*! @@ -213,7 +170,7 @@ added to the box template inline void expand(Box& box, Geometry const& geometry) { - resolve_variant::expand::apply(box, geometry, default_strategy()); + resolve_dynamic::expand::apply(box, geometry, default_strategy()); } }} // namespace boost::geometry diff --git a/include/boost/geometry/strategies/envelope/cartesian.hpp b/include/boost/geometry/strategies/envelope/cartesian.hpp index 3bce5dbc3..3d3605a62 100644 --- a/include/boost/geometry/strategies/envelope/cartesian.hpp +++ b/include/boost/geometry/strategies/envelope/cartesian.hpp @@ -68,6 +68,13 @@ struct cartesian { return strategy::envelope::cartesian(); } + + template + static auto envelope(Geometry const&, Box const&, + typename util::enable_if_geometry_collection_t * = nullptr) + { + return strategy::envelope::cartesian(); + } }; diff --git a/include/boost/geometry/strategies/envelope/geographic.hpp b/include/boost/geometry/strategies/envelope/geographic.hpp index 96940c470..5b824aded 100644 --- a/include/boost/geometry/strategies/envelope/geographic.hpp +++ b/include/boost/geometry/strategies/envelope/geographic.hpp @@ -86,6 +86,16 @@ public: FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } + + template + auto envelope(Geometry const&, Box const&, + typename util::enable_if_geometry_collection_t * = nullptr) const + { + return strategy::envelope::geographic + < + FormulaPolicy, Spheroid, CalculationType + >(base_t::m_spheroid); + } }; diff --git a/include/boost/geometry/strategies/envelope/spherical.hpp b/include/boost/geometry/strategies/envelope/spherical.hpp index 0c5aad62b..cf174ea16 100644 --- a/include/boost/geometry/strategies/envelope/spherical.hpp +++ b/include/boost/geometry/strategies/envelope/spherical.hpp @@ -79,6 +79,13 @@ struct spherical { return strategy::envelope::spherical(); } + + template + static auto envelope(Geometry const&, Box const&, + typename util::enable_if_geometry_collection_t * = nullptr) + { + return strategy::envelope::spherical(); + } }; From 47119631f061591c37fd606602b58fd56398347b Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 3 Oct 2021 18:06:18 +0200 Subject: [PATCH 03/16] [algorithms] Support DG/GC in various algorithms. --- .../boost/geometry/algorithms/centroid.hpp | 49 +++----- include/boost/geometry/algorithms/densify.hpp | 109 ++++++++++++------ .../algorithms/detail/is_valid/interface.hpp | 76 ++++++------ .../boost/geometry/algorithms/num_points.hpp | 75 ++++++------ .../geometry/algorithms/num_segments.hpp | 62 +++++----- .../boost/geometry/algorithms/perimeter.hpp | 68 +++++------ .../boost/geometry/algorithms/simplify.hpp | 105 +++++++++++------ 7 files changed, 307 insertions(+), 237 deletions(-) diff --git a/include/boost/geometry/algorithms/centroid.hpp b/include/boost/geometry/algorithms/centroid.hpp index 621a4f5c0..291560d34 100644 --- a/include/boost/geometry/algorithms/centroid.hpp +++ b/include/boost/geometry/algorithms/centroid.hpp @@ -28,9 +28,6 @@ #include #include #include -#include -#include -#include #include #include @@ -41,15 +38,18 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include +#include // For backward compatibility #include #include @@ -61,6 +61,7 @@ #include #include +#include #include @@ -540,9 +541,9 @@ struct centroid } // namespace resolve_strategy -namespace resolve_variant { +namespace resolve_dynamic { -template +template ::type> struct centroid { template @@ -553,37 +554,22 @@ struct centroid } }; -template -struct centroid > +template +struct centroid { template - struct visitor: boost::static_visitor + static inline void apply(Geometry const& geometry, + Point& out, + Strategy const& strategy) { - Point& m_out; - Strategy const& m_strategy; - - visitor(Point& out, Strategy const& strategy) - : m_out(out), m_strategy(strategy) - {} - - template - void operator()(Geometry const& geometry) const + traits::visit::apply([&](auto const& g) { - centroid::apply(geometry, m_out, m_strategy); - } - }; - - template - static inline void - apply(boost::variant const& geometry, - Point& out, - Strategy const& strategy) - { - boost::apply_visitor(visitor(out, strategy), geometry); + centroid>::apply(g, out, strategy); + }, geometry); } }; -} // namespace resolve_variant +} // namespace resolve_dynamic /*! @@ -604,10 +590,9 @@ struct centroid > */ template -inline void centroid(Geometry const& geometry, Point& c, - Strategy const& strategy) +inline void centroid(Geometry const& geometry, Point& c, Strategy const& strategy) { - resolve_variant::centroid::apply(geometry, c, strategy); + resolve_dynamic::centroid::apply(geometry, c, strategy); } diff --git a/include/boost/geometry/algorithms/densify.hpp b/include/boost/geometry/algorithms/densify.hpp index d601bd3c8..84e32bb2f 100644 --- a/include/boost/geometry/algorithms/densify.hpp +++ b/include/boost/geometry/algorithms/densify.hpp @@ -11,8 +11,14 @@ #define BOOST_GEOMETRY_ALGORITHMS_DENSIFY_HPP +#include +#include +#include + #include +#include #include +#include #include #include #include @@ -20,6 +26,8 @@ #include #include #include +#include +#include // For backward compatibility #include #include #include @@ -28,11 +36,6 @@ #include #include -#include -#include - -#include - namespace boost { namespace geometry { @@ -146,6 +149,15 @@ struct densify_ring : densify_range {}; +struct densify_convert +{ + template + static void apply(GeometryIn const& in, GeometryOut &out, + T const& , Strategy const& ) + { + geometry::convert(in, out); + } +}; }} // namespace detail::densify #endif // DOXYGEN_NO_DETAIL @@ -167,6 +179,26 @@ struct densify : not_implemented {}; +template +struct densify + : geometry::detail::densify::densify_convert +{}; + +template +struct densify + : geometry::detail::densify::densify_convert +{}; + +template +struct densify + : geometry::detail::densify::densify_convert +{}; + +template +struct densify + : geometry::detail::densify::densify_convert +{}; + template struct densify : geometry::detail::densify::densify_range<> @@ -328,9 +360,9 @@ struct densify } // namespace resolve_strategy -namespace resolve_variant { +namespace resolve_dynamic { -template +template ::type> struct densify { template @@ -346,43 +378,48 @@ struct densify } }; -template -struct densify > +template +struct densify { - template - struct visitor: boost::static_visitor - { - Distance const& m_max_distance; - Strategy const& m_strategy; - - visitor(Distance const& max_distance, Strategy const& strategy) - : m_max_distance(max_distance) - , m_strategy(strategy) - {} - - template - void operator()(Geometry const& geometry, Geometry& out) const - { - densify::apply(geometry, out, m_max_distance, m_strategy); - } - }; - template static inline void - apply(boost::variant const& geometry, - boost::variant& out, + apply(Geometry const& geometry, + Geometry& out, Distance const& max_distance, Strategy const& strategy) { - boost::apply_visitor( - visitor(max_distance, strategy), - geometry, - out - ); + traits::visit::apply([&](auto const& g) + { + using geom_t = util::remove_cref_t; + geom_t o; + densify::apply(g, o, max_distance, strategy); + out = std::move(o); + }, geometry); } }; -} // namespace resolve_variant +template +struct densify +{ + template + static inline void + apply(Geometry const& geometry, + Geometry& out, + Distance const& max_distance, + Strategy const& strategy) + { + detail::visit_breadth_first([&](auto const& g) + { + using geom_t = util::remove_cref_t; + geom_t o; + densify::apply(g, o, max_distance, strategy); + traits::emplace_back::apply(out, std::move(o)); + return true; + }, geometry); + } +}; + +} // namespace resolve_dynamic /*! @@ -428,7 +465,7 @@ inline void densify(Geometry const& geometry, geometry::clear(out); - resolve_variant::densify + resolve_dynamic::densify < Geometry >::apply(geometry, out, max_distance, strategy); diff --git a/include/boost/geometry/algorithms/detail/is_valid/interface.hpp b/include/boost/geometry/algorithms/detail/is_valid/interface.hpp index 4f8d1f543..7ee7b38af 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/interface.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/interface.hpp @@ -1,6 +1,6 @@ // Boost.Geometry -// Copyright (c) 2014-2020, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -14,12 +14,11 @@ #include #include -#include -#include -#include - +#include #include #include +#include +#include // For backward compatibility #include #include #include @@ -90,10 +89,10 @@ struct is_valid } // namespace resolve_strategy -namespace resolve_variant +namespace resolve_dynamic { -template +template ::type> struct is_valid { template @@ -110,39 +109,42 @@ struct is_valid } }; -template -struct is_valid > +template +struct is_valid { template - struct visitor : boost::static_visitor + static inline bool apply(Geometry const& geometry, + VisitPolicy& policy_visitor, + Strategy const& strategy) { - visitor(VisitPolicy& policy, Strategy const& strategy) - : m_policy(policy) - , m_strategy(strategy) - {} - - template - bool operator()(Geometry const& geometry) const + bool result = true; + traits::visit::apply([&](auto const& g) { - return is_valid::apply(geometry, m_policy, m_strategy); - } - - VisitPolicy& m_policy; - Strategy const& m_strategy; - }; - - template - static inline bool - apply(boost::variant const& geometry, - VisitPolicy& policy_visitor, - Strategy const& strategy) - { - return boost::apply_visitor(visitor(policy_visitor, strategy), - geometry); + result = is_valid>::apply(g, policy_visitor, strategy); + }, geometry); + return result; } }; -} // namespace resolve_variant +template +struct is_valid +{ + template + static inline bool apply(Geometry const& geometry, + VisitPolicy& policy_visitor, + Strategy const& strategy) + { + bool result = true; + detail::visit_breadth_first([&](auto const& g) + { + result = is_valid>::apply(g, policy_visitor, strategy); + return result; + }, geometry); + return result; + } +}; + +} // namespace resolve_dynamic // Undocumented for now @@ -151,7 +153,7 @@ inline bool is_valid(Geometry const& geometry, VisitPolicy& visitor, Strategy const& strategy) { - return resolve_variant::is_valid::apply(geometry, visitor, strategy); + return resolve_dynamic::is_valid::apply(geometry, visitor, strategy); } @@ -175,7 +177,7 @@ template inline bool is_valid(Geometry const& geometry, Strategy const& strategy) { is_valid_default_policy<> visitor; - return resolve_variant::is_valid::apply(geometry, visitor, strategy); + return resolve_dynamic::is_valid::apply(geometry, visitor, strategy); } /*! @@ -220,7 +222,7 @@ template inline bool is_valid(Geometry const& geometry, validity_failure_type& failure, Strategy const& strategy) { failure_type_policy<> visitor; - bool result = resolve_variant::is_valid::apply(geometry, visitor, strategy); + bool result = resolve_dynamic::is_valid::apply(geometry, visitor, strategy); failure = visitor.failure(); return result; } @@ -271,7 +273,7 @@ inline bool is_valid(Geometry const& geometry, std::string& message, Strategy co { std::ostringstream stream; failing_reason_policy<> visitor(stream); - bool result = resolve_variant::is_valid::apply(geometry, visitor, strategy); + bool result = resolve_dynamic::is_valid::apply(geometry, visitor, strategy); message = stream.str(); return result; } diff --git a/include/boost/geometry/algorithms/num_points.hpp b/include/boost/geometry/algorithms/num_points.hpp index a5d46833f..ee1609dc7 100644 --- a/include/boost/geometry/algorithms/num_points.hpp +++ b/include/boost/geometry/algorithms/num_points.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2014 Mateusz Loskot, London, UK. // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014-2020. -// Modifications copyright (c) 2014-2020, Oracle and/or its affiliates. +// This file was modified by Oracle on 2014-2021. +// Modifications copyright (c) 2014-2021, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -26,21 +26,20 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include #include #include +#include -#include - -#include - +#include // For backward compatibility #include +#include namespace boost { namespace geometry { @@ -140,48 +139,54 @@ struct num_points #endif -namespace resolve_variant +namespace resolve_dynamic { -template +template ::type> struct num_points { - static inline std::size_t apply(Geometry const& geometry, - bool add_for_open) + static inline std::size_t apply(Geometry const& geometry, bool add_for_open) { concepts::check(); return add_for_open - ? dispatch::num_points::apply(geometry) - : dispatch::num_points::apply(geometry); + ? dispatch::num_points::apply(geometry) + : dispatch::num_points::apply(geometry); } }; -template -struct num_points > +template +struct num_points { - struct visitor: boost::static_visitor + static inline std::size_t apply(Geometry const& geometry, bool add_for_open) { - bool m_add_for_open; - - visitor(bool add_for_open): m_add_for_open(add_for_open) {} - - template - inline std::size_t operator()(Geometry const& geometry) const + std::size_t result = 0; + traits::visit::apply([&](auto const& g) { - return num_points::apply(geometry, m_add_for_open); - } - }; - - static inline std::size_t - apply(boost::variant const& geometry, - bool add_for_open) - { - return boost::apply_visitor(visitor(add_for_open), geometry); + result = num_points>::apply(g, add_for_open); + }, geometry); + return result; } }; -} // namespace resolve_variant + +template +struct num_points +{ + static inline std::size_t apply(Geometry const& geometry, bool add_for_open) + { + std::size_t result = 0; + detail::visit_breadth_first([&](auto const& g) + { + result += num_points>::apply(g, add_for_open); + return true; + }, geometry); + return result; + } +}; + + +} // namespace resolve_dynamic /*! @@ -198,7 +203,7 @@ struct num_points > template inline std::size_t num_points(Geometry const& geometry, bool add_for_open = false) { - return resolve_variant::num_points::apply(geometry, add_for_open); + return resolve_dynamic::num_points::apply(geometry, add_for_open); } #if defined(_MSC_VER) diff --git a/include/boost/geometry/algorithms/num_segments.hpp b/include/boost/geometry/algorithms/num_segments.hpp index 4868c09dc..556f8bfe9 100644 --- a/include/boost/geometry/algorithms/num_segments.hpp +++ b/include/boost/geometry/algorithms/num_segments.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014-2020, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -16,22 +16,19 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include #include +#include -#include - +#include // For backward compatibility #include -#include - -#include - +#include namespace boost { namespace geometry { @@ -140,11 +137,11 @@ struct num_segments -namespace resolve_variant +namespace resolve_dynamic { -template +template ::type> struct num_segments { static inline std::size_t apply(Geometry const& geometry) @@ -156,27 +153,38 @@ struct num_segments }; -template -struct num_segments > +template +struct num_segments { - struct visitor: boost::static_visitor + static inline std::size_t apply(Geometry const& geometry) { - template - inline std::size_t operator()(Geometry const& geometry) const + std::size_t result = 0; + traits::visit::apply([&](auto const& g) { - return num_segments::apply(geometry); - } - }; - - static inline std::size_t - apply(boost::variant const& geometry) - { - return boost::apply_visitor(visitor(), geometry); + result = num_segments>::apply(g); + }, geometry); + return result; } }; -} // namespace resolve_variant +template +struct num_segments +{ + static inline std::size_t apply(Geometry const& geometry) + { + std::size_t result = 0; + detail::visit_breadth_first([&](auto const& g) + { + result += num_segments>::apply(g); + return true; + }, geometry); + return result; + } +}; + + +} // namespace resolve_dynamic @@ -193,7 +201,7 @@ struct num_segments > template inline std::size_t num_segments(Geometry const& geometry) { - return resolve_variant::num_segments::apply(geometry); + return resolve_dynamic::num_segments::apply(geometry); } diff --git a/include/boost/geometry/algorithms/perimeter.hpp b/include/boost/geometry/algorithms/perimeter.hpp index ff88857ed..290caeb41 100644 --- a/include/boost/geometry/algorithms/perimeter.hpp +++ b/include/boost/geometry/algorithms/perimeter.hpp @@ -21,20 +21,19 @@ #include -#include -#include -#include - #include #include #include #include // #include +#include #include #include #include +#include +#include // For backward compatibility #include #include @@ -162,9 +161,9 @@ struct perimeter } // namespace resolve_strategy -namespace resolve_variant { +namespace resolve_dynamic { -template +template ::type> struct perimeter { template @@ -176,39 +175,40 @@ struct perimeter } }; -template -struct perimeter > +template +struct perimeter { - typedef typename default_length_result - < - boost::variant - >::type result_type; - template - struct visitor: boost::static_visitor + static inline typename default_length_result::type + apply(Geometry const& geometry, Strategy const& strategy) { - Strategy const& m_strategy; - - visitor(Strategy const& strategy): m_strategy(strategy) {} - - template - typename default_length_result::type - operator()(Geometry const& geometry) const + typename default_length_result::type result = 0; + traits::visit::apply([&](auto const& g) { - return perimeter::apply(geometry, m_strategy); - } - }; - - template - static inline result_type - apply(boost::variant const& geometry, - Strategy const& strategy) - { - return boost::apply_visitor(visitor(strategy), geometry); + result = perimeter>::apply(g, strategy); + }, geometry); + return result; } }; -} // namespace resolve_variant +template +struct perimeter +{ + template + static inline typename default_length_result::type + apply(Geometry const& geometry, Strategy const& strategy) + { + typename default_length_result::type result = 0; + detail::visit_breadth_first([&](auto const& g) + { + result += perimeter>::apply(g, strategy); + return true; + }, geometry); + return result; + } +}; + +} // namespace resolve_dynamic /*! @@ -232,7 +232,7 @@ inline typename default_length_result::type perimeter( Geometry const& geometry) { // detail::throw_on_empty_input(geometry); - return resolve_variant::perimeter::apply(geometry, default_strategy()); + return resolve_dynamic::perimeter::apply(geometry, default_strategy()); } /*! @@ -254,7 +254,7 @@ inline typename default_length_result::type perimeter( Geometry const& geometry, Strategy const& strategy) { // detail::throw_on_empty_input(geometry); - return resolve_variant::perimeter::apply(geometry, strategy); + return resolve_dynamic::perimeter::apply(geometry, strategy); } }} // namespace boost::geometry diff --git a/include/boost/geometry/algorithms/simplify.hpp b/include/boost/geometry/algorithms/simplify.hpp index bea8f6cba..18626e9bf 100644 --- a/include/boost/geometry/algorithms/simplify.hpp +++ b/include/boost/geometry/algorithms/simplify.hpp @@ -31,15 +31,13 @@ #include #include #include -#include -#include -#include #include #include #include #include #include +#include #include #include #include @@ -50,7 +48,9 @@ #include #include #include +#include +#include // For backward compatibility #include #include @@ -60,6 +60,8 @@ #include #include +#include + #ifdef BOOST_GEOMETRY_DEBUG_DOUGLAS_PEUCKER #include #endif @@ -301,6 +303,23 @@ struct simplify_range_insert }; +struct simplify_copy_assign +{ + template + < + typename In, typename Out, typename Distance, + typename Impl, typename Strategies + > + static inline void apply(In const& in, Out& out, + Distance const& , + Impl const& , + Strategies const& ) + { + out = in; + } +}; + + struct simplify_copy { template @@ -615,6 +634,17 @@ struct simplify } }; +template +struct simplify + : detail::simplify::simplify_copy_assign +{}; + +template +struct simplify + : detail::simplify::simplify_copy_assign +{}; + + // Linestring, keep 2 points (unless those points are the same) template struct simplify @@ -803,9 +833,9 @@ struct simplify_insert } // namespace resolve_strategy -namespace resolve_variant { +namespace resolve_dynamic { -template +template ::type> struct simplify { template @@ -818,43 +848,46 @@ struct simplify } }; -template -struct simplify > +template +struct simplify { template - struct visitor: boost::static_visitor + static inline void apply(Geometry const& geometry, + Geometry& out, + Distance const& max_distance, + Strategy const& strategy) { - Distance const& m_max_distance; - Strategy const& m_strategy; - - visitor(Distance const& max_distance, Strategy const& strategy) - : m_max_distance(max_distance) - , m_strategy(strategy) - {} - - template - void operator()(Geometry const& geometry, Geometry& out) const + traits::visit::apply([&](auto const& g) { - simplify::apply(geometry, out, m_max_distance, m_strategy); - } - }; - - template - static inline void - apply(boost::variant const& geometry, - boost::variant& out, - Distance const& max_distance, - Strategy const& strategy) - { - boost::apply_visitor( - visitor(max_distance, strategy), - geometry, - out - ); + using geom_t = util::remove_cref_t; + geom_t o; + simplify::apply(g, o, max_distance, strategy); + out = std::move(o); + }, geometry); } }; -} // namespace resolve_variant +template +struct simplify +{ + template + static inline void apply(Geometry const& geometry, + Geometry& out, + Distance const& max_distance, + Strategy const& strategy) + { + detail::visit_breadth_first([&](auto const& g) + { + using geom_t = util::remove_cref_t; + geom_t o; + simplify::apply(g, o, max_distance, strategy); + traits::emplace_back::apply(out, std::move(o)); + return true; + }, geometry); + } +}; + +} // namespace resolve_dynamic /*! @@ -882,7 +915,7 @@ inline void simplify(Geometry const& geometry, Geometry& out, geometry::clear(out); - resolve_variant::simplify::apply(geometry, out, max_distance, strategy); + resolve_dynamic::simplify::apply(geometry, out, max_distance, strategy); } From 90bbacf5e092edc95ac401f44ecff1b430078a3d Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 3 Oct 2021 18:06:56 +0200 Subject: [PATCH 04/16] [test] Add DG/GC tests for various algorithms. --- test/algorithms/densify.cpp | 15 ++++++- .../envelope_expand/test_envelope.hpp | 5 +++ test/algorithms/is_valid.cpp | 41 ++++++++++++++++- test/algorithms/num_points.cpp | 16 +++++++ test/algorithms/num_segments.cpp | 16 ++++++- test/algorithms/simplify.cpp | 16 +++++++ test/algorithms/test_perimeter.hpp | 31 ++++++++++--- test/algorithms/test_simplify.hpp | 45 ++++++++++++++++--- 8 files changed, 170 insertions(+), 15 deletions(-) diff --git a/test/algorithms/densify.cpp b/test/algorithms/densify.cpp index bf723bbc1..78aa81ea3 100644 --- a/test/algorithms/densify.cpp +++ b/test/algorithms/densify.cpp @@ -1,7 +1,7 @@ // Boost.Geometry // Unit Test -// Copyright (c) 2017-2018, Oracle and/or its affiliates. +// Copyright (c) 2017-2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -9,6 +9,8 @@ // http://www.boost.org/users/license.html +#include + #include #include @@ -159,6 +161,17 @@ inline void test_geometry(std::string const& wkt, Check const& check) bg::densify(g, o, max_distance); check_result(g, o, max_distance, def_s, check); + + using variant_t = boost::variant::type>; + variant_t v = g, vo; + bg::densify(v, vo, max_distance); + + check(v, vo, def_s); + + bg::model::geometry_collection gc{v}, gco; + bg::densify(gc, gco, max_distance); + + check(gc, gco, def_s); } { diff --git a/test/algorithms/envelope_expand/test_envelope.hpp b/test/algorithms/envelope_expand/test_envelope.hpp index 64792366c..0873d81ba 100644 --- a/test/algorithms/envelope_expand/test_envelope.hpp +++ b/test/algorithms/envelope_expand/test_envelope.hpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -97,6 +98,10 @@ void test_envelope(std::string const& wkt, check_result::type::value> ::apply(b, x1, y1, z1, x2, y2, z2); + bg::model::geometry_collection> gc{v}; + bg::envelope(gc, b); + check_result::type::value> + ::apply(b, x1, y1, z1, x2, y2, z2); } diff --git a/test/algorithms/is_valid.cpp b/test/algorithms/is_valid.cpp index 9c9ca4dde..f74b0b23c 100644 --- a/test/algorithms/is_valid.cpp +++ b/test/algorithms/is_valid.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014-2018, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -27,6 +27,8 @@ #include #include +#include + BOOST_AUTO_TEST_CASE( test_is_valid_point ) { #ifdef BOOST_GEOMETRY_TEST_DEBUG @@ -1414,3 +1416,40 @@ BOOST_AUTO_TEST_CASE( test_is_valid_variant ) vg = invalid_polygon; test::apply("v04", vg, false); } + +BOOST_AUTO_TEST_CASE( test_is_valid_geometry_collection ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl; + std::cout << "************************************" << std::endl; + std::cout << " is_valid: geometry collection" << std::endl; + std::cout << "************************************" << std::endl; +#endif + + using polygon_type = bg::model::polygon; // cw, closed + using variant_type = boost::variant + < + linestring_type, multi_linestring_type, polygon_type + >; + using gc_type = bg::model::geometry_collection; + + typedef test_valid_variant test; + + gc_type gc; + + linestring_type valid_linestring = + from_wkt("LINESTRING(0 0,1 0)"); + multi_linestring_type invalid_multi_linestring = + from_wkt("MULTILINESTRING((0 0,1 0),(0 0))"); + polygon_type valid_polygon = + from_wkt("POLYGON((0 0,1 1,1 0,0 0))"); + polygon_type invalid_polygon = + from_wkt("POLYGON((0 0,2 2,2 0,1 0))"); + + gc = {valid_linestring, valid_polygon}; + test::apply("gc01", gc, true); + gc = {invalid_multi_linestring, valid_polygon}; + test::apply("gc02", gc, false); + gc = {valid_linestring, invalid_polygon}; + test::apply("gc03", gc, false); +} diff --git a/test/algorithms/num_points.cpp b/test/algorithms/num_points.cpp index 6d24f43f0..997023701 100644 --- a/test/algorithms/num_points.cpp +++ b/test/algorithms/num_points.cpp @@ -6,6 +6,10 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021, Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // 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) @@ -67,6 +71,12 @@ int test_main(int, char* []) typedef bg::model::polygon open_polygon; typedef bg::model::multi_polygon open_multi_polygon; + using variant = boost::variant; + using open_variant = boost::variant; + + using geometry_collection = bg::model::geometry_collection; + using open_geometry_collection = bg::model::geometry_collection; + test_num_points("POINT(0 0)", 1u); test_num_points("LINESTRING(0 0,1 1)", 2u); test_num_points("LINESTRING(0 0,1 1)", 2u); @@ -89,6 +99,12 @@ int test_main(int, char* []) test_num_points("MULTIPOLYGON(((0 0,0 10,10 10,10 0)),((0 10,1 10,1 9)))", 7u, 9u); test_num_points("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 10,1 10,1 9,0 10)))", 7u, 9u); + test_num_points("POLYGON((0 0,1 1,0 1,0 0))", 4u); + test_num_points("POLYGON((0 0,1 1,0 1))", 3u, 4u); + + test_num_points("GEOMETRYCOLLECTION(POLYGON((0 0,1 1,0 1,0 0)),LINESTRING(0 0,1 1))", 6u); + test_num_points("GEOMETRYCOLLECTION(POLYGON((0 0,1 1,0 1)),LINESTRING(0 0,1 1))", 5u, 6u); + return 0; } diff --git a/test/algorithms/num_segments.cpp b/test/algorithms/num_segments.cpp index f6f0ddbf1..7b1143d7c 100644 --- a/test/algorithms/num_segments.cpp +++ b/test/algorithms/num_segments.cpp @@ -1,9 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -289,3 +290,16 @@ BOOST_AUTO_TEST_CASE( test_variant ) variant_geometry = p_closed; tester::apply(variant_geometry, 4); } + +BOOST_AUTO_TEST_CASE( test_geometry_collection ) +{ + using variant = boost::variant; + using geometry_collection = bg::model::geometry_collection; + + using tester = test_num_segments; + + geometry_collection gc; + bg::read_wkt("GEOMETRYCOLLECTION(LINESTRING(0 0,1 1,2 2),POLYGON((0 0,0 1,1 1,1 0,0 0)))", gc); + + tester::apply(gc, 6); +} diff --git a/test/algorithms/simplify.cpp b/test/algorithms/simplify.cpp index 9ee2fbbdc..6ef7c6cb0 100644 --- a/test/algorithms/simplify.cpp +++ b/test/algorithms/simplify.cpp @@ -5,6 +5,10 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -222,6 +226,18 @@ void test_all() "POINT(0 0)", "POINT(0 0)", 1.0); + test_geometry >( + "SEGMENT(0 0, 1 1)", + "SEGMENT(0 0, 1 1)", 1.0); + + test_geometry >( + "BOX(0 0, 1 1)", + "BOX(0 0, 1 1)", 1.0); + + test_geometry >( + "MULTIPOINT(0 0, 1 1, 2 2)", + "MULTIPOINT(0 0, 1 1, 2 2)", 1.0); + // RING: check compilation and behaviour test_geometry >( diff --git a/test/algorithms/test_perimeter.hpp b/test/algorithms/test_perimeter.hpp index 32a5defb6..0ba9a675e 100644 --- a/test/algorithms/test_perimeter.hpp +++ b/test/algorithms/test_perimeter.hpp @@ -2,6 +2,11 @@ // Unit Test // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021, Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // 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) @@ -15,6 +20,7 @@ #include #include +#include #include #include @@ -37,6 +43,16 @@ void test_perimeter(Geometry const& geometry, long double expected_perimeter) #endif BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); + + boost::variant v(geometry); + perimeter = bg::perimeter(v); + + BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); + + bg::model::geometry_collection> gc{v}; + perimeter = bg::perimeter(gc); + + BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); } @@ -58,6 +74,16 @@ void test_perimeter(Geometry const& geometry, long double expected_perimeter, St #endif BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); + + boost::variant v(geometry); + perimeter = bg::perimeter(v, strategy); + + BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); + + bg::model::geometry_collection> gc{v}; + perimeter = bg::perimeter(gc, strategy); + + BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001); } template @@ -65,12 +91,7 @@ void test_geometry(std::string const& wkt, double expected_perimeter) { Geometry geometry; bg::read_wkt(wkt, geometry); - boost::variant v(geometry); - test_perimeter(geometry, expected_perimeter); -#if !defined(BOOST_GEOMETRY_TEST_DEBUG) - test_perimeter(v, expected_perimeter); -#endif } template diff --git a/test/algorithms/test_simplify.hpp b/test/algorithms/test_simplify.hpp index 2ae96d58b..352c5e881 100644 --- a/test/algorithms/test_simplify.hpp +++ b/test/algorithms/test_simplify.hpp @@ -2,6 +2,11 @@ // Unit Test // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // 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) @@ -18,11 +23,24 @@ #include #include #include +#include #include #include #include +template ::type> +struct boost_variant_type +{ + using type = boost::variant::type>; +}; + +template +struct boost_variant_type +{ + using type = boost::variant; +}; + template < typename GeometryForTag, @@ -158,8 +176,9 @@ void test_geometry(std::string const& wkt, bg::read_wkt(wkt, geometry); bg::read_wkt(expected_wkt, expected); - boost::variant v(geometry); - + using variant_t = typename boost_variant_type::type; + variant_t v(geometry); + // Define default strategy for testing typedef bg::strategy::simplify::douglas_peucker < @@ -167,15 +186,27 @@ void test_geometry(std::string const& wkt, bg::strategy::distance::projected_point > dp; + BOOST_CONCEPT_ASSERT((bg::concepts::SimplifyStrategy)); + check_geometry(geometry, expected, distance); check_geometry(v, expected, distance); - - - BOOST_CONCEPT_ASSERT( (bg::concepts::SimplifyStrategy) ); - + check_geometry(geometry, expected, distance, dp()); check_geometry(v, expected, distance, dp()); + // For now check GC here because it's not supported by equals() + { + using gc_t = bg::model::geometry_collection; + gc_t gc{v}; + gc_t gc_simplified; + bg::simplify(gc, gc_simplified, distance); + bg::detail::visit_breadth_first([&](auto const& g) + { + test_equality::apply(g, expected); + return false; + }, gc_simplified); + } + // Check inserter (if applicable) test_inserter < @@ -217,7 +248,7 @@ void test_geometry(std::string const& wkt, bg::correct_closure(geometry); bg::correct_closure(expected); - boost::variant v(geometry); + typename boost_variant_type::type v(geometry); BOOST_CONCEPT_ASSERT( (bg::concepts::SimplifyStrategy::type>) ); From c7dea67fa4f59ff4ed50a51befc8e271a08d61fc Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 3 Oct 2021 20:38:06 +0200 Subject: [PATCH 05/16] [self_turns] Pass AssignPolicy correctly and use strategy converter for backward compatibility. --- .../detail/is_valid/has_valid_self_turns.hpp | 18 +-- .../detail/overlay/self_turn_points.hpp | 109 +++++++++++++++--- 2 files changed, 98 insertions(+), 29 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp b/include/boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp index 6c33961b3..b12c42c8e 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014-2020, Oracle and/or its affiliates. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -54,11 +54,6 @@ private: CSTag >::type rescale_policy_type; - typedef detail::overlay::get_turn_info - < - detail::overlay::assign_null_policy - > turn_policy; - public: typedef detail::overlay::turn_info < @@ -88,12 +83,11 @@ public: > interrupt_policy; // Calculate self-turns, skipping adjacent segments - detail::self_get_turn_points::self_turns(geometry, - strategy, - robust_policy, - turns, - interrupt_policy, - 0, true); + detail::self_get_turn_points::self_turns + < + false, detail::overlay::assign_null_policy + >(geometry, strategy, robust_policy, turns, interrupt_policy, + 0, true); if (interrupt_policy.has_intersections) { diff --git a/include/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp b/include/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp index 0845390a9..519c88328 100644 --- a/include/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp @@ -3,9 +3,8 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2017-2020. -// Modifications copyright (c) 2017-2020 Oracle and/or its affiliates. - +// This file was modified by Oracle on 2017-2021. +// Modifications copyright (c) 2017-2021 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -33,6 +32,9 @@ #include #include +#include +#include + #include @@ -271,6 +273,85 @@ struct self_get_turn_points #endif // DOXYGEN_NO_DISPATCH +namespace resolve_strategy +{ + +template +< + bool Reverse, + typename AssignPolicy, + typename Strategies, + bool IsUmbrella = strategies::detail::is_umbrella_strategy::value +> +struct self_get_turn_points +{ + template + < + typename Geometry, + typename RobustPolicy, + typename Turns, + typename InterruptPolicy + > + static inline void apply(Geometry const& geometry, + Strategies const& strategies, + RobustPolicy const& robust_policy, + Turns& turns, + InterruptPolicy& interrupt_policy, + int source_index, + bool skip_adjacent) + { + using turn_policy = detail::overlay::get_turn_info; + + dispatch::self_get_turn_points + < + Reverse, + typename tag::type, + Geometry, + turn_policy + >::apply(geometry, strategies, robust_policy, turns, interrupt_policy, + source_index, skip_adjacent); + } +}; + +template +struct self_get_turn_points +{ + template + < + typename Geometry, + typename RobustPolicy, + typename Turns, + typename InterruptPolicy + > + static inline void apply(Geometry const& geometry, + Strategy const& strategy, + RobustPolicy const& robust_policy, + Turns& turns, + InterruptPolicy& interrupt_policy, + int source_index, + bool skip_adjacent) + { + using strategies::relate::services::strategy_converter; + + self_get_turn_points + < + Reverse, + AssignPolicy, + decltype(strategy_converter::get(strategy)) + >::apply(geometry, + strategy_converter::get(strategy), + robust_policy, + turns, + interrupt_policy, + source_index, + skip_adjacent); + } +}; + + +} // namespace resolve_strategy + + #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace self_get_turn_points { @@ -282,13 +363,13 @@ template bool Reverse, typename AssignPolicy, typename Geometry, - typename IntersectionStrategy, + typename Strategy, typename RobustPolicy, typename Turns, typename InterruptPolicy > inline void self_turns(Geometry const& geometry, - IntersectionStrategy const& strategy, + Strategy const& strategy, RobustPolicy const& robust_policy, Turns& turns, InterruptPolicy& interrupt_policy, @@ -297,14 +378,9 @@ inline void self_turns(Geometry const& geometry, { concepts::check(); - typedef detail::overlay::get_turn_info turn_policy; - - dispatch::self_get_turn_points + resolve_strategy::self_get_turn_points < - Reverse, - typename tag::type, - Geometry, - turn_policy + Reverse, AssignPolicy, Strategy >::apply(geometry, strategy, robust_policy, turns, interrupt_policy, source_index, skip_adjacent); } @@ -351,12 +427,11 @@ inline void self_turns(Geometry const& geometry, geometry::point_order::value >::value; - detail::self_get_turn_points::self_turns + resolve_strategy::self_get_turn_points < - reverse, - AssignPolicy - >(geometry, strategy, robust_policy, turns, interrupt_policy, - source_index, skip_adjacent); + reverse, AssignPolicy, Strategy + >::apply(geometry, strategy, robust_policy, turns, interrupt_policy, + source_index, skip_adjacent); } From b0043abf5bfcdda05667d9cac7c8a660902f7d53 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 5 Oct 2021 23:37:00 +0200 Subject: [PATCH 06/16] [strategies] Fix area strategy converter altered_strategy for boxes. --- include/boost/geometry/strategies/area/geographic.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/strategies/area/geographic.hpp b/include/boost/geometry/strategies/area/geographic.hpp index 342ba45f3..a8d806c39 100644 --- a/include/boost/geometry/strategies/area/geographic.hpp +++ b/include/boost/geometry/strategies/area/geographic.hpp @@ -86,8 +86,11 @@ struct strategy_converter > : strategies::area::geographic(spheroid) {} + using strategies::area::geographic::area; + template - auto area(Geometry const&) const + auto area(Geometry const&, + std::enable_if_t::value> * = nullptr) const { return strategy::area::geographic(this->m_spheroid); } From 9d7485bc27a2a911276f72bacd4d07ac2e92a1be Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 8 Oct 2021 14:08:06 +0200 Subject: [PATCH 07/16] [envelope] Remove characters following #include directive. --- .../geometry/algorithms/detail/envelope/implementation.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/geometry/algorithms/detail/envelope/implementation.hpp b/include/boost/geometry/algorithms/detail/envelope/implementation.hpp index 6e7907bb3..cb4108d16 100644 --- a/include/boost/geometry/algorithms/detail/envelope/implementation.hpp +++ b/include/boost/geometry/algorithms/detail/envelope/implementation.hpp @@ -28,7 +28,7 @@ #include #include -#include .hpp> +#include #include #include #include From da4dee76a7cbd4c9cad99a2ce53b91ac61991878 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Fri, 8 Oct 2021 15:21:39 +0200 Subject: [PATCH 08/16] [test] exclude most of the types, keep only one per family --- test/algorithms/set_operations/union/Jamfile | 3 ++- .../set_operations/union/union_other_types.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/algorithms/set_operations/union/Jamfile b/test/algorithms/set_operations/union/Jamfile index d9b1c04ee..02622230a 100644 --- a/test/algorithms/set_operations/union/Jamfile +++ b/test/algorithms/set_operations/union/Jamfile @@ -25,5 +25,6 @@ test-suite boost-geometry-algorithms-union : algorithms_union_multi ] [ run union_pl_pl.cpp : : : : algorithms_union_pl_pl ] [ run union_tupled.cpp : : : : algorithms_union_tupled ] - [ run union_other_types.cpp : : : : algorithms_union_other_types ] + [ run union_other_types.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE + : algorithms_union_other_types ] ; diff --git a/test/algorithms/set_operations/union/union_other_types.cpp b/test/algorithms/set_operations/union/union_other_types.cpp index d32f8f62c..bd3bb6e89 100644 --- a/test/algorithms/set_operations/union/union_other_types.cpp +++ b/test/algorithms/set_operations/union/union_other_types.cpp @@ -113,6 +113,7 @@ int test_main(int, char* []) using bg::model::d2::point_xy; +#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) // Standard floating point types test_areal>({exclude::hard}); test_areal>({}); @@ -121,23 +122,30 @@ int test_main(int, char* []) // Standard integer types test_areal>({exclude::fp}); test_areal>({exclude::fp}); +#endif test_areal>({exclude::fp}); // Boost multi precision (integer) test_areal>({exclude::fp}); +#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) test_areal>({exclude::fp}); +#endif // Boost multi precision (floating point) +#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) test_areal>>>(); test_areal>>>(); test_areal>>>(); +#endif test_areal>>>(); test_areal>>>({}); // Boost multi precision (rational) test_areal>({exclude::fp}); +#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) test_areal>({exclude::fp}); +#endif // Boost multi precision float128 wrapper, is currently NOT supported // and it is limited to certain compilers anyway @@ -146,8 +154,10 @@ int test_main(int, char* []) // Boost rational (tests compilation) // (the rectangular case is correct; other input might give wrong results) // The int16 version throws a exception +#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) test_areal>>({exclude::all}); test_areal>>({exclude::fp}); +#endif test_areal>>({exclude::fp}); return 0; From 5c4d27e91794d542bc7ae9621976be5b9311ad58 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 11 Oct 2021 11:13:55 +0200 Subject: [PATCH 09/16] Fix c++20 compilation errors related to rational types. --- .../overlay/enrich_intersection_points.hpp | 18 ++++++++---------- .../policies/robustness/segment_ratio.hpp | 17 +++++++++-------- .../strategies/cartesian/intersection.hpp | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp index 58ab4fcdd..7e2b0d0f2 100644 --- a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp @@ -3,9 +3,8 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2017-2020. +// This file was modified by Oracle on 2017-2021. // Modifications copyright (c) 2017-2020 Oracle and/or its affiliates. - // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -353,21 +352,20 @@ inline typename geometry::coordinate_type::type template inline void calculate_remaining_distance(Turns& turns) { - typedef typename boost::range_value::type turn_type; - typedef typename turn_type::turn_operation_type op_type; + using turn_type = typename boost::range_value::type; + using op_type = typename turn_type::turn_operation_type; - for (typename boost::range_iterator::type - it = boost::begin(turns); - it != boost::end(turns); - ++it) + typename op_type::comparable_distance_type const zero_distance = 0; + + for (auto it = boost::begin(turns); it != boost::end(turns); ++it) { turn_type& turn = *it; op_type& op0 = turn.operations[0]; op_type& op1 = turn.operations[1]; - if (op0.remaining_distance != 0 - || op1.remaining_distance != 0) + if (op0.remaining_distance != zero_distance + || op1.remaining_distance != zero_distance) { continue; } diff --git a/include/boost/geometry/policies/robustness/segment_ratio.hpp b/include/boost/geometry/policies/robustness/segment_ratio.hpp index 4a63eb08b..6d50a5b89 100644 --- a/include/boost/geometry/policies/robustness/segment_ratio.hpp +++ b/include/boost/geometry/policies/robustness/segment_ratio.hpp @@ -2,8 +2,8 @@ // Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2016-2020. -// Modifications copyright (c) 2016-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2016-2021. +// Modifications copyright (c) 2016-2021 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -53,8 +53,8 @@ struct less template static inline bool apply(Ratio const& lhs, Ratio const& rhs) { - BOOST_GEOMETRY_ASSERT(lhs.denominator() != 0); - BOOST_GEOMETRY_ASSERT(rhs.denominator() != 0); + BOOST_GEOMETRY_ASSERT(lhs.denominator() != Type(0)); + BOOST_GEOMETRY_ASSERT(rhs.denominator() != Type(0)); Type const a = lhs.numerator() / lhs.denominator(); Type const b = rhs.numerator() / rhs.denominator(); return ! geometry::math::equals(a, b) @@ -86,8 +86,8 @@ struct equal template static inline bool apply(Ratio const& lhs, Ratio const& rhs) { - BOOST_GEOMETRY_ASSERT(lhs.denominator() != 0); - BOOST_GEOMETRY_ASSERT(rhs.denominator() != 0); + BOOST_GEOMETRY_ASSERT(lhs.denominator() != Type(0)); + BOOST_GEOMETRY_ASSERT(rhs.denominator() != Type(0)); Type const a = lhs.numerator() / lhs.denominator(); Type const b = rhs.numerator() / rhs.denominator(); return geometry::math::equals(a, b); @@ -144,7 +144,8 @@ class segment_ratio // Type-alias for the type itself using thistype = segment_ratio; -public : +public: + using int_type = Type; inline segment_ratio() : m_numerator(0) @@ -231,7 +232,7 @@ public : ); } - inline bool is_zero() const { return math::equals(m_numerator, 0); } + inline bool is_zero() const { return math::equals(m_numerator, Type(0)); } inline bool is_one() const { return math::equals(m_numerator, m_denominator); } inline bool on_segment() const { diff --git a/include/boost/geometry/strategies/cartesian/intersection.hpp b/include/boost/geometry/strategies/cartesian/intersection.hpp index d7b2754c0..1f8a824ad 100644 --- a/include/boost/geometry/strategies/cartesian/intersection.hpp +++ b/include/boost/geometry/strategies/cartesian/intersection.hpp @@ -174,7 +174,7 @@ struct cartesian_segments // Up to now, division was postponed. Here we divide using numerator/ // denominator. In case of integer this results in an integer // division. - BOOST_GEOMETRY_ASSERT(ratio.denominator() != 0); + BOOST_GEOMETRY_ASSERT(ratio.denominator() != typename SegmentRatio::int_type(0)); typedef typename promote_integral::type calc_type; From ee6589b5c93cf5b7f15069624600c422fe5d72a9 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 11 Oct 2021 13:31:22 +0200 Subject: [PATCH 10/16] [convex_hull] Fix compilation error with gcc-5. --- .../geometry/algorithms/detail/convex_hull/interface.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp b/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp index c7823b1b8..0fa011282 100644 --- a/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp +++ b/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp @@ -98,7 +98,7 @@ struct input_geometry_collection_proxy { detail::visit_breadth_first([&](auto const& g) { - call_for_non_boxes(g, fun); + input_geometry_collection_proxy::call_for_non_boxes(g, fun); return true; }, m_geometry); @@ -262,7 +262,7 @@ struct convex_hull std::vector box_rings; detail::visit_breadth_first([&](auto const& g) { - add_ring_for_box(box_rings, g, strategy); + convex_hull::add_ring_for_box(box_rings, g, strategy); return true; }, geometry); From 820451a0c96531865581bb4433620eea53ee6a1d Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 7 Oct 2021 19:01:04 +0200 Subject: [PATCH 11/16] [distance] Add support for DG/GC in distance(). --- .../detail/distance/geometry_collection.hpp | 236 ++++++++++++++++ .../detail/distance/implementation.hpp | 3 +- .../algorithms/detail/distance/interface.hpp | 254 +++++------------- .../geometry/algorithms/detail/visit.hpp | 56 +++- .../geometry/algorithms/dispatch/distance.hpp | 29 +- include/boost/geometry/core/geometry_id.hpp | 22 +- test/algorithms/distance/distance.cpp | 20 ++ 7 files changed, 418 insertions(+), 202 deletions(-) create mode 100644 include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp b/include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp new file mode 100644 index 000000000..f57c934fb --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp @@ -0,0 +1,236 @@ +// Boost.Geometry + +// Copyright (c) 2021 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_GEOMETRY_COLLECTION_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_GEOMETRY_COLLECTION_HPP + + +#include + +#include +#include +#include +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + +template +inline auto geometry_to_collection(Geometry const& geometry, + GeometryCollection const& collection, + Strategies const& strategies) +{ + using result_t = typename geometry::distance_result::type; + result_t result = 0; + bool is_first = true; + detail::visit_breadth_first([&](auto const& g) + { + result_t r = dispatch::distance + < + Geometry, util::remove_cref_t, Strategies + >::apply(geometry, g, strategies); + if (is_first) + { + result = r; + is_first = false; + } + else if (r < result) + { + result = r; + } + return result > result_t(0); + }, collection); + + return result; +} + +template +inline auto collection_to_collection(GeometryCollection1 const& collection1, + GeometryCollection2 const& collection2, + Strategies const& strategies) +{ + using result_t = typename geometry::distance_result::type; + + using point1_t = typename geometry::point_type::type; + using box1_t = model::box; + using point2_t = typename geometry::point_type::type; + using box2_t = model::box; + + using rtree_value_t = std::pair::type>; + using rtree_params_t = index::parameters, Strategies>; + using rtree_t = index::rtree; + + rtree_params_t rtree_params(index::rstar<4>(), strategies); + rtree_t rtree(rtree_params); + + // Build rtree of boxes and iterators of elements of GC1 + // TODO: replace this with visit_breadth_first_iterator to avoid creating an unnecessary container? + { + std::vector values; + visit_breadth_first_impl::apply([&](auto & g1, auto it) + { + box1_t b1 = geometry::return_envelope(g1, strategies); + geometry::detail::expand_by_epsilon(b1); + values.emplace_back(b1, it); + return true; + }, collection1); + rtree_t rt(values.begin(), values.end(), rtree_params); + rtree = std::move(rt); + } + + result_t const zero = 0; + auto const rtree_qend = rtree.qend(); + + result_t result = 0; + bool is_first = true; + visit_breadth_first([&](auto const& g2) + { + box2_t b2 = geometry::return_envelope(g2, strategies); + geometry::detail::expand_by_epsilon(b2); + + for (auto it = rtree.qbegin(index::nearest(b2, rtree.size())) ; it != rtree_qend ; ++it) + { + // If the distance between boxes is greater than or equal to previously found + // distance between geometries then stop processing the current b2 because no + // closer b1 will be found + if (! is_first) + { + result_t const bd = dispatch::distance + < + box1_t, box2_t, Strategies + >::apply(it->first, b2, strategies); + if (bd >= result) + { + break; + } + } + + // Boxes are closer than the previously found distance (or it's the first time), + // calculate the new distance between geometries and check if it's closer (or assign it). + traits::iter_visit::apply([&](auto const& g1) + { + result_t const d = dispatch::distance + < + util::remove_cref_t, util::remove_cref_t, Strategies + >::apply(g1, g2, strategies); + if (is_first) + { + result = d; + is_first = false; + } + else if (d < result) + { + result = d; + } + }, it->second); + + // The smallest possible distance found, end searching. + if (! is_first && result <= zero) + { + return false; + } + } + + // Just in case + return is_first || result > zero; + }, collection2); + + return result; +} + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +template +< + typename Geometry, typename GeometryCollection, typename Strategies, typename Tag1 +> +struct distance + < + Geometry, GeometryCollection, Strategies, + Tag1, geometry_collection_tag, void, false + > +{ + static inline auto apply(Geometry const& geometry, + GeometryCollection const& collection, + Strategies const& strategies) + { + assert_dimension_equal(); + + return detail::distance::geometry_to_collection(geometry, collection, strategies); + } +}; + +template +< + typename GeometryCollection, typename Geometry, typename Strategies, typename Tag2 +> +struct distance + < + GeometryCollection, Geometry, Strategies, + geometry_collection_tag, Tag2, void, false + > +{ + static inline auto apply(GeometryCollection const& collection, + Geometry const& geometry, + Strategies const& strategies) + { + assert_dimension_equal(); + + return detail::distance::geometry_to_collection(geometry, collection, strategies); + } +}; + +template +< + typename GeometryCollection1, typename GeometryCollection2, typename Strategies +> +struct distance + < + GeometryCollection1, GeometryCollection2, Strategies, + geometry_collection_tag, geometry_collection_tag, void, false + > +{ + static inline auto apply(GeometryCollection1 const& collection1, + GeometryCollection2 const& collection2, + Strategies const& strategies) + { + assert_dimension_equal(); + + // Build the rtree for the smaller GC (ignoring recursive GCs) + return boost::size(collection1) <= boost::size(collection2) + ? detail::distance::collection_to_collection(collection1, collection2, strategies) + : detail::distance::collection_to_collection(collection2, collection1, strategies); + } +}; + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_BOX_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/implementation.hpp b/include/boost/geometry/algorithms/detail/distance/implementation.hpp index 91b1d817b..8dfe4fec7 100644 --- a/include/boost/geometry/algorithms/detail/distance/implementation.hpp +++ b/include/boost/geometry/algorithms/detail/distance/implementation.hpp @@ -7,9 +7,9 @@ // This file was modified by Oracle on 2014-2021. // Modifications copyright (c) 2014-2021, Oracle and/or its affiliates. - // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/include/boost/geometry/algorithms/detail/distance/interface.hpp b/include/boost/geometry/algorithms/detail/distance/interface.hpp index f39f50554..5fdb66bea 100644 --- a/include/boost/geometry/algorithms/detail/distance/interface.hpp +++ b/include/boost/geometry/algorithms/detail/distance/interface.hpp @@ -8,7 +8,6 @@ // This file was modified by Oracle on 2014-2021. // Modifications copyright (c) 2014-2021, Oracle and/or its affiliates. - // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -28,6 +27,7 @@ #include #include +#include #include // For backward compatibility #include @@ -92,10 +92,9 @@ template struct distance { template - static inline typename distance_result::type - apply(Geometry1 const& geometry1, - Geometry2 const& geometry2, - Strategy const& strategy) + static inline auto apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy) { return dispatch::distance < @@ -123,11 +122,9 @@ struct distance typename Geometry1, typename Geometry2, typename S, std::enable_if_t::value, int> = 0 > - static inline - typename distance_result::type - apply(Geometry1 const& geometry1, - Geometry2 const& geometry2, - S const& strategy) + static inline auto apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + S const& strategy) { typedef strategies::distance::services::strategy_converter converter; typedef decltype(converter::get(strategy)) strategy_type; @@ -143,11 +140,9 @@ struct distance typename Geometry1, typename Geometry2, typename S, std::enable_if_t::value, int> = 0 > - static inline - typename distance_result::type - apply(Geometry1 const& geometry1, - Geometry2 const& geometry2, - S const& strategy) + static inline auto apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + S const& strategy) { typedef strategies::distance::services::custom_strategy_converter < @@ -166,11 +161,9 @@ template <> struct distance { template - static inline - typename distance_result::type - apply(Geometry1 const& geometry1, - Geometry2 const& geometry2, - default_strategy) + static inline auto apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + default_strategy) { typedef typename strategies::distance::services::default_strategy < @@ -187,18 +180,22 @@ struct distance } // namespace resolve_strategy -namespace resolve_variant +namespace resolve_dynamic { -template +template +< + typename Geometry1, typename Geometry2, + typename Tag1 = typename geometry::tag::type, + typename Tag2 = typename geometry::tag::type +> struct distance { template - static inline typename distance_result::type - apply(Geometry1 const& geometry1, - Geometry2 const& geometry2, - Strategy const& strategy) + static inline auto apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy) { return resolve_strategy::distance < @@ -208,174 +205,72 @@ struct distance }; -template -struct distance, Geometry2> +template +struct distance { template - struct visitor: static_visitor - < - typename distance_result - < - variant, - Geometry2, - Strategy - >::type - > + static inline auto apply(DynamicGeometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy) { - Geometry2 const& m_geometry2; - Strategy const& m_strategy; - - visitor(Geometry2 const& geometry2, - Strategy const& strategy) - : m_geometry2(geometry2), - m_strategy(strategy) - {} - - template - typename distance_result::type - operator()(Geometry1 const& geometry1) const + using result_t = typename geometry::distance_result::type; + result_t result = 0; + traits::visit::apply([&](auto const& g1) { - return distance - < - Geometry1, - Geometry2 - >::template apply - < - Strategy - >(geometry1, m_geometry2, m_strategy); - } - }; - - template - static inline typename distance_result - < - variant, - Geometry2, - Strategy - >::type - apply(variant const& geometry1, - Geometry2 const& geometry2, - Strategy const& strategy) - { - return boost::apply_visitor(visitor(geometry2, strategy), geometry1); + result = resolve_strategy::distance + < + Strategy + >::apply(g1, geometry2, strategy); + }, geometry1); + return result; } }; -template -struct distance > +template +struct distance { template - struct visitor: static_visitor - < - typename distance_result - < - Geometry1, - variant, - Strategy - >::type - > + static inline auto apply(Geometry1 const& geometry1, + DynamicGeometry2 const& geometry2, + Strategy const& strategy) { - Geometry1 const& m_geometry1; - Strategy const& m_strategy; - - visitor(Geometry1 const& geometry1, - Strategy const& strategy) - : m_geometry1(geometry1), - m_strategy(strategy) - {} - - template - typename distance_result::type - operator()(Geometry2 const& geometry2) const + using result_t = typename geometry::distance_result::type; + result_t result = 0; + traits::visit::apply([&](auto const& g2) { - return distance - < - Geometry1, - Geometry2 - >::template apply - < - Strategy - >(m_geometry1, geometry2, m_strategy); - } - }; - - template - static inline typename distance_result - < - Geometry1, - variant, - Strategy - >::type - apply( - Geometry1 const& geometry1, - const variant& geometry2, - Strategy const& strategy) - { - return boost::apply_visitor(visitor(geometry1, strategy), geometry2); + result = resolve_strategy::distance + < + Strategy + >::apply(geometry1, g2, strategy); + }, geometry2); + return result; } }; -template -< - BOOST_VARIANT_ENUM_PARAMS(typename T1), - BOOST_VARIANT_ENUM_PARAMS(typename T2) -> -struct distance - < - boost::variant, - boost::variant - > +template +struct distance { template - struct visitor: static_visitor - < - typename distance_result - < - boost::variant, - boost::variant, - Strategy - >::type - > + static inline auto apply(DynamicGeometry1 const& geometry1, + DynamicGeometry2 const& geometry2, + Strategy const& strategy) { - Strategy const& m_strategy; - - visitor(Strategy const& strategy) - : m_strategy(strategy) - {} - - template - typename distance_result::type - operator()(Geometry1 const& geometry1, Geometry2 const& geometry2) const + using result_t = typename geometry::distance_result::type; + result_t result = 0; + traits::visit::apply([&](auto const& g1, auto const& g2) { - return distance - < - Geometry1, - Geometry2 - >::template apply - < - Strategy - >(geometry1, geometry2, m_strategy); - } - }; - - template - static inline typename distance_result - < - boost::variant, - boost::variant, - Strategy - >::type - apply(boost::variant const& geometry1, - boost::variant const& geometry2, - Strategy const& strategy) - { - return boost::apply_visitor(visitor(strategy), geometry1, geometry2); + result = resolve_strategy::distance + < + Strategy + >::apply(g1, g2, strategy); + }, geometry1, geometry2); + return result; } }; -} // namespace resolve_variant +} // namespace resolve_dynamic /*! @@ -415,10 +310,9 @@ for distance, it is probably so that there is no specialization for return_type<...> for your strategy. */ template -inline typename distance_result::type -distance(Geometry1 const& geometry1, - Geometry2 const& geometry2, - Strategy const& strategy) +inline auto distance(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy) { concepts::check(); concepts::check(); @@ -426,7 +320,7 @@ distance(Geometry1 const& geometry1, detail::throw_on_empty_input(geometry1); detail::throw_on_empty_input(geometry2); - return resolve_variant::distance + return resolve_dynamic::distance < Geometry1, Geometry2 @@ -448,13 +342,9 @@ distance(Geometry1 const& geometry1, \qbk{[include reference/algorithms/distance.qbk]} */ template -inline typename default_distance_result::type -distance(Geometry1 const& geometry1, - Geometry2 const& geometry2) +inline auto distance(Geometry1 const& geometry1, + Geometry2 const& geometry2) { - concepts::check(); - concepts::check(); - return geometry::distance(geometry1, geometry2, default_strategy()); } diff --git a/include/boost/geometry/algorithms/detail/visit.hpp b/include/boost/geometry/algorithms/detail/visit.hpp index bbc2f4e86..5fd36cf5c 100644 --- a/include/boost/geometry/algorithms/detail/visit.hpp +++ b/include/boost/geometry/algorithms/detail/visit.hpp @@ -181,6 +181,14 @@ struct visit_breadth_first } }; +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + // NOTE: This specialization works partially like std::visit and partially like // std::ranges::for_each. If the argument is rvalue reference then the elements // are passed into the function as rvalue references as well. This is consistent @@ -193,8 +201,8 @@ struct visit_breadth_first // but in the future there might be some issues. Consider e.g. passing a temporary // mutable proxy range as geometry collection. In such case the elements would be // passed as rvalue references which would be incorrect. -template -struct visit_breadth_first +template +struct visit_breadth_first_impl { template static bool apply(F function, Geom && geom) @@ -217,7 +225,7 @@ struct visit_breadth_first bool result = true; traits::iter_visit>::apply([&](auto && g) { - result = visit_breadth_first::visit_or_enqueue( + result = visit_or_enqueue( function, std::forward(g), queue, it); }, it); @@ -236,7 +244,7 @@ struct visit_breadth_first // so this call can be avoided. traits::iter_visit>::apply([&](auto && g) { - visit_breadth_first::set_iterators(std::forward(g), it, end); + set_iterators(std::forward(g), it, end); }, queue.front()); queue.pop_front(); } @@ -247,7 +255,7 @@ struct visit_breadth_first private: template < - typename F, typename Geom, typename Iterator, + bool PassIter, typename F, typename Geom, typename Iterator, std::enable_if_t::value, int> = 0 > static bool visit_or_enqueue(F &, Geom &&, std::deque & queue, Iterator iter) @@ -257,13 +265,22 @@ private: } template < - typename F, typename Geom, typename Iterator, - std::enable_if_t::value, int> = 0 + bool PassIter, typename F, typename Geom, typename Iterator, + std::enable_if_t::value && ! PassIter, int> = 0 > static bool visit_or_enqueue(F & f, Geom && g, std::deque & , Iterator) { return f(std::forward(g)); } + template + < + bool PassIter, typename F, typename Geom, typename Iterator, + std::enable_if_t::value && PassIter, int> = 0 + > + static bool visit_or_enqueue(F & f, Geom && g, std::deque & , Iterator iter) + { + return f(std::forward(g), iter); + } template < @@ -284,6 +301,31 @@ private: {} }; +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + +// NOTE: This specialization works partially like std::visit and partially like +// std::ranges::for_each. If the argument is rvalue reference then the elements +// are passed into the function as rvalue references as well. This is consistent +// with std::visit but different than std::ranges::for_each. It's done this way +// because visit_breadth_first is also specialized for static and dynamic geometries +// which and references for them has to be propagated like that. If this is not +// desireable then the support for other kinds of geometries should be dropped and +// this algorithm should work only for geometry collection. +// This is not a problem right now because only non-rvalue references are passed +// but in the future there might be some issues. Consider e.g. passing a temporary +// mutable proxy range as geometry collection. In such case the elements would be +// passed as rvalue references which would be incorrect. +template +struct visit_breadth_first + : detail::visit_breadth_first_impl<> +{}; + } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH diff --git a/include/boost/geometry/algorithms/dispatch/distance.hpp b/include/boost/geometry/algorithms/dispatch/distance.hpp index 4d56a3aa0..eb9cd92f6 100644 --- a/include/boost/geometry/algorithms/dispatch/distance.hpp +++ b/include/boost/geometry/algorithms/dispatch/distance.hpp @@ -68,6 +68,29 @@ struct distance_strategy_type {}; +template +< + typename Geometry1, typename Geometry2, typename Strategies, + bool IsDynamicOrGC = util::is_dynamic_geometry::value + || util::is_dynamic_geometry::value + || util::is_geometry_collection::value + || util::is_geometry_collection::value +> +struct distance_strategy_tag +{ + using type = void; +}; + +template +struct distance_strategy_tag +{ + using type = typename strategy::distance::services::tag + < + typename distance_strategy_type::type + >::type; +}; + + template < typename Geometry1, typename Geometry2, @@ -91,11 +114,11 @@ template linear_tag, areal_tag >::type, - typename StrategyTag = typename strategy::distance::services::tag + typename StrategyTag = typename distance_strategy_tag < - typename distance_strategy_type::type + Geometry1, Geometry2, Strategy >::type, - bool Reverse = reverse_dispatch::type::value + bool Reverse = reverse_dispatch::value > struct distance : not_implemented {}; diff --git a/include/boost/geometry/core/geometry_id.hpp b/include/boost/geometry/core/geometry_id.hpp index 27901eca4..2c68cedcd 100644 --- a/include/boost/geometry/core/geometry_id.hpp +++ b/include/boost/geometry/core/geometry_id.hpp @@ -45,39 +45,43 @@ struct geometry_id template <> -struct geometry_id : std::integral_constant {}; +struct geometry_id : std::integral_constant {}; template <> -struct geometry_id : std::integral_constant {}; +struct geometry_id : std::integral_constant {}; template <> -struct geometry_id : std::integral_constant {}; +struct geometry_id : std::integral_constant {}; template <> -struct geometry_id : std::integral_constant {}; +struct geometry_id : std::integral_constant {}; template <> -struct geometry_id : std::integral_constant {}; +struct geometry_id : std::integral_constant {}; template <> -struct geometry_id : std::integral_constant {}; +struct geometry_id : std::integral_constant {}; template <> -struct geometry_id : std::integral_constant {}; +struct geometry_id : std::integral_constant {}; template <> -struct geometry_id : std::integral_constant {}; +struct geometry_id : std::integral_constant {}; template <> -struct geometry_id : std::integral_constant {}; +struct geometry_id : std::integral_constant {}; + + +template <> +struct geometry_id : std::integral_constant {}; } // namespace core_dispatch diff --git a/test/algorithms/distance/distance.cpp b/test/algorithms/distance/distance.cpp index 6f1a7b6a4..da260cb5e 100644 --- a/test/algorithms/distance/distance.cpp +++ b/test/algorithms/distance/distance.cpp @@ -491,6 +491,24 @@ void test_variant() //BOOST_CHECK_CLOSE(bg::distance(point, v2, s), bg::distance(point, point, s), 0.0001); } +template +void test_geometry_collection() +{ + using point_type = bg::model::point; + using segment_type = bg::model::segment; + using box_type = bg::model::box; + using variant_type = boost::variant; + using gc_type = bg::model::geometry_collection; + + point_type p1 {1, 3}, p2 {2, 3}; + segment_type s1 {{2, 2}, {4, 4}}, s2 {{3, 2}, {5, 4}}; + gc_type gc1 {p1, s1}, gc2 {p2, s2}; + + BOOST_CHECK_CLOSE(bg::distance(p1, gc2), bg::distance(p1, p2), 0.0001); + BOOST_CHECK_CLOSE(bg::distance(gc1, s2), bg::distance(s1, s2), 0.0001); + BOOST_CHECK_CLOSE(bg::distance(gc1, gc2), bg::distance(s1, s2), 0.0001); +} + int test_main(int, char* []) { #ifdef TEST_ARRAY @@ -525,5 +543,7 @@ int test_main(int, char* []) test_variant(); test_variant(); + test_geometry_collection(); + return 0; } From e131a0217570d05bc7c8556e6db56b70246e52eb Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Fri, 8 Oct 2021 12:08:31 +0200 Subject: [PATCH 12/16] fix: example of wxwidgets --- example/with_external_libs/CMakeLists.txt | 34 ++++ .../x04_wxwidgets_world_mapper.cpp | 171 ++++++------------ .../x04_wxwidgets_world_mapper_readme.txt | 23 --- 3 files changed, 94 insertions(+), 134 deletions(-) create mode 100644 example/with_external_libs/CMakeLists.txt delete mode 100644 example/with_external_libs/x04_wxwidgets_world_mapper_readme.txt diff --git a/example/with_external_libs/CMakeLists.txt b/example/with_external_libs/CMakeLists.txt new file mode 100644 index 000000000..1d60eb866 --- /dev/null +++ b/example/with_external_libs/CMakeLists.txt @@ -0,0 +1,34 @@ +# Boost.Geometry +# Example CMakeLists.txt building the Boost.Geometry with wxWidget example +# +# Copyright (c) 2021-2021 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) + +cmake_minimum_required(VERSION 3.10) + +project(with_external_libs) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# Set BOOST_ROOT in your environment (this is cmake default) +find_package(Boost) + +# Set WX_ROOT, similarly, also in your environment +set(WX_ROOT $ENV{WX_ROOT}) +message(STATUS "Using wxWidgets from this folder: " $ENV{WX_ROOT}) + +# WX Widgets +link_directories(${WX_ROOT}/lib) +add_executable(wx x04_wxwidgets_world_mapper.cpp) +target_include_directories(wx PRIVATE ${Boost_INCLUDE_DIRS}) +target_include_directories(wx PRIVATE ${WX_ROOT}/include) +target_include_directories(wx PRIVATE ${WX_ROOT}/include/wx-3.1) + +# WX configuration (get the values using wx-config --cxxflags and wx-config --libs) +target_compile_definitions(wx PRIVATE WXUSINGDLL __WXGTK2__ __WXGTK__) +target_link_libraries(wx PRIVATE wx_gtk2u_html-3.1 wx_gtk2u_core-3.1 wx_baseu_net-3.1 wx_baseu-3.1) + diff --git a/example/with_external_libs/x04_wxwidgets_world_mapper.cpp b/example/with_external_libs/x04_wxwidgets_world_mapper.cpp index 49bf0878b..ac3f6322e 100644 --- a/example/with_external_libs/x04_wxwidgets_world_mapper.cpp +++ b/example/with_external_libs/x04_wxwidgets_world_mapper.cpp @@ -1,115 +1,62 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry // -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2021 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) // // wxWidgets World Mapper example +// +// It will show a basic wxWidgets window, displaying world countries, +// highlighting the country under the mouse, and indicating position +// of the mouse in latitude/longitude and in pixels. +// To compile this program: +// Install wxWidgets (if not done before) +// export BOOST_ROOT=..... +// export WX_ROOT=.... (for example /home/myname/mylib/wxWidgets/Linux/x86_64) +// mkdir build +// cd build +// cmake .. -G Ninja +// ninja +// If necessary, CMakeLists.txt should be adapted, the options for wx +// are provided by "wx-config --cxxflags" and "... --libs" +// and might need a change in CMakeLists.txt -// #define EXAMPLE_WX_USE_GRAPHICS_CONTEXT 1 +//#define EXAMPLE_WX_USE_GRAPHICS_CONTEXT 1 #include #include -#include -#include -#include - #include #include #include -#include +#include #include #include -#include - - -// wxWidgets, if these headers are NOT found, adapt include path (and lib path) #include "wx/wx.h" #include "wx/math.h" #include "wx/stockitem.h" - #ifdef EXAMPLE_WX_USE_GRAPHICS_CONTEXT #include "wx/graphics.h" #include "wx/dcgraph.h" #endif -typedef boost::geometry::model::d2::point_xy point_2d; -typedef boost::geometry::model::multi_polygon + +using point_2d = boost::geometry::model::d2::point_xy; +using country_type = boost::geometry::model::multi_polygon < boost::geometry::model::polygon - > country_type; + >; // Adapt wxWidgets points to Boost.Geometry points such that they can be used // in e.g. transformations (see below) BOOST_GEOMETRY_REGISTER_POINT_2D(wxPoint, int, cs::cartesian, x, y) BOOST_GEOMETRY_REGISTER_POINT_2D(wxRealPoint, double, cs::cartesian, x, y) - -// wxWidgets draws using wxPoint*, so we HAVE to use that. -// Therefore have to make a wxPoint* array -// 1) compatible with Boost.Geometry -// 2) compatible with Boost.Range (required by Boost.Geometry) -// 3) compatible with std::back_inserter (required by Boost.Geometry) - -// For compatible 2): -typedef std::pair wxPointPointerPair; - -// For compatible 1): -BOOST_GEOMETRY_REGISTER_RING(wxPointPointerPair); - - -// For compatible 3): -// Specialize back_insert_iterator for the wxPointPointerPair -// (has to be done within "namespace std") -namespace std -{ - -template <> -class back_insert_iterator -{ -public: - typedef std::output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - typedef wxPointPointerPair container_type; - - explicit back_insert_iterator(wxPointPointerPair& x) - : current(boost::begin(x)) - , end(boost::end(x)) - {} - - inline back_insert_iterator& - operator=(wxPoint const& value) - { - // Check if not passed beyond - if (current != end) - { - *current++ = value; - } - return *this; - } - - // Boiler-plate - inline back_insert_iterator& operator*() { return *this; } - inline back_insert_iterator& operator++() { return *this; } - inline back_insert_iterator& operator++(int) { return *this; } - -private: - boost::range_iterator::type current, end; -}; - -} // namespace std - - // ---------------------------------------------------------------------------- // Read an ASCII file containing WKT's // ---------------------------------------------------------------------------- @@ -161,26 +108,29 @@ private: void OnPaint(wxPaintEvent& ); void OnMouseMove(wxMouseEvent&); - typedef boost::geometry::strategy::transform::map_transformer + using map_transformer_type = boost::geometry::strategy::transform::map_transformer < double, 2, 2, true, true - > map_transformer_type; + >; - typedef boost::geometry::strategy::transform::inverse_transformer + using inverse_transformer_type = boost::geometry::strategy::transform::inverse_transformer < double, 2, 2 - > inverse_transformer_type; + >; - boost::shared_ptr m_map_transformer; - boost::shared_ptr m_inverse_transformer; + std::shared_ptr m_map_transformer; + std::shared_ptr m_inverse_transformer; boost::geometry::model::box m_box; std::vector m_countries; - int m_focus; + int m_focus = -1; - wxBrush m_orange; - wxFrame* m_owner; + wxBrush m_orange = wxBrush(wxColour(255, 128, 0), wxBRUSHSTYLE_SOLID); + wxBrush m_blue = wxBrush(wxColour(0, 128, 255), wxBRUSHSTYLE_SOLID); + wxBrush m_green = wxBrush(wxColour(0, 255, 0), wxBRUSHSTYLE_SOLID); + + wxFrame* m_owner = nullptr; DECLARE_EVENT_TABLE() }; @@ -244,19 +194,14 @@ void HelloWorldFrame::OnCloseWindow(wxCloseEvent& ) HelloWorldCanvas::HelloWorldCanvas(wxFrame *frame) : wxWindow(frame, wxID_ANY) , m_owner(frame) - , m_focus(-1) { boost::geometry::assign_inverse(m_box); read_wkt("../data/world.wkt", m_countries, m_box); - m_orange = wxBrush(wxColour(255, 128, 0), wxSOLID); } - void HelloWorldCanvas::OnMouseMove(wxMouseEvent &event) { - namespace bg = boost::geometry; - if (m_inverse_transformer) { // Boiler-plate wxWidgets code @@ -264,19 +209,21 @@ void HelloWorldCanvas::OnMouseMove(wxMouseEvent &event) PrepareDC(dc); m_owner->PrepareDC(dc); - // Transform the point to Lon/Lat + // Transform the point opn the screen back to Lon/Lat point_2d point; - bg::transform(event.GetPosition(), point, *m_inverse_transformer); + boost::geometry::transform(event.GetPosition(), point, + *m_inverse_transformer); // Determine selected object int i = 0; int previous_focus = m_focus; m_focus = -1; - BOOST_FOREACH(country_type const& country, m_countries) + for (country_type const& country : m_countries) { - if (bg::selected(country, point, 0)) + if (boost::geometry::within(point, country)) { m_focus = i; + break; } i++; } @@ -287,7 +234,7 @@ void HelloWorldCanvas::OnMouseMove(wxMouseEvent &event) // Undraw old focus if (previous_focus >= 0) { - dc.SetBrush(*wxWHITE_BRUSH); + dc.SetBrush(m_green); DrawCountry(dc, m_countries[previous_focus]); } // Draw new focus @@ -309,6 +256,11 @@ void HelloWorldCanvas::OnMouseMove(wxMouseEvent &event) void HelloWorldCanvas::OnPaint(wxPaintEvent& ) { + if (m_countries.empty()) + { + return; + } + #if defined(EXAMPLE_WX_USE_GRAPHICS_CONTEXT) wxPaintDC pdc(this); wxGCDC gdc(pdc); @@ -340,11 +292,12 @@ void HelloWorldCanvas::DrawCountries(wxDC& dc) { namespace bg = boost::geometry; - dc.SetBackground(*wxLIGHT_GREY_BRUSH); + dc.SetBackground(m_blue); dc.Clear(); - BOOST_FOREACH(country_type const& country, m_countries) + for (country_type const& country : m_countries) { + dc.SetBrush(m_green); DrawCountry(dc, country); } if (m_focus != -1) @@ -357,27 +310,23 @@ void HelloWorldCanvas::DrawCountries(wxDC& dc) void HelloWorldCanvas::DrawCountry(wxDC& dc, country_type const& country) { - namespace bg = boost::geometry; - - BOOST_FOREACH(bg::model::polygon const& poly, country) + for (auto const& poly : country) { - // Use only exterior ring, holes are (for the moment) ignored. This would need - // a holey-polygon compatible wx object + // Use only exterior ring, holes are (for the moment) ignored. + // This would need a holey-polygon compatible wx object - std::size_t n = boost::size(bg::exterior_ring(poly)); - - boost::scoped_array points(new wxPoint[n]); - - wxPointPointerPair pair = std::make_pair(points.get(), points.get() + n); - bg::transform(bg::exterior_ring(poly), pair, *m_map_transformer); - - dc.DrawPolygon(n, points.get()); + // Define a Boost.Geometry ring of wxPoints + // Behind the scenes that is a vector, and a vector has .data(), + // can be used for the *wxPoint pointer needed for wxWidget DrawPolygon + boost::geometry::model::ring ring; + boost::geometry::transform(boost::geometry::exterior_ring(poly), ring, + *m_map_transformer); + dc.DrawPolygon(ring.size(), ring.data()); } } // ---------------------------------------------------------------------------- - BEGIN_EVENT_TABLE(HelloWorldFrame, wxFrame) EVT_CLOSE(HelloWorldFrame::OnCloseWindow) EVT_MENU(wxID_EXIT, HelloWorldFrame::OnExit) diff --git a/example/with_external_libs/x04_wxwidgets_world_mapper_readme.txt b/example/with_external_libs/x04_wxwidgets_world_mapper_readme.txt deleted file mode 100644 index cba0c8eeb..000000000 --- a/example/with_external_libs/x04_wxwidgets_world_mapper_readme.txt +++ /dev/null @@ -1,23 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// -// Copyright Barend Gehrels 2010, Geodan, 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) - - - -wxWidgets World Mapper example - -It will show a basic wxWidgets window, displaying world countries, highlighting the country under -the mouse, and indicating position of the mouse in latitude/longitude and in pixels. - - -To compile this program: - -Install wxWidgets (if not done before) - -Using Linux/gcc - - check if installation is OK, http://wiki.wxwidgets.org/Installing_and_configuring_under_Ubuntu - - compile using e.g. gcc -o x04_wxwidgets -I../../../.. x04_wxwidgets_world_mapper.cpp `wx-config --cxxflags` `wx-config --libs` - From ba9590f9033e214df952608c8f7ce923ba064c8b Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 17 Oct 2021 19:45:42 +0200 Subject: [PATCH 13/16] [algorithms] Fix too long line and a comment. --- .../detail/distance/geometry_collection.hpp | 3 ++- .../boost/geometry/algorithms/detail/visit.hpp | 17 +++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp b/include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp index f57c934fb..f23095843 100644 --- a/include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp +++ b/include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp @@ -126,7 +126,8 @@ inline auto collection_to_collection(GeometryCollection1 const& collection1, { result_t const d = dispatch::distance < - util::remove_cref_t, util::remove_cref_t, Strategies + util::remove_cref_t, util::remove_cref_t, + Strategies >::apply(g1, g2, strategies); if (is_first) { diff --git a/include/boost/geometry/algorithms/detail/visit.hpp b/include/boost/geometry/algorithms/detail/visit.hpp index 5fd36cf5c..14a763493 100644 --- a/include/boost/geometry/algorithms/detail/visit.hpp +++ b/include/boost/geometry/algorithms/detail/visit.hpp @@ -189,18 +189,6 @@ struct visit_breadth_first namespace detail { -// NOTE: This specialization works partially like std::visit and partially like -// std::ranges::for_each. If the argument is rvalue reference then the elements -// are passed into the function as rvalue references as well. This is consistent -// with std::visit but different than std::ranges::for_each. It's done this way -// because visit_breadth_first is also specialized for static and dynamic geometries -// which and references for them has to be propagated like that. If this is not -// desireable then the support for other kinds of geometries should be dropped and -// this algorithm should work only for geometry collection. -// This is not a problem right now because only non-rvalue references are passed -// but in the future there might be some issues. Consider e.g. passing a temporary -// mutable proxy range as geometry collection. In such case the elements would be -// passed as rvalue references which would be incorrect. template struct visit_breadth_first_impl { @@ -314,9 +302,10 @@ namespace dispatch // are passed into the function as rvalue references as well. This is consistent // with std::visit but different than std::ranges::for_each. It's done this way // because visit_breadth_first is also specialized for static and dynamic geometries -// which and references for them has to be propagated like that. If this is not +// and references for them has to be propagated like that. If this is not // desireable then the support for other kinds of geometries should be dropped and -// this algorithm should work only for geometry collection. +// this algorithm should work only for geometry collection. Or forwarding of rvalue +// references should simply be dropped entirely. // This is not a problem right now because only non-rvalue references are passed // but in the future there might be some issues. Consider e.g. passing a temporary // mutable proxy range as geometry collection. In such case the elements would be From d0838774aae3c73f208f89623e0a1423973381b7 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 19 Oct 2021 14:14:14 +0200 Subject: [PATCH 14/16] [visit] Prefix member function template call with struct name. --- include/boost/geometry/algorithms/detail/visit.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/visit.hpp b/include/boost/geometry/algorithms/detail/visit.hpp index 14a763493..7cbf9e231 100644 --- a/include/boost/geometry/algorithms/detail/visit.hpp +++ b/include/boost/geometry/algorithms/detail/visit.hpp @@ -213,7 +213,7 @@ struct visit_breadth_first_impl bool result = true; traits::iter_visit>::apply([&](auto && g) { - result = visit_or_enqueue( + result = visit_breadth_first_impl::visit_or_enqueue( function, std::forward(g), queue, it); }, it); @@ -232,7 +232,7 @@ struct visit_breadth_first_impl // so this call can be avoided. traits::iter_visit>::apply([&](auto && g) { - set_iterators(std::forward(g), it, end); + visit_breadth_first_impl::set_iterators(std::forward(g), it, end); }, queue.front()); queue.pop_front(); } From bdccf14b10b7d1bbe7ed6dfc1e50940637dd89d5 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 13 Oct 2021 11:31:55 +0200 Subject: [PATCH 15/16] [side] use side from services --- .../strategies/agnostic/point_in_box_by_side.hpp | 13 ++++++++----- .../geometry/strategies/cartesian/intersection.hpp | 5 +++-- .../strategies/cartesian/point_in_poly_winding.hpp | 6 ++++-- .../geometry/strategies/convex_hull/cartesian.hpp | 7 +++++-- .../geometry/strategies/intersection_strategies.hpp | 2 -- .../geometry/strategies/is_convex/cartesian.hpp | 1 + .../boost/geometry/strategies/relate/cartesian.hpp | 5 ++++- 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/include/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp b/include/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp index 8c3f0ba0a..0d0ea8bb0 100644 --- a/include/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp +++ b/include/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp @@ -26,7 +26,7 @@ #include -#include +#include #include #include @@ -118,11 +118,14 @@ struct cartesian_point_box_by_side template static inline bool apply(Point const& point, Box const& box) { + using side_strategy_type + = typename strategy::side::services::default_strategy + ::type; + return within::detail::point_in_box_by_side < within::detail::decide_within - >(point, box, - strategy::side::side_robust()); + >(point, box, side_strategy_type()); } }; @@ -189,11 +192,11 @@ struct cartesian_point_box_by_side template static bool apply(Point const& point, Box const& box) { + using side_strategy_type = typename strategy::side::services::default_strategy::type; return within::detail::point_in_box_by_side < within::detail::decide_covered_by - >(point, box, - strategy::side::side_robust()); + >(point, box, side_strategy_type()); } }; diff --git a/include/boost/geometry/strategies/cartesian/intersection.hpp b/include/boost/geometry/strategies/cartesian/intersection.hpp index 1f8a824ad..dbfa08224 100644 --- a/include/boost/geometry/strategies/cartesian/intersection.hpp +++ b/include/boost/geometry/strategies/cartesian/intersection.hpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include @@ -439,7 +438,9 @@ struct cartesian_segments return Policy::disjoint(); } - typedef side::side_robust side_strategy_type; + using side_strategy_type + = typename side::services::default_strategy + ::type; side_info sides; sides.set<0>(side_strategy_type::apply(q1, q2, p1), side_strategy_type::apply(q1, q2, p2)); diff --git a/include/boost/geometry/strategies/cartesian/point_in_poly_winding.hpp b/include/boost/geometry/strategies/cartesian/point_in_poly_winding.hpp index 3268d5a33..1f989dd43 100644 --- a/include/boost/geometry/strategies/cartesian/point_in_poly_winding.hpp +++ b/include/boost/geometry/strategies/cartesian/point_in_poly_winding.hpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -116,7 +116,9 @@ public: else // count == 2 || count == -2 { // 1 left, -1 right - typedef side::side_robust side_strategy_type; + using side_strategy_type + = typename side::services::default_strategy + ::type; side = side_strategy_type::apply(s1, s2, point); } diff --git a/include/boost/geometry/strategies/convex_hull/cartesian.hpp b/include/boost/geometry/strategies/convex_hull/cartesian.hpp index d19dedeaf..87814e14d 100644 --- a/include/boost/geometry/strategies/convex_hull/cartesian.hpp +++ b/include/boost/geometry/strategies/convex_hull/cartesian.hpp @@ -11,11 +11,11 @@ #ifndef BOOST_GEOMETRY_STRATEGIES_CONVEX_HULL_CARTESIAN_HPP #define BOOST_GEOMETRY_STRATEGIES_CONVEX_HULL_CARTESIAN_HPP +#include #include #include #include -#include #include @@ -42,7 +42,10 @@ public: static auto side() { - return strategy::side::side_robust(); + using side_strategy_type + = typename strategy::side::services::default_strategy + ::type; + return side_strategy_type(); } }; diff --git a/include/boost/geometry/strategies/intersection_strategies.hpp b/include/boost/geometry/strategies/intersection_strategies.hpp index afb1afb5d..e9a17305a 100644 --- a/include/boost/geometry/strategies/intersection_strategies.hpp +++ b/include/boost/geometry/strategies/intersection_strategies.hpp @@ -19,8 +19,6 @@ #include #include -#include - #include #include #include diff --git a/include/boost/geometry/strategies/is_convex/cartesian.hpp b/include/boost/geometry/strategies/is_convex/cartesian.hpp index 1eed10ad3..c6c340fbd 100644 --- a/include/boost/geometry/strategies/is_convex/cartesian.hpp +++ b/include/boost/geometry/strategies/is_convex/cartesian.hpp @@ -15,6 +15,7 @@ #include #include #include +#include namespace boost { namespace geometry diff --git a/include/boost/geometry/strategies/relate/cartesian.hpp b/include/boost/geometry/strategies/relate/cartesian.hpp index 3ddc766a2..8613e6800 100644 --- a/include/boost/geometry/strategies/relate/cartesian.hpp +++ b/include/boost/geometry/strategies/relate/cartesian.hpp @@ -158,7 +158,10 @@ public: static auto side() { - return strategy::side::side_robust(); + using side_strategy_type + = typename strategy::side::services::default_strategy + ::type; + return side_strategy_type(); } // within From ef1b8e33f983f6780b780b13c65cebb94003fb31 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 13 Oct 2021 13:48:21 +0200 Subject: [PATCH 16/16] [side] make the default for no-rescaling triangle to avoid regressions when rescaling is turned off Tests are now tested in both modes --- .../agnostic/point_in_box_by_side.hpp | 4 +++- .../strategy/cartesian/side_by_triangle.hpp | 21 ++++++++++++++++--- .../strategy/cartesian/side_robust.hpp | 3 +++ test/algorithms/buffer/Jamfile | 11 +++++++++- .../set_operations/difference/Jamfile | 11 +++++----- .../difference/difference_multi_spike.cpp | 2 +- .../set_operations/intersection/Jamfile | 8 +++---- test/algorithms/set_operations/union/Jamfile | 11 +++++----- 8 files changed, 49 insertions(+), 22 deletions(-) diff --git a/include/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp b/include/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp index 0d0ea8bb0..448ae4393 100644 --- a/include/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp +++ b/include/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp @@ -192,7 +192,9 @@ struct cartesian_point_box_by_side template static bool apply(Point const& point, Box const& box) { - using side_strategy_type = typename strategy::side::services::default_strategy::type; + using side_strategy_type + = typename strategy::side::services::default_strategy + ::type; return within::detail::point_in_box_by_side < within::detail::decide_covered_by diff --git a/include/boost/geometry/strategy/cartesian/side_by_triangle.hpp b/include/boost/geometry/strategy/cartesian/side_by_triangle.hpp index 56436a2a2..410b1000a 100644 --- a/include/boost/geometry/strategy/cartesian/side_by_triangle.hpp +++ b/include/boost/geometry/strategy/cartesian/side_by_triangle.hpp @@ -24,17 +24,15 @@ #include +#include #include #include -#include #include #include #include -#include - #include @@ -254,6 +252,23 @@ private: } }; +#if ! defined(BOOST_GEOMETRY_USE_RESCALING) +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef side_by_triangle type; +}; + +} + +#endif +#endif + }} // namespace strategy::side }} // namespace boost::geometry diff --git a/include/boost/geometry/strategy/cartesian/side_robust.hpp b/include/boost/geometry/strategy/cartesian/side_robust.hpp index e50e06b7f..61eccb0af 100644 --- a/include/boost/geometry/strategy/cartesian/side_robust.hpp +++ b/include/boost/geometry/strategy/cartesian/side_robust.hpp @@ -18,6 +18,7 @@ #ifndef BOOST_GEOMETRY_STRATEGY_CARTESIAN_SIDE_ROBUST_HPP #define BOOST_GEOMETRY_STRATEGY_CARTESIAN_SIDE_ROBUST_HPP +#include #include #include @@ -177,6 +178,7 @@ public: }; +#ifdef BOOST_GEOMETRY_USE_RESCALING #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS namespace services @@ -190,6 +192,7 @@ struct default_strategy } +#endif #endif }} // namespace strategy::side diff --git a/test/algorithms/buffer/Jamfile b/test/algorithms/buffer/Jamfile index 50bbc99d2..ba7388a24 100644 --- a/test/algorithms/buffer/Jamfile +++ b/test/algorithms/buffer/Jamfile @@ -26,7 +26,16 @@ test-suite boost-geometry-algorithms-buffer [ run buffer_multi_linestring.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_buffer_multi_linestring ] [ run buffer_multi_polygon.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_buffer_multi_polygon ] [ run buffer_linestring_aimes.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_buffer_linestring_aimes ] -# Uncomment next line if you want to test this manually; requires access to data/ folder +# TODO +# [ run buffer_linestring.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_linestring_norescale ] +# [ run buffer_multi_linestring.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_multi_linestring_norescale ] + [ run buffer_ring.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_ring_norescale ] + [ run buffer_polygon.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_polygon_norescale ] + [ run buffer_multi_point.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_multi_point_norescale ] + [ run buffer_multi_polygon.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_multi_polygon_norescale ] + [ run buffer_linestring_aimes.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_linestring_aimes_norescale ] +# Uncomment next lines if you want to test this manually; requires access to data/ folder # [ run buffer_countries.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_buffer_countries ] +# [ run buffer_countries.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_buffer_countries_norescale ] ; diff --git a/test/algorithms/set_operations/difference/Jamfile b/test/algorithms/set_operations/difference/Jamfile index c719158c8..8acb54183 100644 --- a/test/algorithms/set_operations/difference/Jamfile +++ b/test/algorithms/set_operations/difference/Jamfile @@ -16,16 +16,15 @@ test-suite boost-geometry-algorithms-difference : - [ run difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE - : algorithms_difference ] + [ run difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_difference ] + [ run difference_multi.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_difference_multi ] + [ run difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_difference_norescale ] + [ run difference_multi.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_difference_multi_norescale ] + [ run difference_multi_spike.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_difference_multi_spike ] [ run difference_areal_linear.cpp : : : : algorithms_difference_areal_linear ] [ run difference_l_a_sph.cpp : : : : algorithms_difference_l_a_sph ] [ run difference_linear_linear.cpp : : : : algorithms_difference_linear_linear ] - [ run difference_multi.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE - : algorithms_difference_multi ] [ run difference_multi_areal_linear.cpp : : : : algorithms_difference_multi_areal_linear ] - [ run difference_multi_spike.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE - : algorithms_difference_multi_spike ] [ run difference_pl_a.cpp : : : : algorithms_difference_pl_a ] [ run difference_pl_l.cpp : : : : algorithms_difference_pl_l ] [ run difference_pl_pl.cpp : : : : algorithms_difference_pl_pl ] diff --git a/test/algorithms/set_operations/difference/difference_multi_spike.cpp b/test/algorithms/set_operations/difference/difference_multi_spike.cpp index 0a9308d3a..3937ea2df 100644 --- a/test/algorithms/set_operations/difference/difference_multi_spike.cpp +++ b/test/algorithms/set_operations/difference/difference_multi_spike.cpp @@ -51,7 +51,7 @@ void test_spikes_in_ticket_8364() "MULTIPOLYGON(((1032 2556,1778 2556,1032 2130,1032 2556)),((3234 2580,3234 2556,1778 2556,2136 2760,3234 2580)))", count_set(1, 2), -1, expectation_limits(2615783, 2616030), // SQL Server: 2616029.55616044 1, -1, expectation_limits(161054, 161134), // SQL Server: 161054.560110092 - count_set(1, 3)); + count_set(1, 3), ignore_validity); } template diff --git a/test/algorithms/set_operations/intersection/Jamfile b/test/algorithms/set_operations/intersection/Jamfile index 783c20781..e42cf7671 100644 --- a/test/algorithms/set_operations/intersection/Jamfile +++ b/test/algorithms/set_operations/intersection/Jamfile @@ -16,12 +16,12 @@ test-suite boost-geometry-algorithms-intersection : - [ run intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE - : algorithms_intersection ] + [ run intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_intersection ] + [ run intersection_multi.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_intersection_multi ] + [ run intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_intersection_norescale ] + [ run intersection_multi.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_intersection_multi_norescale ] [ run intersection_areal_areal_linear.cpp : : : : algorithms_intersection_areal_areal_linear ] [ run intersection_linear_linear.cpp : : : : algorithms_intersection_linear_linear ] - [ run intersection_multi.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE - : algorithms_intersection_multi ] [ run intersection_pl_a.cpp : : : : algorithms_intersection_pl_a ] [ run intersection_pl_l.cpp : : : : algorithms_intersection_pl_l ] [ run intersection_pl_pl.cpp : : : : algorithms_intersection_pl_pl ] diff --git a/test/algorithms/set_operations/union/Jamfile b/test/algorithms/set_operations/union/Jamfile index 02622230a..0e2e9e48d 100644 --- a/test/algorithms/set_operations/union/Jamfile +++ b/test/algorithms/set_operations/union/Jamfile @@ -16,15 +16,14 @@ test-suite boost-geometry-algorithms-union : - [ run union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE - : algorithms_union ] + [ run union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_union ] + [ run union_multi.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_union_multi ] + [ run union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_union_norescale ] + [ run union_multi.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_NO_ROBUSTNESS : algorithms_union_multi_norescale ] [ run union_aa_geo.cpp : : : : algorithms_union_aa_geo ] [ run union_aa_sph.cpp : : : : algorithms_union_aa_sph ] [ run union_linear_linear.cpp : : : : algorithms_union_linear_linear ] - [ run union_multi.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE - : algorithms_union_multi ] [ run union_pl_pl.cpp : : : : algorithms_union_pl_pl ] [ run union_tupled.cpp : : : : algorithms_union_tupled ] - [ run union_other_types.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE - : algorithms_union_other_types ] + [ run union_other_types.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_union_other_types ] ;