diff --git a/.github/workflows/minimal-clang.yml b/.github/workflows/minimal-clang.yml index 5033993a18..782e4d3f84 100644 --- a/.github/workflows/minimal-clang.yml +++ b/.github/workflows/minimal-clang.yml @@ -32,28 +32,28 @@ jobs: include: - b2_toolset: clang-3.9 - b2_cxxstd: 03,11 + b2_cxxstd: 14 version: "3.9" - b2_toolset: clang-4.0 - b2_cxxstd: 03,11 + b2_cxxstd: 14 version: "4.0" - b2_toolset: clang-5.0 - b2_cxxstd: 03,11,14 + b2_cxxstd: 14 version: "5.0" - b2_toolset: clang-6.0 - b2_cxxstd: 03,11,14 + b2_cxxstd: 14 version: "6.0" - b2_toolset: clang-7 - b2_cxxstd: 03,11,14,17 + b2_cxxstd: 14,17 version: "7" - b2_toolset: clang-8 - b2_cxxstd: 03,11,14,17 + b2_cxxstd: 14,17 version: "8" - b2_toolset: clang-9 - b2_cxxstd: 03,11,14,17,2a + b2_cxxstd: 14,17,2a version: "9" - b2_toolset: clang-10 - b2_cxxstd: 03,11,14,17,2a + b2_cxxstd: 14,17,2a version: "10" steps: diff --git a/.github/workflows/minimal-gcc.yml b/.github/workflows/minimal-gcc.yml index bcf1654e3c..101b617652 100644 --- a/.github/workflows/minimal-gcc.yml +++ b/.github/workflows/minimal-gcc.yml @@ -20,7 +20,6 @@ jobs: fail-fast: false matrix: b2_toolset: [ - gcc-4.8, gcc-4.9, gcc-5, gcc-6, @@ -30,26 +29,23 @@ jobs: ] include: - - b2_toolset: gcc-4.8 - b2_cxxstd: 03,11 - version: "4.8" - b2_toolset: gcc-4.9 - b2_cxxstd: 03,11 + b2_cxxstd: 14 version: "4.9" - b2_toolset: gcc-5 - b2_cxxstd: 03,11,14 + b2_cxxstd: 14 version: "5" - b2_toolset: gcc-6 - b2_cxxstd: 03,11,14 + b2_cxxstd: 14 version: "6" - b2_toolset: gcc-7 - b2_cxxstd: 03,11,14,17 + b2_cxxstd: 14,17 version: "7" - b2_toolset: gcc-8 - b2_cxxstd: 03,11,14,17 + b2_cxxstd: 14,17 version: "8" - b2_toolset: gcc-9 - b2_cxxstd: 03,11,14,17,2a + b2_cxxstd: 14,17,2a version: "9" steps: diff --git a/include/boost/geometry/algorithms/area.hpp b/include/boost/geometry/algorithms/area.hpp index b5ec53392f..1ccc45045e 100644 --- a/include/boost/geometry/algorithms/area.hpp +++ b/include/boost/geometry/algorithms/area.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2017, 2018. -// Modifications copyright (c) 2017-2018 Oracle and/or its affiliates. +// This file was modified by Oracle on 2017-2020. +// Modifications copyright (c) 2017-2020 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 @@ -43,10 +43,12 @@ // #include #include -#include -#include -#include +#include +#include + +#include #include +#include #include @@ -86,15 +88,17 @@ template > struct ring_area { - template - static inline typename area_result::type - apply(Ring const& ring, Strategy const& strategy) + template + static inline typename area_result::type + apply(Ring const& ring, Strategies const& strategies) { - BOOST_CONCEPT_ASSERT( (geometry::concepts::AreaStrategy) ); + using strategy_type = decltype(strategies.area(ring)); + + BOOST_CONCEPT_ASSERT( (geometry::concepts::AreaStrategy) ); assert_dimension(); // Ignore warning (because using static method sometimes) on strategy - boost::ignore_unused(strategy); + boost::ignore_unused(strategies); // An open ring has at least three points, // A closed ring has at least four points, @@ -102,7 +106,7 @@ struct ring_area if (boost::size(ring) < core_detail::closure::minimum_ring_size::value) { - return typename area_result::type(); + return typename area_result::type(); } typedef typename reversible_view::type rview_type; @@ -114,10 +118,12 @@ struct ring_area rview_type rview(ring); view_type view(rview); - typename Strategy::template state state; iterator_type it = boost::begin(view); iterator_type end = boost::end(view); + strategy_type strategy = strategies.area(ring); + typename strategy_type::template state state; + for (iterator_type previous = it++; it != end; ++previous, ++it) @@ -216,7 +222,11 @@ struct area : detail::multi_sum namespace resolve_strategy { -template +template +< + typename Strategy, + bool IsUmbrella = strategies::detail::is_umbrella_strategy::value +> struct area { template @@ -227,16 +237,30 @@ struct area } }; +template +struct area +{ + template + static auto apply(Geometry const& geometry, Strategy const& strategy) + { + using strategies::area::services::strategy_converter; + return dispatch::area + < + Geometry + >::apply(geometry, strategy_converter::get(strategy)); + } +}; + template <> -struct area +struct area { template static inline typename area_result::type apply(Geometry const& geometry, default_strategy) { - typedef typename strategy::area::services::default_strategy + typedef typename strategies::area::services::default_strategy < - typename cs_tag::type + Geometry >::type strategy_type; return dispatch::area::apply(geometry, strategy_type()); diff --git a/include/boost/geometry/algorithms/area_result.hpp b/include/boost/geometry/algorithms/area_result.hpp new file mode 100644 index 0000000000..017a632e3b --- /dev/null +++ b/include/boost/geometry/algorithms/area_result.hpp @@ -0,0 +1,152 @@ +// Boost.Geometry + +// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2020. +// Modifications copyright (c) 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, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_STRATEGY_AREA_RESULT_HPP +#define BOOST_GEOMETRY_STRATEGY_AREA_RESULT_HPP + + +#include +#include + +#include +#include +#include +#include + +#include +#include + + +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace area +{ + + +template +< + typename Geometry, + typename Strategy, + bool IsUmbrella = strategies::detail::is_umbrella_strategy::value +> +struct area_result + : decltype(std::declval().area(std::declval())) + ::template result_type +{}; + +template +< + typename Geometry, + typename Strategy +> +struct area_result + : Strategy::template result_type +{}; + + +}} // namespace detail::area +#endif //DOXYGEN_NO_DETAIL + + +/*! +\brief Meta-function defining return type of area function +\ingroup area +\note The return-type is defined by Geometry and Strategy + */ +template +< + typename Geometry, + typename Strategy = default_strategy +> +struct area_result + : detail::area::area_result +{}; + +template +struct area_result, Strategy> + : geometry::area_result + < + typename geometry::util::select_sequence_element + < + typename boost::variant::types + >::type, + Strategy + > +{}; + +template +struct area_result + : geometry::area_result + < + Geometry, + typename geometry::strategies::area::services::default_strategy + < + Geometry + >::type + > +{}; + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace area +{ + +template +struct pred_more_precise_default_area_result +{ + typedef typename geometry::area_result::type curr_result_t; + typedef typename geometry::area_result::type next_result_t; + + typedef typename boost::mpl::if_c + < + boost::is_same + < + curr_result_t, + typename geometry::select_most_precise + < + curr_result_t, + next_result_t + >::type + >::value, + Curr, + Next + >::type type; +}; + +}} // namespace detail::area +#endif //DOXYGEN_NO_DETAIL + +template +struct area_result, default_strategy> + : geometry::area_result + < + typename geometry::util::select_sequence_element + < + typename boost::variant::types, + geometry::detail::area::pred_more_precise_default_area_result + >::type, + default_strategy + > +{}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGY_AREA_RESULT_HPP diff --git a/include/boost/geometry/algorithms/correct.hpp b/include/boost/geometry/algorithms/correct.hpp index 21b9977ce5..3a828580e0 100644 --- a/include/boost/geometry/algorithms/correct.hpp +++ b/include/boost/geometry/algorithms/correct.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // Copyright (c) 2014-2017 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017 Oracle and/or its affiliates. +// This file was modified by Oracle on 2017-2020. +// Modifications copyright (c) 2017-2020 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 @@ -147,7 +147,13 @@ struct correct_ring typedef typename area_result::type area_result_type; Predicate predicate; area_result_type const zero = 0; - if (predicate(ring_area_type::apply(r, strategy), zero)) + if (predicate(ring_area_type::apply(r, + // TEMP - in the future (umbrella) strategy will be passed + geometry::strategies::area::services::strategy_converter + < + Strategy + >::get(strategy)), + zero)) { std::reverse(boost::begin(r), boost::end(r)); } diff --git a/include/boost/geometry/algorithms/default_area_result.hpp b/include/boost/geometry/algorithms/default_area_result.hpp new file mode 100644 index 0000000000..c3accb85f8 --- /dev/null +++ b/include/boost/geometry/algorithms/default_area_result.hpp @@ -0,0 +1,41 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-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) + +#ifndef BOOST_GEOMETRY_STRATEGY_DEFAULT_AREA_RESULT_HPP +#define BOOST_GEOMETRY_STRATEGY_DEFAULT_AREA_RESULT_HPP + + +#include + + +namespace boost { namespace geometry +{ + +/*! +\brief Meta-function defining return type of area function, using the default strategy +\ingroup area +\note The strategy defines the return-type (so this situation is different + from length, where distance is sqr/sqrt, but length always squared) + */ + +template +struct default_area_result + : area_result +{}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGY_DEFAULT_AREA_RESULT_HPP diff --git a/include/boost/geometry/algorithms/detail/calculate_point_order.hpp b/include/boost/geometry/algorithms/detail/calculate_point_order.hpp index a3024076ed..789fec4b28 100644 --- a/include/boost/geometry/algorithms/detail/calculate_point_order.hpp +++ b/include/boost/geometry/algorithms/detail/calculate_point_order.hpp @@ -1,6 +1,6 @@ // Boost.Geometry -// Copyright (c) 2019, Oracle and/or its affiliates. +// Copyright (c) 2019-2020, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -297,7 +297,12 @@ struct calculate_point_order_by_area Ring, Strategy >::type result_type; - result_type const result = ring_area_type::apply(ring, strategy); + result_type const result = ring_area_type::apply(ring, + // TEMP - in the future (umbrella) strategy will be passed + geometry::strategies::area::services::strategy_converter + < + decltype(strategy.get_area_strategy()) + >::get(strategy.get_area_strategy())); result_type const zero = 0; return result == zero ? geometry::order_undetermined diff --git a/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp b/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp index 58fe2b4fd4..bd3273eb51 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// Copyright (c) 2014-2019, Oracle and/or its affiliates. +// Copyright (c) 2014-2020, 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 @@ -42,6 +42,12 @@ #include +// TEMP +#include +#include +#include + + namespace boost { namespace geometry { @@ -139,7 +145,12 @@ class multipoint_linear { geometry::expand(total, geometry::return_envelope(segment, m_strategy), - typename EnvelopeStrategy::box_expand_strategy_type()); + // TEMP - envelope umbrella strategy also contains + // expand strategies + strategies::envelope::services::strategy_converter + < + EnvelopeStrategy + >::get(m_strategy)); } EnvelopeStrategy const& m_strategy; @@ -423,7 +434,14 @@ class multi_point_multi_geometry > overlaps_box_point_type; typedef expand_box_box_pair < - typename Strategy::envelope_strategy_type::box_expand_strategy_type + // TEMP - envelope umbrella strategy also contains + // expand strategies + decltype(strategies::envelope::services::strategy_converter + < + typename Strategy::envelope_strategy_type + >::get(strategy.get_envelope_strategy()) + .expand(std::declval(), + std::declval())) > expand_box_box_pair_type; typedef overlaps_box_box_pair < diff --git a/include/boost/geometry/algorithms/detail/disjoint/segment_box.hpp b/include/boost/geometry/algorithms/detail/disjoint/segment_box.hpp index ea51f6be7a..ae89d1d6be 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/segment_box.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/segment_box.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2014 Mateusz Loskot, London, UK. // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013-2019. -// Modifications copyright (c) 2013-2019, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013-2020. +// Modifications copyright (c) 2013-2020, 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 @@ -40,7 +40,7 @@ #include // Temporary, for envelope_segment_impl -#include +#include namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/detail/envelope/box.hpp b/include/boost/geometry/algorithms/detail/envelope/box.hpp index b085a14b9d..4650bcbca2 100644 --- a/include/boost/geometry/algorithms/detail/envelope/box.hpp +++ b/include/boost/geometry/algorithms/detail/envelope/box.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2015-2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 @@ -21,10 +21,6 @@ #include -// For backward compatibility -#include -#include - namespace boost { namespace geometry { @@ -39,9 +35,10 @@ template struct envelope { template - static inline void apply(BoxIn const& box_in, BoxOut& mbr, Strategy const& ) + static inline void apply(BoxIn const& box_in, BoxOut& mbr, Strategy const& strategy) { - Strategy::apply(box_in, mbr); + using strategy_t = decltype(strategy.envelope(box_in, mbr)); + strategy_t::apply(box_in, mbr); } }; diff --git a/include/boost/geometry/algorithms/detail/envelope/interface.hpp b/include/boost/geometry/algorithms/detail/envelope/interface.hpp index 28c815f4c2..4230b1a986 100644 --- a/include/boost/geometry/algorithms/detail/envelope/interface.hpp +++ b/include/boost/geometry/algorithms/detail/envelope/interface.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2015, 2016, 2017, 2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 @@ -35,7 +35,9 @@ #include #include -#include +#include +#include +#include #include @@ -46,31 +48,49 @@ namespace boost { namespace geometry namespace resolve_strategy { -template +template +< + typename Strategy, + bool IsUmbrella = strategies::detail::is_umbrella_strategy::value +> struct envelope { - template + template static inline void apply(Geometry const& geometry, Box& box, Strategy const& strategy) { dispatch::envelope::apply(geometry, box, strategy); } +}; + +template +struct envelope +{ + template + static inline void apply(Geometry const& geometry, + Box& box, + Strategy const& strategy) + { + using strategies::envelope::services::strategy_converter; + return dispatch::envelope + < + Geometry + >::apply(geometry, box, strategy_converter::get(strategy)); + } +}; - template +template <> +struct envelope +{ + template static inline void apply(Geometry const& geometry, Box& box, default_strategy) { - typedef typename strategy::envelope::services::default_strategy + typedef typename strategies::envelope::services::default_strategy < - typename tag::type, - typename cs_tag::type, - typename select_most_precise - < - typename coordinate_type::type, - typename coordinate_type::type - >::type + Geometry, Box >::type strategy_type; dispatch::envelope::apply(geometry, box, strategy_type()); @@ -93,7 +113,7 @@ struct envelope concepts::check(); concepts::check(); - resolve_strategy::envelope::apply(geometry, box, strategy); + resolve_strategy::envelope::apply(geometry, box, strategy); } }; @@ -131,6 +151,7 @@ struct envelope > } // namespace resolve_variant + /*! \brief \brief_calc{envelope (with strategy)} \ingroup envelope diff --git a/include/boost/geometry/algorithms/detail/envelope/linear.hpp b/include/boost/geometry/algorithms/detail/envelope/linear.hpp index e2f05f2e3a..d76621e277 100644 --- a/include/boost/geometry/algorithms/detail/envelope/linear.hpp +++ b/include/boost/geometry/algorithms/detail/envelope/linear.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2015, 2016, 2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 @@ -25,11 +25,6 @@ #include -// For backward compatibility -#include -#include -#include - namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/detail/envelope/multipoint.hpp b/include/boost/geometry/algorithms/detail/envelope/multipoint.hpp index ce112e4d78..d6280b4a66 100644 --- a/include/boost/geometry/algorithms/detail/envelope/multipoint.hpp +++ b/include/boost/geometry/algorithms/detail/envelope/multipoint.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2015-2018, Oracle and/or its affiliates. +// Copyright (c) 2015-2020, 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 @@ -17,10 +17,6 @@ #include -// For backward compatibility -#include -#include - namespace boost { namespace geometry { @@ -34,9 +30,11 @@ template struct envelope { template - static inline void apply(MultiPoint const& multipoint, Box& mbr, Strategy const& ) + static inline void apply(MultiPoint const& multipoint, Box& mbr, Strategy const& strategy) { - Strategy::apply(multipoint, mbr); + // strategy.envelope(multipoint, mbr).apply(multipoint, mbr); + using strategy_t = decltype(strategy.envelope(multipoint, mbr)); + strategy_t::apply(multipoint, mbr); } }; diff --git a/include/boost/geometry/algorithms/detail/envelope/point.hpp b/include/boost/geometry/algorithms/detail/envelope/point.hpp index 164274a280..87f768b508 100644 --- a/include/boost/geometry/algorithms/detail/envelope/point.hpp +++ b/include/boost/geometry/algorithms/detail/envelope/point.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2015, 2016, 2017, 2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 @@ -22,11 +22,6 @@ #include -// For backward compatibility -#include -#include - - namespace boost { namespace geometry { @@ -38,9 +33,11 @@ namespace detail { namespace envelope struct envelope_point { template - static inline void apply(Point const& point, Box& mbr, Strategy const& ) + static inline void apply(Point const& point, Box& mbr, Strategy const& strategy) { - Strategy::apply(point, mbr); + // strategy.envelope(point, mbr).apply(point, mbr); + using strategy_t = decltype(strategy.envelope(point, mbr)); + strategy_t::apply(point, mbr); } }; diff --git a/include/boost/geometry/algorithms/detail/envelope/range.hpp b/include/boost/geometry/algorithms/detail/envelope/range.hpp index 2d33600d0f..068685b0ef 100644 --- a/include/boost/geometry/algorithms/detail/envelope/range.hpp +++ b/include/boost/geometry/algorithms/detail/envelope/range.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2015, 2016, 2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 @@ -64,7 +64,7 @@ struct envelope_range dispatch::envelope < value_type - >::apply(*it, mbr, strategy.get_element_envelope_strategy()); + >::apply(*it, mbr, strategy); // consider now the remaining elements in the range (if any) for (++it; it != last; ++it) @@ -72,7 +72,7 @@ struct envelope_range dispatch::expand < Box, value_type - >::apply(mbr, *it, strategy.get_element_expand_strategy()); + >::apply(mbr, *it, strategy); } } } @@ -80,7 +80,9 @@ struct envelope_range template static inline void apply(Range const& range, Box& mbr, Strategy const& strategy) { - return apply(Strategy::begin(range), Strategy::end(range), mbr, strategy); + using strategy_t = decltype(strategy.envelope(range, mbr)); + return apply(strategy_t::begin(range), strategy_t::end(range), + mbr, strategy); } }; @@ -94,16 +96,20 @@ struct envelope_multi_range Box& mbr, Strategy const& strategy) { - apply(boost::begin(multirange), boost::end(multirange), mbr, strategy); + using range_t = typename boost::range_value::type; + using strategy_t = decltype(strategy.envelope(std::declval(), mbr)); + using state_t = typename strategy_t::template multi_state; + apply(boost::begin(multirange), boost::end(multirange), mbr, strategy); } - template +private: + template static inline void apply(Iter it, Iter last, Box& mbr, Strategy const& strategy) { - typename Strategy::template multi_state state; + State state; for (; it != last; ++it) { if (! geometry::is_empty(*it)) diff --git a/include/boost/geometry/algorithms/detail/envelope/segment.hpp b/include/boost/geometry/algorithms/detail/envelope/segment.hpp index af79f34508..27aa632f6b 100644 --- a/include/boost/geometry/algorithms/detail/envelope/segment.hpp +++ b/include/boost/geometry/algorithms/detail/envelope/segment.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2015-2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 @@ -25,10 +25,8 @@ #include #include -// For backward compatibility -#include -#include -#include +// TEMP +#include namespace boost { namespace geometry { @@ -37,18 +35,37 @@ namespace boost { namespace geometry namespace detail { namespace envelope { -template -struct envelope_segment +// TEMP +template +< + typename Strategy, + bool IsUmbrella = strategies::detail::is_umbrella_strategy::value +> +struct envelope_segment_call_strategy { - template - static inline void apply(Point const& p1, - Point const& p2, - Box& mbr, + template + static inline void apply(Point const& p1, Point const& p2, + Segment const& segment, Box& mbr, + Strategy const& strategy) + { + strategy.envelope(segment, mbr).apply(p1, p2, mbr); + } +}; + +template +struct envelope_segment_call_strategy +{ + template + static inline void apply(Point const& p1, Point const& p2, + Segment const& segment, Box& mbr, Strategy const& strategy) { strategy.apply(p1, p2, mbr); } +}; +struct envelope_segment +{ template static inline void apply(Segment const& segment, Box& mbr, Strategy const& strategy) @@ -56,7 +73,9 @@ struct envelope_segment typename point_type::type p[2]; detail::assign_point_from_index<0>(segment, p[0]); detail::assign_point_from_index<1>(segment, p[1]); - apply(p[0], p[1], mbr, strategy); + + // TEMP - expand calls this and Umbrella strategies are not yet supported there + envelope_segment_call_strategy::apply(p[0], p[1], segment, mbr, strategy); } }; @@ -77,13 +96,10 @@ struct envelope Box& mbr, Strategy const& strategy) { - typename point_type::type p[2]; - detail::assign_point_from_index<0>(segment, p[0]); - detail::assign_point_from_index<1>(segment, p[1]); detail::envelope::envelope_segment - < + /*< dimension::value - >::apply(p[0], p[1], mbr, strategy); + >*/::apply(segment, mbr, strategy); } }; diff --git a/include/boost/geometry/algorithms/detail/expand/box.hpp b/include/boost/geometry/algorithms/detail/expand/box.hpp index 41571dba6a..d24100c61c 100644 --- a/include/boost/geometry/algorithms/detail/expand/box.hpp +++ b/include/boost/geometry/algorithms/detail/expand/box.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. -// This file was modified by Oracle on 2015, 2016, 2017, 2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 @@ -24,10 +24,6 @@ #include -// For backward compatibility -#include -#include - namespace boost { namespace geometry { @@ -51,9 +47,11 @@ struct expand template static inline void apply(BoxOut& box_out, BoxIn const& box_in, - Strategy const& ) + Strategy const& strategy) { - Strategy::apply(box_out, box_in); + // strategy.expand(box_out, box_in).apply(box_out, box_in); + using strategy_t = decltype(strategy.expand(box_out, box_in)); + strategy_t::apply(box_out, box_in); } }; diff --git a/include/boost/geometry/algorithms/detail/expand/interface.hpp b/include/boost/geometry/algorithms/detail/expand/interface.hpp index 28241b379b..85fddc5d11 100644 --- a/include/boost/geometry/algorithms/detail/expand/interface.hpp +++ b/include/boost/geometry/algorithms/detail/expand/interface.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. -// This file was modified by Oracle on 2015, 2016, 2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 @@ -35,7 +35,9 @@ #include #include -#include +#include +#include +#include namespace boost { namespace geometry @@ -44,26 +46,49 @@ namespace boost { namespace geometry namespace resolve_strategy { -template +template +< + typename Strategy, + bool IsUmbrella = strategies::detail::is_umbrella_strategy::value +> struct expand { - template + template static inline void apply(Box& box, Geometry const& geometry, Strategy const& strategy) { dispatch::expand::apply(box, geometry, strategy); } +}; - template +template +struct expand +{ + template + static inline void apply(Box& box, + Geometry const& geometry, + Strategy const& strategy) + { + using strategies::expand::services::strategy_converter; + dispatch::expand + < + Box, Geometry + >::apply(box, geometry, strategy_converter::get(strategy)); + } +}; + +template <> +struct expand +{ + template static inline void apply(Box& box, Geometry const& geometry, default_strategy) { - typedef typename strategy::expand::services::default_strategy + typedef typename strategies::expand::services::default_strategy < - typename tag::type, - typename cs_tag::type + Box, Geometry >::type strategy_type; dispatch::expand::apply(box, geometry, strategy_type()); @@ -88,7 +113,7 @@ struct expand concepts::check(); concepts::check_concepts_and_equal_dimensions(); - resolve_strategy::expand::apply(box, geometry, strategy); + resolve_strategy::expand::apply(box, geometry, strategy); } }; @@ -171,7 +196,6 @@ 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); } diff --git a/include/boost/geometry/algorithms/detail/expand/point.hpp b/include/boost/geometry/algorithms/detail/expand/point.hpp index d4a9097cb3..17ab1fbcf7 100644 --- a/include/boost/geometry/algorithms/detail/expand/point.hpp +++ b/include/boost/geometry/algorithms/detail/expand/point.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. -// This file was modified by Oracle on 2015-2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 @@ -27,10 +27,6 @@ #include -// For backward compatibility -#include -#include - namespace boost { namespace geometry { @@ -54,9 +50,11 @@ struct expand template static inline void apply(BoxOut& box, Point const& point, - Strategy const& ) + Strategy const& strategy) { - Strategy::apply(box, point); + // strategy.expand(box, point).apply(box, point); + using strategy_t = decltype(strategy.expand(box, point)); + strategy_t::apply(box, point); } }; diff --git a/include/boost/geometry/algorithms/detail/expand/segment.hpp b/include/boost/geometry/algorithms/detail/expand/segment.hpp index 3f6f196026..c09c664e22 100644 --- a/include/boost/geometry/algorithms/detail/expand/segment.hpp +++ b/include/boost/geometry/algorithms/detail/expand/segment.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. -// This file was modified by Oracle on 2015, 2016, 2017, 2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 @@ -26,11 +26,6 @@ #include -// For backward compatibility -#include -#include -#include - namespace boost { namespace geometry { @@ -54,8 +49,7 @@ struct expand Segment const& segment, Strategy const& strategy) { - boost::ignore_unused(strategy); - strategy.apply(box, segment); + strategy.expand(box, segment).apply(box, segment); } }; diff --git a/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp b/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp index 90ce2b8982..d4758546eb 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// Copyright (c) 2014-2019, Oracle and/or its affiliates. +// Copyright (c) 2014-2020, 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 @@ -63,6 +63,12 @@ #include +// TEMP +#include +#include +#include + + namespace boost { namespace geometry { @@ -189,7 +195,12 @@ class is_valid_polygon { geometry::expand(total, item.get_envelope(m_strategy), - m_strategy.get_box_expand_strategy()); + // TEMP - envelope umbrella strategy also contains + // expand strategies + strategies::envelope::services::strategy_converter + < + EnvelopeStrategy + >::get(m_strategy)); } EnvelopeStrategy const& m_strategy; diff --git a/include/boost/geometry/algorithms/detail/is_valid/ring.hpp b/include/boost/geometry/algorithms/detail/is_valid/ring.hpp index 2a377ee8cc..9238780cf8 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/ring.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/ring.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// Copyright (c) 2014-2019, Oracle and/or its affiliates. +// Copyright (c) 2014-2020, 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 @@ -38,7 +38,11 @@ #include #include -#include +// TEMP - with UmberllaStrategy this will be not needed +#include +#include +// TODO: use point_order instead of area + #ifdef BOOST_GEOMETRY_TEST_DEBUG #include @@ -132,7 +136,11 @@ struct is_properly_oriented area_result_type const zero = 0; area_result_type const area = ring_area_type::apply(ring, - strategy.template get_area_strategy()); + // TEMP - in the future (umbrella) strategy will be passed here + geometry::strategies::area::services::strategy_converter + < + decltype(strategy.template get_area_strategy()) + >::get(strategy.template get_area_strategy())); if (predicate(area, zero)) { return visitor.template apply(); diff --git a/include/boost/geometry/algorithms/detail/overlay/pointlike_areal.hpp b/include/boost/geometry/algorithms/detail/overlay/pointlike_areal.hpp index f175f5e0d1..60c0e23696 100644 --- a/include/boost/geometry/algorithms/detail/overlay/pointlike_areal.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/pointlike_areal.hpp @@ -34,6 +34,12 @@ #include +// TEMP +#include +#include +#include + + namespace boost { namespace geometry { @@ -167,7 +173,14 @@ class multipoint_multipolygon_point box_pairs, strategy.get_envelope_strategy()); - typedef typename Strategy::envelope_strategy_type::box_expand_strategy_type expand_box_strategy_type; + // TEMP - envelope umbrella strategy also contains + // expand strategies + using expand_box_strategy_type = decltype( + strategies::envelope::services::strategy_converter + < + typename Strategy::envelope_strategy_type + >::get(strategy.get_envelope_strategy()) + .expand(std::declval(), std::declval())); typedef typename Strategy::disjoint_box_box_strategy_type disjoint_box_box_strategy_type; typedef typename Strategy::disjoint_point_box_strategy_type disjoint_point_box_strategy_type; typedef typename Strategy::expand_point_strategy_type expand_point_strategy_type; diff --git a/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp b/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp index 6e7bdcd667..ec033a1911 100644 --- a/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp @@ -38,6 +38,12 @@ #include +// TEMP +#include +#include +#include + + namespace boost { namespace geometry { @@ -142,7 +148,12 @@ class multipoint_linear_point { geometry::expand(total, geometry::return_envelope(segment, m_strategy), - m_strategy.get_box_expand_strategy()); + // TEMP - envelope umbrella strategy also contains + // expand strategies + strategies::envelope::services::strategy_converter + < + EnvelopeStrategy + >::get(m_strategy)); } EnvelopeStrategy const& m_strategy; diff --git a/include/boost/geometry/algorithms/detail/relate/multi_point_geometry.hpp b/include/boost/geometry/algorithms/detail/relate/multi_point_geometry.hpp index 7f9e138392..8b7399ae1d 100644 --- a/include/boost/geometry/algorithms/detail/relate/multi_point_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/relate/multi_point_geometry.hpp @@ -1,6 +1,6 @@ // Boost.Geometry -// Copyright (c) 2017-2019 Oracle and/or its affiliates. +// Copyright (c) 2017-2020 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -31,6 +31,12 @@ #include +// TEMP +#include +#include +#include + + namespace boost { namespace geometry { @@ -396,7 +402,14 @@ class multi_point_multi_geometry_ii_ib > overlaps_box_point_type; typedef expand_box_box_pair < - typename Strategy::envelope_strategy_type::box_expand_strategy_type + // TEMP - envelope umbrella strategy also contains + // expand strategies + decltype(strategies::envelope::services::strategy_converter + < + typename Strategy::envelope_strategy_type + >::get(strategy.get_envelope_strategy()) + .expand(std::declval(), + std::declval())) > expand_box_box_pair_type; typedef overlaps_box_box_pair < diff --git a/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp b/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp index 6cb80aa58e..0ed7ca28df 100644 --- a/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp +++ b/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013, 2014, 2015, 2017, 2018, 2019. -// Modifications copyright (c) 2013-2019 Oracle and/or its affiliates. +// This file was modified by Oracle on 2013-2020. +// Modifications copyright (c) 2013-2020 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -38,11 +38,12 @@ #include #include #include - +#include #include #include #include #include +#include #include #include @@ -51,18 +52,17 @@ #include #include -#include +#include #include #include +#include +#include #include #include -#include - -#include -#include -#include -#include +// TEMP +#include +#include namespace boost { namespace geometry { diff --git a/include/boost/geometry/geometry.hpp b/include/boost/geometry/geometry.hpp index bc6c99c0ed..24b12fab71 100644 --- a/include/boost/geometry/geometry.hpp +++ b/include/boost/geometry/geometry.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2014-2018. -// Modifications copyright (c) 2014-2018 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014-2020. +// Modifications copyright (c) 2014-2020 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle diff --git a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp index 4fa04fe411..04b55f2e84 100644 --- a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2014-2015 Mateusz Loskot, London, UK. // Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2015, 2019. -// Modifications copyright (c) 2015, 2019, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 @@ -44,6 +44,13 @@ #include + +// TEMP +#include +#include +#include + + namespace boost { namespace geometry { @@ -160,7 +167,13 @@ static inline void init_rescale_policy(Geometry1 const& geometry1, < model::box >(geometry2, strategy2); - geometry::expand(env, env2, strategy1.get_box_expand_strategy()); + geometry::expand(env, env2, + // TEMP - envelope umbrella strategy also contains + // expand strategies + strategies::envelope::services::strategy_converter + < + EnvelopeStrategy1 + >::get(strategy1)); } scale_box_to_integer_range(env, min_point, min_robust_point, factor); diff --git a/include/boost/geometry/strategies/area.hpp b/include/boost/geometry/strategies/area.hpp index 866f37e846..9e0cd01b4a 100644 --- a/include/boost/geometry/strategies/area.hpp +++ b/include/boost/geometry/strategies/area.hpp @@ -1,92 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2020, Oracle and/or its affiliates. -// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library -// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. +// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_AREA_HPP #define BOOST_GEOMETRY_STRATEGIES_AREA_HPP -#include -#include +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -#include +#include -namespace boost { namespace geometry -{ - - -namespace strategy { namespace area -{ - - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - -// If user specified a CalculationType, use that type, whatever it is -// and whatever the Geometry is. -// Else, use Geometry's coordinate-type promoted to double if needed. -template -< - typename Geometry, - typename CalculationType -> -struct result_type -{ - typedef CalculationType type; -}; - -template -< - typename Geometry -> -struct result_type - : select_most_precise - < - typename coordinate_type::type, - double - > -{}; - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - - -namespace services -{ - -/*! - \brief Traits class binding a default area strategy to a coordinate system - \ingroup area - \tparam Tag tag of coordinate system -*/ -template -struct default_strategy -{ - BOOST_MPL_ASSERT_MSG - ( - false, NOT_IMPLEMENTED_FOR_THIS_COORDINATE_SYSTEM - , (types) - ); -}; - - -} // namespace services - -}} // namespace strategy::area - - -}} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_AREA_HPP diff --git a/include/boost/geometry/strategies/area/cartesian.hpp b/include/boost/geometry/strategies/area/cartesian.hpp new file mode 100644 index 0000000000..bd156c226b --- /dev/null +++ b/include/boost/geometry/strategies/area/cartesian.hpp @@ -0,0 +1,63 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_AREA_CARTESIAN_HPP +#define BOOST_GEOMETRY_STRATEGIES_AREA_CARTESIAN_HPP + + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategies { namespace area +{ + +template +struct cartesian : strategies::detail::cartesian_base +{ + template + static auto area(Geometry const&) + { + return strategy::area::cartesian(); + } +}; + + +namespace services +{ + +template +struct default_strategy +{ + using type = strategies::area::cartesian<>; +}; + + +template +struct strategy_converter > +{ + static auto get(strategy::area::cartesian const& strategy) + { + return strategies::area::cartesian(); + } +}; + + +} // namespace services + +}} // namespace strategies::area + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_AREA_CARTESIAN_HPP diff --git a/include/boost/geometry/strategies/area/geographic.hpp b/include/boost/geometry/strategies/area/geographic.hpp new file mode 100644 index 0000000000..4c04da7bed --- /dev/null +++ b/include/boost/geometry/strategies/area/geographic.hpp @@ -0,0 +1,82 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_AREA_GEOGRAPHIC_HPP +#define BOOST_GEOMETRY_STRATEGIES_AREA_GEOGRAPHIC_HPP + + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategies { namespace area +{ + +template +< + typename FormulaPolicy = strategy::andoyer, + std::size_t SeriesOrder = strategy::default_order::value, + typename Spheroid = srs::spheroid, + typename CalculationType = void +> +class geographic : strategies::detail::geographic_base +{ + using base_t = strategies::detail::geographic_base; + +public: + geographic() + : base_t() + {} + + explicit geographic(Spheroid const& spheroid) + : base_t(spheroid) + {} + + template + auto area(Geometry const&) const + { + return strategy::area::geographic + < + FormulaPolicy, SeriesOrder, Spheroid, CalculationType + >(base_t::m_spheroid); + } +}; + + +namespace services +{ + +template +struct default_strategy +{ + using type = strategies::area::geographic<>; +}; + + +template +struct strategy_converter > +{ + static auto get(strategy::area::geographic const& strategy) + { + return strategies::area::geographic(strategy.model()); + } +}; + +} // namespace services + +}} // namespace strategies::area + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_AREA_GEOGRAPHIC_HPP diff --git a/include/boost/geometry/strategies/area/services.hpp b/include/boost/geometry/strategies/area/services.hpp new file mode 100644 index 0000000000..67eb91be3d --- /dev/null +++ b/include/boost/geometry/strategies/area/services.hpp @@ -0,0 +1,60 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_AREA_SERVICES_HPP +#define BOOST_GEOMETRY_STRATEGIES_AREA_SERVICES_HPP + + +#include + +#include + + +namespace boost { namespace geometry +{ + + +namespace strategies { namespace area { + +namespace services +{ + +template +< + typename Geometry, + typename CSTag = typename geometry::cs_tag::type +> +struct default_strategy +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_COORDINATE_SYSTEM + , (types) + ); +}; + +template +struct strategy_converter +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY + , (Strategy) + ); +}; + + +} // namespace services + +}} // namespace strategies::area + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_AREA_SERVICES_HPP diff --git a/include/boost/geometry/strategies/area/spherical.hpp b/include/boost/geometry/strategies/area/spherical.hpp new file mode 100644 index 0000000000..2486abb7d2 --- /dev/null +++ b/include/boost/geometry/strategies/area/spherical.hpp @@ -0,0 +1,94 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_AREA_SPHERICAL_HPP +#define BOOST_GEOMETRY_STRATEGIES_AREA_SPHERICAL_HPP + + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategies { namespace area +{ + +template +< + typename RadiusTypeOrSphere = double, + typename CalculationType = void +> +class spherical : strategies::detail::spherical_base +{ + using base_t = strategies::detail::spherical_base; + +public: + spherical() + : base_t() + {} + + template + explicit spherical(RadiusOrSphere const& radius_or_sphere) + : base_t(radius_or_sphere) + {} + + template + auto area(Geometry const&) const + { + return strategy::area::spherical + < + typename base_t::radius_type, CalculationType + >(base_t::m_radius); + } +}; + + +namespace services +{ + +template +struct default_strategy +{ + using type = strategies::area::spherical<>; +}; + +template +struct default_strategy +{ + using type = strategies::area::spherical<>; +}; + +template +struct default_strategy +{ + using type = strategies::area::spherical<>; +}; + + +template +struct strategy_converter > +{ + static auto get(strategy::area::spherical const& strategy) + { + return strategies::area::spherical(strategy.model()); + } +}; + + +} // namespace services + +}} // namespace strategies::area + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_AREA_SPHERICAL_HPP diff --git a/include/boost/geometry/strategies/area_result.hpp b/include/boost/geometry/strategies/area_result.hpp index b8a6c4c85e..e15a116ae3 100644 --- a/include/boost/geometry/strategies/area_result.hpp +++ b/include/boost/geometry/strategies/area_result.hpp @@ -1,116 +1,21 @@ // Boost.Geometry -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2020, Oracle and/or its affiliates. -// 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) +// 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_STRATEGIES_AREA_RESULT_HPP #define BOOST_GEOMETRY_STRATEGIES_AREA_RESULT_HPP -#include -#include - -#include -#include - -#include -#include - - -#include -#include -#include - - -namespace boost { namespace geometry -{ - - -/*! -\brief Meta-function defining return type of area function -\ingroup area -\note The return-type is defined by Geometry and Strategy - */ -template -< - typename Geometry, - typename Strategy = default_strategy -> -struct area_result - : Strategy::template result_type -{}; - -template -struct area_result, Strategy> - : geometry::area_result - < - typename geometry::util::select_sequence_element - < - typename boost::variant::types - >::type, - Strategy - > -{}; - -template -struct area_result - : geometry::area_result - < - Geometry, - typename geometry::strategy::area::services::default_strategy - < - typename cs_tag::type - >::type - > -{}; - -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace area -{ - -template -struct pred_more_precise_default_area_result -{ - typedef typename geometry::area_result::type curr_result_t; - typedef typename geometry::area_result::type next_result_t; - - typedef typename boost::mpl::if_c - < - boost::is_same - < - curr_result_t, - typename geometry::select_most_precise - < - curr_result_t, - next_result_t - >::type - >::value, - Curr, - Next - >::type type; -}; - -}} // namespace detail::area -#endif //DOXYGEN_NO_DETAIL - -template -struct area_result, default_strategy> - : geometry::area_result - < - typename geometry::util::select_sequence_element - < - typename boost::variant::types, - geometry::detail::area::pred_more_precise_default_area_result - >::type, - default_strategy - > -{}; +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace boost::geometry +#include #endif // BOOST_GEOMETRY_STRATEGIES_AREA_RESULT_HPP diff --git a/include/boost/geometry/strategies/cartesian.hpp b/include/boost/geometry/strategies/cartesian.hpp new file mode 100644 index 0000000000..68e6a96b26 --- /dev/null +++ b/include/boost/geometry/strategies/cartesian.hpp @@ -0,0 +1,106 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_CARTESIAN_HPP +#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_HPP + + +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +namespace strategies +{ + + +template +struct cartesian : strategies::detail::cartesian_base +{ + // area + + template + static auto area(Geometry const&) + { + return strategy::area::cartesian(); + } + + // envelope + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::envelope::cartesian_point(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_multi_point::type * = nullptr) + { + return strategy::envelope::cartesian_multipoint(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::envelope::cartesian_box(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_segment::type * = nullptr) + { + return strategy::envelope::cartesian_segment(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_non_trivial_linear_or_polygonal::type * = nullptr) + { + return strategy::envelope::cartesian(); + } + + // expand + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::expand::cartesian_point(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::expand::cartesian_box(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_segment::type * = nullptr) + { + return strategy::expand::cartesian_segment(); + } +}; + + +} // namespace strategies + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_HPP diff --git a/include/boost/geometry/strategies/cartesian/area.hpp b/include/boost/geometry/strategies/cartesian/area.hpp index 070e8f56b0..a19738c0a7 100644 --- a/include/boost/geometry/strategies/cartesian/area.hpp +++ b/include/boost/geometry/strategies/cartesian/area.hpp @@ -1,147 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. - -// This file was modified by Oracle on 2016, 2017, 2018. -// Modifications copyright (c) 2016-2018, Oracle and/or its affiliates. +// Copyright (c) 2020, 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. - -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_AREA_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_AREA_HPP -#include - -//#include -#include -#include -#include -#include -#include - - -namespace boost { namespace geometry -{ - -namespace strategy { namespace area -{ - -/*! -\brief Cartesian area calculation -\ingroup strategies -\details Calculates cartesian area using the trapezoidal rule -\tparam CalculationType \tparam_calculation - -\qbk{ -[heading See also] -[link geometry.reference.algorithms.area.area_2_with_strategy area (with strategy)] -} - -*/ -template -< - typename CalculationType = void -> -class cartesian -{ -public : - template - struct result_type - : strategy::area::detail::result_type - < - Geometry, - CalculationType - > - {}; - - template - class state - { - friend class cartesian; - - typedef typename result_type::type return_type; - - public: - inline state() - : sum(0) - { - // Strategy supports only 2D areas - assert_dimension(); - } - - private: - inline return_type area() const - { - return_type const two = 2; - return sum / two; - } - - return_type sum; - }; - - template - static inline void apply(PointOfSegment const& p1, - PointOfSegment const& p2, - state& st) - { - typedef typename state::return_type return_type; - - // Below formulas are equivalent, however the two lower ones - // suffer less from accuracy loss for great values of coordinates. - // See: https://svn.boost.org/trac/boost/ticket/11928 - - // SUM += x2 * y1 - x1 * y2; - // state.sum += detail::determinant(p2, p1); - - // SUM += (x2 - x1) * (y2 + y1) - //state.sum += (return_type(get<0>(p2)) - return_type(get<0>(p1))) - // * (return_type(get<1>(p2)) + return_type(get<1>(p1))); - - // SUM += (x1 + x2) * (y1 - y2) - st.sum += (return_type(get<0>(p1)) + return_type(get<0>(p2))) - * (return_type(get<1>(p1)) - return_type(get<1>(p2))); - } - - template - static inline typename result_type::type - result(state& st) - { - return st.area(); - } - -}; - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - template <> - struct default_strategy - { - typedef strategy::area::cartesian<> type; - }; - -} // namespace services - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - - -}} // namespace strategy::area - +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace boost::geometry +#include #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_AREA_HPP diff --git a/include/boost/geometry/strategies/cartesian/area_surveyor.hpp b/include/boost/geometry/strategies/cartesian/area_surveyor.hpp index 91df31745a..181d66f73d 100644 --- a/include/boost/geometry/strategies/cartesian/area_surveyor.hpp +++ b/include/boost/geometry/strategies/cartesian/area_surveyor.hpp @@ -1,29 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. - -// This file was modified by Oracle on 2016, 2017. -// Modifications copyright (c) 2016-2017, Oracle and/or its affiliates. +// Copyright (c) 2020, 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. - -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_AREA_SURVEYOR_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_AREA_SURVEYOR_HPP -// keep this file for now, for backward compatibility -// functionality-wise, make it equivalent to boost/geometry/strategies/cartesian/area.hpp -#include +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") + + +#include #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_AREA_SURVEYOR_HPP diff --git a/include/boost/geometry/strategies/cartesian/envelope.hpp b/include/boost/geometry/strategies/cartesian/envelope.hpp index b7fc947bba..0e07e84256 100644 --- a/include/boost/geometry/strategies/cartesian/envelope.hpp +++ b/include/boost/geometry/strategies/cartesian/envelope.hpp @@ -1,155 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015, 2016, 2018, 2019. -// Modifications copyright (c) 2015-2019, 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. - -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_HPP -#include -#include - -#include - -#include -#include -#include -#include - -namespace boost { namespace geometry -{ - -namespace strategy { namespace envelope -{ - -template -class cartesian -{ -public: - typedef cartesian_tag cs_tag; - - typedef cartesian_point element_envelope_strategy_type; - static inline element_envelope_strategy_type get_element_envelope_strategy() - { - return element_envelope_strategy_type(); - } - - typedef expand::cartesian_point element_expand_strategy_type; - static inline element_expand_strategy_type get_element_expand_strategy() - { - return element_expand_strategy_type(); - } - - typedef expand::cartesian_box box_expand_strategy_type; - static inline box_expand_strategy_type get_box_expand_strategy() - { - return box_expand_strategy_type(); - } - - // Linestring, Ring, Polygon - - template - static inline typename boost::range_iterator::type begin(Range const& range) - { - return boost::begin(range); - } - - template - static inline typename boost::range_iterator::type end(Range const& range) - { - return boost::end(range); - } - - // MultiLinestring, MultiPolygon - - template - struct multi_state - { - multi_state() - : m_initialized(false) - {} - - void apply(Box const& single_box) - { - if (! m_initialized) - { - m_box = single_box; - m_initialized = true; - } - else - { - box_expand_strategy_type::apply(m_box, single_box); - } - } - - void result(Box & box) - { - if (m_initialized) - { - box = m_box; - } - else - { - geometry::detail::envelope::initialize::value>::apply(box); - } - } - - private: - bool m_initialized; - Box m_box; - }; - - // Segment - - template - static inline void apply(Point1 const& point1, Point2 const& point2, - Box& box) - { - cartesian_segment::apply(point1, point2, box); - } - - // Box - - template - static inline void apply(BoxIn const& box_in, Box& box) - { - cartesian_box::apply(box_in, box); - } -}; - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::cartesian type; -}; - -} // namespace services -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::envelope +#include -}} //namepsace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_HPP diff --git a/include/boost/geometry/strategies/cartesian/envelope_box.hpp b/include/boost/geometry/strategies/cartesian/envelope_box.hpp index 893866fdf6..de7d186f6d 100644 --- a/include/boost/geometry/strategies/cartesian/envelope_box.hpp +++ b/include/boost/geometry/strategies/cartesian/envelope_box.hpp @@ -1,130 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015-2019. -// Modifications copyright (c) 2015-2019, 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 -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_BOX_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_BOX_HPP -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include - -#include - - -namespace boost { namespace geometry -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace envelope -{ - - -template -< - std::size_t Index, - std::size_t Dimension, - std::size_t DimensionCount -> -struct envelope_indexed_box -{ - template - static inline void apply(BoxIn const& box_in, BoxOut& mbr) - { - detail::indexed_point_view box_in_corner(box_in); - detail::indexed_point_view mbr_corner(mbr); - - detail::conversion::point_to_point - < - detail::indexed_point_view, - detail::indexed_point_view, - Dimension, - DimensionCount - >::apply(box_in_corner, mbr_corner); - } -}; - - -}} // namespace detail::envelope -#endif // DOXYGEN_NO_DETAIL - - -namespace strategy { namespace envelope -{ - - -struct cartesian_box -{ - typedef cartesian_tag cs_tag; - - typedef strategy::expand::cartesian_box box_expand_strategy_type; - - static inline box_expand_strategy_type get_box_expand_strategy() - { - return box_expand_strategy_type(); - } - - template - static inline void apply(BoxIn const& box_in, BoxOut& mbr) - { - geometry::detail::envelope::envelope_indexed_box - < - min_corner, 0, dimension::value - >::apply(box_in, mbr); - - geometry::detail::envelope::envelope_indexed_box - < - max_corner, 0, dimension::value - >::apply(box_in, mbr); - } -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::cartesian_box type; -}; - -} - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -}} // namespace strategy::envelope +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace boost::geometry +#include #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_BOX_HPP diff --git a/include/boost/geometry/strategies/cartesian/envelope_multipoint.hpp b/include/boost/geometry/strategies/cartesian/envelope_multipoint.hpp index 28c2374ce8..835bb56c51 100644 --- a/include/boost/geometry/strategies/cartesian/envelope_multipoint.hpp +++ b/include/boost/geometry/strategies/cartesian/envelope_multipoint.hpp @@ -1,59 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2018, Oracle and/or its affiliates. +// Copyright (c) 2020, 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_MULTIPOINT_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_MULTIPOINT_HPP -#include -#include +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -#include +#include -namespace boost { namespace geometry -{ - -namespace strategy { namespace envelope -{ - -class cartesian_multipoint -{ -public: - template - static inline void apply(MultiPoint const& multipoint, Box& mbr) - { - geometry::detail::envelope::envelope_range::apply(multipoint, mbr, cartesian<>()); - } -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::cartesian_multipoint type; -}; - - -} // namespace services - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - - -}} // namespace strategy::envelope - -}} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_MULTIPOINT_HPP diff --git a/include/boost/geometry/strategies/cartesian/envelope_point.hpp b/include/boost/geometry/strategies/cartesian/envelope_point.hpp index 3f900c7184..1abd002820 100644 --- a/include/boost/geometry/strategies/cartesian/envelope_point.hpp +++ b/include/boost/geometry/strategies/cartesian/envelope_point.hpp @@ -1,111 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015, 2016, 2017, 2018. -// Modifications copyright (c) 2015-2018, 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 -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_POINT_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_POINT_HPP -#include - -#include -#include -#include -#include -#include - -#include - -#include - -#include - - -namespace boost { namespace geometry -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace envelope -{ - -template -struct envelope_one_point -{ - template - static inline void apply(Point const& point, Box& mbr) - { - detail::indexed_point_view box_corner(mbr); - detail::conversion::point_to_point - < - Point, - detail::indexed_point_view, - Dimension, - DimensionCount - >::apply(point, box_corner); - } - - template - static inline void apply(Point const& point, Box& mbr) - { - apply(point, mbr); - apply(point, mbr); - } -}; - - -}} // namespace detail::envelope -#endif // DOXYGEN_NO_DETAIL - - -namespace strategy { namespace envelope -{ - -struct cartesian_point -{ - template - static inline void apply(Point const& point, Box& mbr) - { - geometry::detail::envelope::envelope_one_point - < - 0, dimension::value - >::apply(point, mbr); - } -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::cartesian_point type; -}; - - -} - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -}} // namespace strategy::envelope +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace boost::geometry +#include #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_POINT_HPP diff --git a/include/boost/geometry/strategies/cartesian/envelope_segment.hpp b/include/boost/geometry/strategies/cartesian/envelope_segment.hpp index cd52775da5..b2951a5faa 100644 --- a/include/boost/geometry/strategies/cartesian/envelope_segment.hpp +++ b/include/boost/geometry/strategies/cartesian/envelope_segment.hpp @@ -1,93 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry + +// Copyright (c) 2020, Oracle and/or its affiliates. -// Copyright (c) 2017-2018 Oracle and/or its affiliates. -// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle // 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_SEGMENT_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_SEGMENT_HPP -#include - -#include -#include - -#include -#include -#include - -namespace boost { namespace geometry { namespace strategy { namespace envelope -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - -template -struct envelope_one_segment -{ - template - static inline void apply(Point const& p1, - Point const& p2, - Box& mbr) - { - geometry::detail::envelope::envelope_one_point - < - Dimension, DimensionCount - >::apply(p1, mbr); - - strategy::expand::detail::point_loop - < - Dimension, DimensionCount - >::apply(mbr, p2); - } -}; - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - - -template -< - typename CalculationType = void -> -class cartesian_segment -{ -public: - template - static inline void apply(Point const& point1, Point const& point2, Box& box) - { - strategy::envelope::detail::envelope_one_segment - < - 0, - dimension::value - >::apply(point1, point2, box); - } - -}; - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::cartesian_segment type; -}; - -} -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::envelope +#include -}} //namepsace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_SEGMENT_HPP diff --git a/include/boost/geometry/strategies/cartesian/expand_box.hpp b/include/boost/geometry/strategies/cartesian/expand_box.hpp index 68b8824f81..2e9cf2df90 100644 --- a/include/boost/geometry/strategies/cartesian/expand_box.hpp +++ b/include/boost/geometry/strategies/cartesian/expand_box.hpp @@ -1,69 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015, 2016, 2017. -// Modifications copyright (c) 2015-2017, 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 -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_EXPAND_BOX_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_EXPAND_BOX_HPP -#include - -#include - -#include - - -namespace boost { namespace geometry -{ - -namespace strategy { namespace expand -{ - -struct cartesian_box -{ - template - static void apply(BoxOut & box_out, BoxIn const& box_in) - { - geometry::detail::expand::expand_indexed - < - 0, dimension::value - >::apply(box_out, box_in); - } -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef cartesian_box type; -}; - - -} // namespace services -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::expand +#include -}} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_EXPAND_BOX_HPP diff --git a/include/boost/geometry/strategies/cartesian/expand_point.hpp b/include/boost/geometry/strategies/cartesian/expand_point.hpp index 87d82dca08..1f067d27b7 100644 --- a/include/boost/geometry/strategies/cartesian/expand_point.hpp +++ b/include/boost/geometry/strategies/cartesian/expand_point.hpp @@ -1,125 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015-2018. -// Modifications copyright (c) 2015-2018, 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. - -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_EXPAND_POINT_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_EXPAND_POINT_HPP -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include - -namespace boost { namespace geometry -{ - -namespace strategy { namespace expand -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - -template -struct point_loop -{ - template - static inline void apply(Box& box, Point const& source) - { - typedef typename select_coordinate_type - < - Point, Box - >::type coordinate_type; - - std::less less; - std::greater greater; - - coordinate_type const coord = get(source); - - if (less(coord, get(box))) - { - set(box, coord); - } - - if (greater(coord, get(box))) - { - set(box, coord); - } - - point_loop::apply(box, source); - } -}; - - -template -struct point_loop -{ - template - static inline void apply(Box&, Point const&) {} -}; - - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - - -struct cartesian_point -{ - template - static void apply(Box & box, Point const& point) - { - expand::detail::point_loop - < - 0, dimension::value - >::apply(box, point); - } -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef cartesian_point type; -}; - - -} // namespace services -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::expand +#include -}} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_EXPAND_POINT_HPP diff --git a/include/boost/geometry/strategies/cartesian/expand_segment.hpp b/include/boost/geometry/strategies/cartesian/expand_segment.hpp index 18fd9c9a78..b658779767 100644 --- a/include/boost/geometry/strategies/cartesian/expand_segment.hpp +++ b/include/boost/geometry/strategies/cartesian/expand_segment.hpp @@ -1,71 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015, 2016, 2017, 2018. -// Modifications copyright (c) 2015-2018, 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 -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_EXPAND_SEGMENT_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_EXPAND_SEGMENT_HPP -#include - -#include - -#include - - -namespace boost { namespace geometry -{ - -namespace strategy { namespace expand -{ - -class cartesian_segment -{ -public: - template - static void apply(Box & box, Segment const& segment) - { - geometry::detail::expand::expand_indexed - < - 0, dimension::value - >::apply(box, segment); - } -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef cartesian_segment type; -}; - - -} // namespace services - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::expand +#include -}} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_EXPAND_SEGMENT_HPP diff --git a/include/boost/geometry/strategies/cartesian/index.hpp b/include/boost/geometry/strategies/cartesian/index.hpp index 80b79bf317..f4a16be5ab 100644 --- a/include/boost/geometry/strategies/cartesian/index.hpp +++ b/include/boost/geometry/strategies/cartesian/index.hpp @@ -2,7 +2,7 @@ // // R-tree strategies // -// Copyright (c) 2019, Oracle and/or its affiliates. +// Copyright (c) 2019-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, @@ -13,6 +13,13 @@ #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_INDEX_HPP +#include +#include +#include +#include +#include +#include + #include #include //#include @@ -20,12 +27,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include #include #include diff --git a/include/boost/geometry/strategies/cartesian/intersection.hpp b/include/boost/geometry/strategies/cartesian/intersection.hpp index 246f68ce25..bac39f22a6 100644 --- a/include/boost/geometry/strategies/cartesian/intersection.hpp +++ b/include/boost/geometry/strategies/cartesian/intersection.hpp @@ -3,8 +3,8 @@ // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2013-2017 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014, 2016, 2017, 2018, 2019. -// Modifications copyright (c) 2014-2019, Oracle and/or its affiliates. +// This file was modified by Oracle on 2014-2020. +// Modifications copyright (c) 2014-2020, 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 @@ -33,13 +33,14 @@ #include #include -#include +#include +#include +#include +#include + #include #include #include -#include -#include -#include #include #include #include @@ -53,6 +54,7 @@ #include #include + #if defined(BOOST_GEOMETRY_DEBUG_ROBUSTNESS) # include #endif 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 bb0fe3f81e..9052b5fc42 100644 --- a/include/boost/geometry/strategies/cartesian/point_in_poly_winding.hpp +++ b/include/boost/geometry/strategies/cartesian/point_in_poly_winding.hpp @@ -3,8 +3,8 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013, 2014, 2016, 2017, 2018, 2019. -// Modifications copyright (c) 2013-2019 Oracle and/or its affiliates. +// This file was modified by Oracle on 2013-2020. +// Modifications copyright (c) 2013-2020 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 @@ -23,6 +23,8 @@ #include #include +#include + #include #include #include diff --git a/include/boost/geometry/strategies/cartesian/point_order.hpp b/include/boost/geometry/strategies/cartesian/point_order.hpp index 02c024be0b..995147daaa 100644 --- a/include/boost/geometry/strategies/cartesian/point_order.hpp +++ b/include/boost/geometry/strategies/cartesian/point_order.hpp @@ -1,6 +1,6 @@ // Boost.Geometry -// Copyright (c) 2019, Oracle and/or its affiliates. +// Copyright (c) 2019-2020, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -13,8 +13,8 @@ #include +#include #include -#include namespace boost { namespace geometry @@ -28,6 +28,12 @@ struct cartesian : strategy::area::cartesian { typedef area_tag version_tag; + + // TEMP + static strategy::area::cartesian get_area_strategy() + { + return strategy::area::cartesian(); + } }; namespace services diff --git a/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp b/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp index e41e4bedbe..245ee51f4a 100644 --- a/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp +++ b/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2015, 2017, 2018, 2019. -// Modifications copyright (c) 2015-2019, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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,8 +28,9 @@ #include #include +#include + #include -#include #include #include #include diff --git a/include/boost/geometry/strategies/default_area_result.hpp b/include/boost/geometry/strategies/default_area_result.hpp index 65818ea91a..21561f326a 100644 --- a/include/boost/geometry/strategies/default_area_result.hpp +++ b/include/boost/geometry/strategies/default_area_result.hpp @@ -1,41 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2020, Oracle and/or its affiliates. -// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library -// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. +// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_DEFAULT_AREA_RESULT_HPP #define BOOST_GEOMETRY_STRATEGIES_DEFAULT_AREA_RESULT_HPP -#include +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -namespace boost { namespace geometry -{ - -/*! -\brief Meta-function defining return type of area function, using the default strategy -\ingroup area -\note The strategy defines the return-type (so this situation is different - from length, where distance is sqr/sqrt, but length always squared) - */ - -template -struct default_area_result - : area_result -{}; - - -}} // namespace boost::geometry +#include #endif // BOOST_GEOMETRY_STRATEGIES_DEFAULT_AREA_RESULT_HPP diff --git a/include/boost/geometry/strategies/detail.hpp b/include/boost/geometry/strategies/detail.hpp new file mode 100644 index 0000000000..605b7fef9d --- /dev/null +++ b/include/boost/geometry/strategies/detail.hpp @@ -0,0 +1,207 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_DETAIL_HPP +#define BOOST_GEOMETRY_STRATEGIES_DETAIL_HPP + + +#include + +#include +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +namespace strategies +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + + +struct umbrella_strategy {}; + + +template +struct is_umbrella_strategy +{ + static const bool value = std::is_base_of::value; +}; + + +struct cartesian_base : umbrella_strategy +{ + typedef cartesian_tag tag; +}; + +template +< + typename RadiusTypeOrSphere +> +class spherical_base : umbrella_strategy +{ +protected: + typedef typename strategy_detail::get_radius + < + RadiusTypeOrSphere + >::type radius_type; + +public: + typedef spherical_tag tag; + + spherical_base() + : m_radius(1.0) + {} + + template + explicit spherical_base(RadiusOrSphere const& radius_or_sphere) + : m_radius(strategy_detail::get_radius + < + RadiusOrSphere + >::apply(radius_or_sphere)) + {} + + srs::sphere model() const + { + return srs::sphere(m_radius); + } + +protected: + radius_type m_radius; +}; + +template <> +class spherical_base : umbrella_strategy +{ +public: + typedef spherical_tag tag; + + srs::sphere model() const + { + return srs::sphere(1.0); + } +}; + +template +class geographic_base : umbrella_strategy +{ +public: + typedef geographic_tag tag; + + geographic_base() + : m_spheroid() + {} + + explicit geographic_base(Spheroid const& spheroid) + : m_spheroid(spheroid) + {} + + Spheroid model() const + { + return m_spheroid; + } + +protected: + Spheroid m_spheroid; +}; + + +template +struct enable_if_pointlike + : std::enable_if + < + std::is_base_of::type>::value, + T + > +{}; + +template +struct enable_if_linear + : std::enable_if + < + std::is_base_of::type>::value, + T + > +{}; + +template +struct enable_if_polygonal + : std::enable_if + < + std::is_base_of::type>::value, + T + > +{}; + +template +struct enable_if_non_trivial_linear_or_polygonal + : std::enable_if + < + ((std::is_base_of::type>::value + || std::is_base_of::type>::value) + && (!std::is_same::type>::value)), + T + > +{}; + +template +struct enable_if_point + : std::enable_if + < + std::is_same::type>::value, + T + > +{}; + +template +struct enable_if_multi_point + : std::enable_if + < + std::is_same::type>::value, + T + > +{}; + +template +struct enable_if_box + : std::enable_if + < + std::is_same::type>::value, + T + > +{}; + +template +struct enable_if_segment + : std::enable_if + < + std::is_same::type>::value, + T + > +{}; + + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +} // namespace strategies + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_DETAIL_HPP diff --git a/include/boost/geometry/strategies/envelope.hpp b/include/boost/geometry/strategies/envelope.hpp index 050ed4658c..5cbc80361a 100644 --- a/include/boost/geometry/strategies/envelope.hpp +++ b/include/boost/geometry/strategies/envelope.hpp @@ -1,46 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry + +// Copyright (c) 2020, Oracle and/or its affiliates. -// Copyright (c) 2016-2018 Oracle and/or its affiliates. -// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle // 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_ENVELOPE_HPP #define BOOST_GEOMETRY_STRATEGIES_ENVELOPE_HPP -#include - -namespace boost { namespace geometry -{ - - -namespace strategy { namespace envelope { namespace services -{ - -/*! -\brief Traits class binding a default envelope strategy to a coordinate system -\ingroup util -\tparam Tag tag of geometry -\tparam CSTag tag of coordinate system -\tparam CalculationType \tparam_calculation -*/ -template -struct default_strategy -{ - BOOST_MPL_ASSERT_MSG - ( - false, NOT_IMPLEMENTED_FOR_THIS_TYPE - , (types) - ); -}; -}}} // namespace strategy::envelope::services +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace boost::geometry +#include -#endif // BOOST_GEOMETRY_STRATEGIES_ENVELOPE_HPP +#endif // BOOST_GEOMETRY_STRATEGIES2_ENVELOPE_HPP diff --git a/include/boost/geometry/strategies/envelope/cartesian.hpp b/include/boost/geometry/strategies/envelope/cartesian.hpp new file mode 100644 index 0000000000..73acd4c776 --- /dev/null +++ b/include/boost/geometry/strategies/envelope/cartesian.hpp @@ -0,0 +1,160 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_ENVELOPE_CARTESIAN_HPP +#define BOOST_GEOMETRY_STRATEGIES_ENVELOPE_CARTESIAN_HPP + + +#include + +#include +#include +#include +#include +#include + +#include // TEMP +#include +#include // TEMP + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategies { namespace envelope +{ + +template +struct cartesian : strategies::detail::cartesian_base +{ + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::envelope::cartesian_point(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_multi_point::type * = nullptr) + { + return strategy::envelope::cartesian_multipoint(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::envelope::cartesian_box(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_segment::type * = nullptr) + { + return strategy::envelope::cartesian_segment(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_non_trivial_linear_or_polygonal::type * = nullptr) + { + return strategy::envelope::cartesian(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::expand::cartesian_point(); + } + + // TEMP + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::expand::cartesian_box(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_segment::type * = nullptr) + { + return strategy::expand::cartesian_segment(); + } +}; + + +namespace services +{ + +template +struct default_strategy +{ + using type = strategies::envelope::cartesian<>; +}; + + +template <> +struct strategy_converter +{ + static auto get(strategy::envelope::cartesian_point const& ) + { + return strategies::envelope::cartesian<>(); + } +}; + +template <> +struct strategy_converter +{ + static auto get(strategy::envelope::cartesian_multipoint const&) + { + return strategies::envelope::cartesian<>(); + } +}; + +template <> +struct strategy_converter +{ + static auto get(strategy::envelope::cartesian_box const& ) + { + return strategies::envelope::cartesian<>(); + } +}; + +template +struct strategy_converter > +{ + static auto get(strategy::envelope::cartesian_segment const&) + { + return strategies::envelope::cartesian(); + } +}; + +template +struct strategy_converter > +{ + static auto get(strategy::envelope::cartesian const&) + { + return strategies::envelope::cartesian(); + } +}; + + +} // namespace services + +}} // namespace strategies::envelope + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_ENVELOPE_CARTESIAN_HPP diff --git a/include/boost/geometry/strategies/envelope/geographic.hpp b/include/boost/geometry/strategies/envelope/geographic.hpp new file mode 100644 index 0000000000..2030e2ce44 --- /dev/null +++ b/include/boost/geometry/strategies/envelope/geographic.hpp @@ -0,0 +1,151 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_ENVELOPE_GEOGRAPHIC_HPP +#define BOOST_GEOMETRY_STRATEGIES_ENVELOPE_GEOGRAPHIC_HPP + + +#include + +#include +#include + +#include // TEMP + +#include + + +namespace boost { namespace geometry +{ + +namespace strategies { namespace envelope +{ + +template +< + typename FormulaPolicy = strategy::andoyer, + typename Spheroid = srs::spheroid, + typename CalculationType = void +> +class geographic : strategies::detail::geographic_base +{ + using base_t = strategies::detail::geographic_base; + +public: + geographic() + : base_t() + {} + + explicit geographic(Spheroid const& spheroid) + : base_t(spheroid) + {} + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::envelope::spherical_point(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_multi_point::type * = nullptr) + { + return strategy::envelope::spherical_multipoint(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::envelope::spherical_box(); + } + + template + auto envelope(Geometry const&, Box const&, + typename detail::enable_if_segment::type * = nullptr) const + { + return strategy::envelope::geographic_segment + < + FormulaPolicy, Spheroid, CalculationType + >(base_t::m_spheroid); + } + + template + auto envelope(Geometry const&, Box const&, + typename detail::enable_if_non_trivial_linear_or_polygonal::type * = nullptr) const + { + return strategy::envelope::geographic + < + FormulaPolicy, Spheroid, CalculationType + >(base_t::m_spheroid); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::expand::spherical_point(); + } + + // TEMP + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::expand::spherical_box(); + } + + template + auto expand(Box const&, Geometry const&, + typename detail::enable_if_segment::type * = nullptr) const + { + return strategy::expand::geographic_segment + < + FormulaPolicy, Spheroid, CalculationType + >(base_t::m_spheroid); + } +}; + + +namespace services +{ + +template +struct default_strategy +{ + using type = strategies::envelope::geographic<>; +}; + + +template +struct strategy_converter > +{ + static auto get(strategy::envelope::geographic_segment const& s) + { + return strategies::envelope::geographic(s.model()); + } +}; + +template +struct strategy_converter > +{ + static auto get(strategy::envelope::geographic const& s) + { + return strategies::envelope::geographic(s.model()); + } +}; + +} // namespace services + +}} // namespace strategies::envelope + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_ENVELOPE_GEOGRAPHIC_HPP diff --git a/include/boost/geometry/strategies/envelope/services.hpp b/include/boost/geometry/strategies/envelope/services.hpp new file mode 100644 index 0000000000..6c6280aeef --- /dev/null +++ b/include/boost/geometry/strategies/envelope/services.hpp @@ -0,0 +1,57 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_ENVELOPE_SERVICES_HPP +#define BOOST_GEOMETRY_STRATEGIES_ENVELOPE_SERVICES_HPP + + +#include + +#include + + +namespace boost { namespace geometry +{ + +namespace strategies { namespace envelope { namespace services +{ + +template +< + typename Geometry, + typename Box, + typename CSTag = typename geometry::cs_tag::type +> +struct default_strategy +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_COORDINATE_SYSTEM + , (types) + ); +}; + +template +struct strategy_converter +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY + , (Strategy) + ); +}; + + +}}} // namespace strategies::envelope::services + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_ENVELOPE_SERVICES_HPP + diff --git a/include/boost/geometry/strategies/envelope/spherical.hpp b/include/boost/geometry/strategies/envelope/spherical.hpp new file mode 100644 index 0000000000..8971c1a276 --- /dev/null +++ b/include/boost/geometry/strategies/envelope/spherical.hpp @@ -0,0 +1,178 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_ENVELOPE_SPHERICAL_HPP +#define BOOST_GEOMETRY_STRATEGIES_ENVELOPE_SPHERICAL_HPP + + +#include + +#include +#include +#include +#include +#include + +#include // TEMP +#include +#include // TEMP + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategies { namespace envelope +{ + +template +< + typename CalculationType = void +> +class spherical : strategies::detail::spherical_base +{ + using base_t = strategies::detail::spherical_base; + +public: + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::envelope::spherical_point(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_multi_point::type * = nullptr) + { + return strategy::envelope::spherical_multipoint(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::envelope::spherical_box(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_segment::type * = nullptr) + { + return strategy::envelope::spherical_segment(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_non_trivial_linear_or_polygonal::type * = nullptr) + { + return strategy::envelope::spherical(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::expand::spherical_point(); + } + + // TEMP + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::expand::spherical_box(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_segment::type * = nullptr) + { + return strategy::expand::spherical_segment(); + } +}; + + +namespace services +{ + +template +struct default_strategy +{ + using type = strategies::envelope::spherical<>; +}; + +template +struct default_strategy +{ + using type = strategies::envelope::spherical<>; +}; + +template +struct default_strategy +{ + using type = strategies::envelope::spherical<>; +}; + + +template <> +struct strategy_converter +{ + static auto get(strategy::envelope::spherical_point const& ) + { + return strategies::envelope::spherical<>(); + } +}; + +template <> +struct strategy_converter +{ + static auto get(strategy::envelope::spherical_multipoint const&) + { + return strategies::envelope::spherical<>(); + } +}; + +template <> +struct strategy_converter +{ + static auto get(strategy::envelope::spherical_box const& ) + { + return strategies::envelope::spherical<>(); + } +}; + +template +struct strategy_converter > +{ + static auto get(strategy::envelope::spherical_segment const&) + { + return strategies::envelope::spherical(); + } +}; + +template +struct strategy_converter > +{ + static auto get(strategy::envelope::spherical const&) + { + return strategies::envelope::spherical(); + } +}; + + +} // namespace services + +}} // namespace strategies::envelope + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_ENVELOPE_SPHERICAL_HPP diff --git a/include/boost/geometry/strategies/expand.hpp b/include/boost/geometry/strategies/expand.hpp index 39d4145144..0a5b21125c 100644 --- a/include/boost/geometry/strategies/expand.hpp +++ b/include/boost/geometry/strategies/expand.hpp @@ -1,45 +1,21 @@ // Boost.Geometry -// Copyright (c) 2018 Oracle and/or its affiliates. +// Copyright (c) 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, -// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_EXPAND_HPP #define BOOST_GEOMETRY_STRATEGIES_EXPAND_HPP -#include - -namespace boost { namespace geometry -{ - -namespace strategy { namespace expand { namespace services -{ +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -/*! -\brief Traits class binding a default envelope strategy to a coordinate system -\ingroup util -\tparam Tag tag of geometry -\tparam CSTag tag of coordinate system -\tparam CalculationType \tparam_calculation -*/ -template -struct default_strategy -{ - BOOST_MPL_ASSERT_MSG - ( - false, NOT_IMPLEMENTED_FOR_THIS_TYPE - , (types) - ); -}; -}}} // namespace strategy::expand::services +#include -}} // namespace boost::geometry - #endif // BOOST_GEOMETRY_STRATEGIES_EXPAND_HPP - diff --git a/include/boost/geometry/strategies/expand/cartesian.hpp b/include/boost/geometry/strategies/expand/cartesian.hpp new file mode 100644 index 0000000000..8b5d34ad98 --- /dev/null +++ b/include/boost/geometry/strategies/expand/cartesian.hpp @@ -0,0 +1,102 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_EXPAND_CARTESIAN_HPP +#define BOOST_GEOMETRY_STRATEGIES_EXPAND_CARTESIAN_HPP + + +#include + +#include +#include +#include + +#include +#include + + +namespace boost { namespace geometry +{ + + +namespace strategies { namespace expand +{ + + +template +struct cartesian : strategies::detail::cartesian_base +{ + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::expand::cartesian_point(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::expand::cartesian_box(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_segment::type * = nullptr) + { + return strategy::expand::cartesian_segment(); + } +}; + + +namespace services +{ + +template +struct default_strategy +{ + using type = strategies::expand::cartesian<>; +}; + + +template <> +struct strategy_converter +{ + static auto get(strategy::expand::cartesian_point const& ) + { + return strategies::expand::cartesian<>(); + } +}; + +template <> +struct strategy_converter +{ + static auto get(strategy::expand::cartesian_box const& ) + { + return strategies::expand::cartesian<>(); + } +}; + +template <> +struct strategy_converter +{ + static auto get(strategy::expand::cartesian_segment const&) + { + return strategies::expand::cartesian<>(); + } +}; + + +} // namespace services + +}} // namespace strategies::envelope + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_EXPAND_CARTESIAN_HPP diff --git a/include/boost/geometry/strategies/expand/geographic.hpp b/include/boost/geometry/strategies/expand/geographic.hpp new file mode 100644 index 0000000000..3d062e1d9f --- /dev/null +++ b/include/boost/geometry/strategies/expand/geographic.hpp @@ -0,0 +1,99 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_EXPAND_GEOGRAPHIC_HPP +#define BOOST_GEOMETRY_STRATEGIES_EXPAND_GEOGRAPHIC_HPP + + +#include + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategies { namespace expand +{ + +template +< + typename FormulaPolicy = strategy::andoyer, + typename Spheroid = srs::spheroid, + typename CalculationType = void +> +class geographic : strategies::detail::geographic_base +{ + using base_t = strategies::detail::geographic_base; + +public: + geographic() + : base_t() + {} + + explicit geographic(Spheroid const& spheroid) + : base_t(spheroid) + {} + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::expand::spherical_point(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::expand::spherical_box(); + } + + template + auto expand(Box const&, Geometry const&, + typename detail::enable_if_segment::type * = nullptr) const + { + return strategy::expand::geographic_segment + < + FormulaPolicy, Spheroid, CalculationType + >(base_t::m_spheroid); + } +}; + + +namespace services +{ + +template +struct default_strategy +{ + using type = strategies::expand::geographic<>; +}; + + +template +struct strategy_converter > +{ + static auto get(strategy::expand::geographic_segment const& s) + { + return strategies::expand::geographic(s.model()); + } +}; + + +} // namespace services + +}} // namespace strategies::envelope + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_EXPAND_GEOGRAPHIC_HPP diff --git a/include/boost/geometry/strategies/expand/services.hpp b/include/boost/geometry/strategies/expand/services.hpp new file mode 100644 index 0000000000..198a99e958 --- /dev/null +++ b/include/boost/geometry/strategies/expand/services.hpp @@ -0,0 +1,56 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_EXPAND_SERVICES_HPP +#define BOOST_GEOMETRY_STRATEGIES_EXPAND_SERVICES_HPP + +#include + +#include + + +namespace boost { namespace geometry +{ + +namespace strategies { namespace expand { namespace services +{ + +template +< + typename Box, + typename Geometry, + typename CSTag = typename geometry::cs_tag::type +> +struct default_strategy +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_COORDINATE_SYSTEM + , (types) + ); +}; + +template +struct strategy_converter +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY + , (Strategy) + ); +}; + + +}}} // namespace strategies::expand::services + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_EXPAND_SERVICES_HPP + diff --git a/include/boost/geometry/strategies/expand/spherical.hpp b/include/boost/geometry/strategies/expand/spherical.hpp new file mode 100644 index 0000000000..c605c62ef6 --- /dev/null +++ b/include/boost/geometry/strategies/expand/spherical.hpp @@ -0,0 +1,119 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_EXPAND_SPHERICAL_HPP +#define BOOST_GEOMETRY_STRATEGIES_EXPAND_SPHERICAL_HPP + + +#include + +#include +#include +#include + +#include +#include + + +namespace boost { namespace geometry +{ + + +namespace strategies { namespace expand +{ + +template +< + typename CalculationType = void +> +class spherical : strategies::detail::spherical_base +{ + using base_t = strategies::detail::spherical_base; + +public: + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::expand::spherical_point(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::expand::spherical_box(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_segment::type * = nullptr) + { + return strategy::expand::spherical_segment(); + } +}; + + +namespace services +{ + +template +struct default_strategy +{ + using type = strategies::expand::spherical<>; +}; + +template +struct default_strategy +{ + using type = strategies::expand::spherical<>; +}; + +template +struct default_strategy +{ + using type = strategies::expand::spherical<>; +}; + + +template <> +struct strategy_converter +{ + static auto get(strategy::expand::spherical_point const& ) + { + return strategies::expand::spherical<>(); + } +}; + +template <> +struct strategy_converter +{ + static auto get(strategy::expand::spherical_box const& ) + { + return strategies::expand::spherical<>(); + } +}; + +template +struct strategy_converter > +{ + static auto get(strategy::expand::spherical_segment const&) + { + return strategies::expand::spherical(); + } +}; + + +} // namespace services + +}} // namespace strategies::envelope + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_EXPAND_SPHERICAL_HPP diff --git a/include/boost/geometry/strategies/geographic.hpp b/include/boost/geometry/strategies/geographic.hpp new file mode 100644 index 0000000000..642fcd798a --- /dev/null +++ b/include/boost/geometry/strategies/geographic.hpp @@ -0,0 +1,135 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_GEOGRAPHIC_HPP +#define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_HPP + + +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +namespace strategies +{ + + +template +< + typename FormulaPolicy = strategy::andoyer, + std::size_t SeriesOrder = strategy::default_order::value, + typename Spheroid = srs::spheroid, + typename CalculationType = void +> +class geographic : strategies::detail::geographic_base +{ + using base_t = strategies::detail::geographic_base; + +public: + geographic() + : base_t() + {} + + explicit geographic(Spheroid const& spheroid) + : base_t(spheroid) + {} + + // area + + template + auto area(Geometry const&) const + { + return strategy::area::geographic + < + FormulaPolicy, SeriesOrder, Spheroid, CalculationType + >(base_t::m_spheroid); + } + + // envelope + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::envelope::spherical_point(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_multi_point::type * = nullptr) + { + return strategy::envelope::spherical_multipoint(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::envelope::spherical_box(); + } + + template + auto envelope(Geometry const&, Box const&, + typename detail::enable_if_segment::type * = nullptr) const + { + return strategy::envelope::geographic_segment + < + FormulaPolicy, Spheroid, CalculationType + >(base_t::m_spheroid); + } + + template + auto envelope(Geometry const&, Box const&, + typename detail::enable_if_non_trivial_linear_or_polygonal::type * = nullptr) const + { + return strategy::envelope::geographic + < + FormulaPolicy, Spheroid, CalculationType + >(base_t::m_spheroid); + } + + // expand + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::expand::spherical_point(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::expand::spherical_box(); + } + + template + auto expand(Box const&, Geometry const&, + typename detail::enable_if_segment::type * = nullptr) const + { + return strategy::expand::geographic_segment + < + FormulaPolicy, Spheroid, CalculationType + >(base_t::m_spheroid); + } +}; + + +} // namespace strategies + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_HPP diff --git a/include/boost/geometry/strategies/geographic/area.hpp b/include/boost/geometry/strategies/geographic/area.hpp index d40a30cf22..600c739454 100644 --- a/include/boost/geometry/strategies/geographic/area.hpp +++ b/include/boost/geometry/strategies/geographic/area.hpp @@ -1,232 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2020, Oracle and/or its affiliates. -// Copyright (c) 2016-2018 Oracle and/or its affiliates. -// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle // 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AREA_HPP #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AREA_HPP -#include +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -#include -#include -#include -#include -#include +#include -namespace boost { namespace geometry -{ - -namespace strategy { namespace area -{ - -/*! -\brief Geographic area calculation -\ingroup strategies -\details Geographic area calculation by trapezoidal rule plus integral - approximation that gives the ellipsoidal correction -\tparam FormulaPolicy Formula used to calculate azimuths -\tparam SeriesOrder The order of approximation of the geodesic integral -\tparam Spheroid The spheroid model -\tparam CalculationType \tparam_calculation -\author See -- Danielsen JS, The area under the geodesic. Surv Rev 30(232): 61–66, 1989 -- Charles F.F Karney, Algorithms for geodesics, 2011 https://arxiv.org/pdf/1109.4448.pdf - -\qbk{ -[heading See also] -\* [link geometry.reference.algorithms.area.area_2_with_strategy area (with strategy)] -\* [link geometry.reference.srs.srs_spheroid srs::spheroid] -} -*/ -template -< - typename FormulaPolicy = strategy::andoyer, - std::size_t SeriesOrder = strategy::default_order::value, - typename Spheroid = srs::spheroid, - typename CalculationType = void -> -class geographic -{ - // Switch between two kinds of approximation(series in eps and n v.s.series in k ^ 2 and e'^2) - static const bool ExpandEpsN = true; - // LongSegment Enables special handling of long segments - static const bool LongSegment = false; - - //Select default types in case they are not set - -public: - template - struct result_type - : strategy::area::detail::result_type - < - Geometry, - CalculationType - > - {}; - -protected : - struct spheroid_constants - { - typedef typename boost::mpl::if_c - < - boost::is_void::value, - typename geometry::radius_type::type, - CalculationType - >::type calc_t; - - Spheroid m_spheroid; - calc_t const m_a2; // squared equatorial radius - calc_t const m_e2; // squared eccentricity - calc_t const m_ep2; // squared second eccentricity - calc_t const m_ep; // second eccentricity - calc_t const m_c2; // squared authalic radius - - inline spheroid_constants(Spheroid const& spheroid) - : m_spheroid(spheroid) - , m_a2(math::sqr(get_radius<0>(spheroid))) - , m_e2(formula::eccentricity_sqr(spheroid)) - , m_ep2(m_e2 / (calc_t(1.0) - m_e2)) - , m_ep(math::sqrt(m_ep2)) - , m_c2(formula_dispatch::authalic_radius_sqr - < - calc_t, Spheroid, srs_spheroid_tag - >::apply(m_a2, m_e2)) - {} - }; - -public: - template - class state - { - friend class geographic; - - typedef typename result_type::type return_type; - - public: - inline state() - : m_excess_sum(0) - , m_correction_sum(0) - , m_crosses_prime_meridian(0) - {} - - private: - inline return_type area(spheroid_constants const& spheroid_const) const - { - return_type result; - - return_type sum = spheroid_const.m_c2 * m_excess_sum - + spheroid_const.m_e2 * spheroid_const.m_a2 * m_correction_sum; - - // If encircles some pole - if (m_crosses_prime_meridian % 2 == 1) - { - std::size_t times_crosses_prime_meridian - = 1 + (m_crosses_prime_meridian / 2); - - result = return_type(2.0) - * geometry::math::pi() - * spheroid_const.m_c2 - * return_type(times_crosses_prime_meridian) - - geometry::math::abs(sum); - - if (geometry::math::sign(sum) == 1) - { - result = - result; - } - - } - else - { - result = sum; - } - - return result; - } - - return_type m_excess_sum; - return_type m_correction_sum; - - // Keep track if encircles some pole - std::size_t m_crosses_prime_meridian; - }; - -public : - explicit inline geographic(Spheroid const& spheroid = Spheroid()) - : m_spheroid_constants(spheroid) - {} - - template - inline void apply(PointOfSegment const& p1, - PointOfSegment const& p2, - state& st) const - { - if (! geometry::math::equals(get<0>(p1), get<0>(p2))) - { - typedef geometry::formula::area_formulas - < - typename result_type::type, - SeriesOrder, ExpandEpsN - > area_formulas; - - typename area_formulas::return_type_ellipsoidal result = - area_formulas::template ellipsoidal - (p1, p2, m_spheroid_constants); - - st.m_excess_sum += result.spherical_term; - st.m_correction_sum += result.ellipsoidal_term; - - // Keep track whenever a segment crosses the prime meridian - if (area_formulas::crosses_prime_meridian(p1, p2)) - { - st.m_crosses_prime_meridian++; - } - } - } - - template - inline typename result_type::type - result(state const& st) const - { - return st.area(m_spheroid_constants); - } - -private: - spheroid_constants m_spheroid_constants; - -}; - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - - -template <> -struct default_strategy -{ - typedef strategy::area::geographic<> type; -}; - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -} - -}} // namespace strategy::area - - - - -}} // namespace boost::geometry - #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_AREA_HPP diff --git a/include/boost/geometry/strategies/geographic/envelope.hpp b/include/boost/geometry/strategies/geographic/envelope.hpp index 56a95169e2..b6dc642de4 100644 --- a/include/boost/geometry/strategies/geographic/envelope.hpp +++ b/include/boost/geometry/strategies/geographic/envelope.hpp @@ -1,118 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015, 2016, 2018, 2019. -// Modifications copyright (c) 2015-2019, 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. - -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_HPP #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_HPP -#include - -#include -#include -#include -#include - -namespace boost { namespace geometry -{ - -namespace strategy { namespace envelope -{ - - -template -< - typename FormulaPolicy = strategy::andoyer, - typename Spheroid = geometry::srs::spheroid, - typename CalculationType = void -> -class geographic - : public spherical -{ -public: - typedef geographic_tag cs_tag; - - typedef Spheroid model_type; - - inline geographic() - : m_spheroid() - {} - - explicit inline geographic(Spheroid const& spheroid) - : m_spheroid(spheroid) - {} - - typedef geographic_segment - < - FormulaPolicy, Spheroid, CalculationType - > element_envelope_strategy_type; - inline element_envelope_strategy_type get_element_envelope_strategy() const - { - return element_envelope_strategy_type(m_spheroid); - } - - typedef expand::geographic_segment - < - FormulaPolicy, Spheroid, CalculationType - > element_expand_strategy_type; - inline element_expand_strategy_type get_element_expand_strategy() const - { - return element_expand_strategy_type(m_spheroid); - } - - template - inline void apply(Point1 const& point1, Point2 const& point2, Box& box) const - { - geographic_segment - < - FormulaPolicy, - Spheroid, - CalculationType - >(m_spheroid).apply(point1, point2, box); - } - -private: - Spheroid m_spheroid; -}; - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::geographic - < - strategy::andoyer, - geometry::srs::spheroid, - CalculationType - > type; -}; - -} -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::envelope +#include -}} //namepsace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_HPP diff --git a/include/boost/geometry/strategies/geographic/envelope_segment.hpp b/include/boost/geometry/strategies/geographic/envelope_segment.hpp index fda7868af2..8afe6959e8 100644 --- a/include/boost/geometry/strategies/geographic/envelope_segment.hpp +++ b/include/boost/geometry/strategies/geographic/envelope_segment.hpp @@ -1,123 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry + +// Copyright (c) 2020, Oracle and/or its affiliates. -// Copyright (c) 2017-2018 Oracle and/or its affiliates. -// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle // 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace geometry -{ - -namespace strategy { namespace envelope -{ - -template -< - typename FormulaPolicy = strategy::andoyer, - typename Spheroid = geometry::srs::spheroid, - typename CalculationType = void -> -class geographic_segment -{ -public: - typedef Spheroid model_type; - - inline geographic_segment() - : m_spheroid() - {} - - explicit inline geographic_segment(Spheroid const& spheroid) - : m_spheroid(spheroid) - {} - - typedef strategy::expand::spherical_box box_expand_strategy_type; - static inline box_expand_strategy_type get_box_expand_strategy() - { - return box_expand_strategy_type(); - } - - template - inline void apply(Point const& point1, Point const& point2, Box& box) const - { - Point p1_normalized, p2_normalized; - strategy::normalize::spherical_point::apply(point1, p1_normalized); - strategy::normalize::spherical_point::apply(point2, p2_normalized); - - geometry::strategy::azimuth::geographic - < - FormulaPolicy, - Spheroid, - CalculationType - > azimuth_geographic(m_spheroid); - - typedef typename geometry::detail::cs_angular_units - < - Point - >::type units_type; - - // first compute the envelope range for the first two coordinates - strategy::envelope::detail::envelope_segment_impl - < - geographic_tag - >::template apply(geometry::get<0>(p1_normalized), - geometry::get<1>(p1_normalized), - geometry::get<0>(p2_normalized), - geometry::get<1>(p2_normalized), - box, - azimuth_geographic); - - // now compute the envelope range for coordinates of - // dimension 2 and higher - strategy::envelope::detail::envelope_one_segment - < - 2, dimension::value - >::apply(point1, point2, box); - } - -private: - Spheroid m_spheroid; -}; - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::geographic_segment - < - strategy::andoyer, - srs::spheroid, - CalculationType - > type; -}; - -} - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::envelope +#include -}} //namepsace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP diff --git a/include/boost/geometry/strategies/geographic/expand_segment.hpp b/include/boost/geometry/strategies/geographic/expand_segment.hpp index 66779c1099..20c327602d 100644 --- a/include/boost/geometry/strategies/geographic/expand_segment.hpp +++ b/include/boost/geometry/strategies/geographic/expand_segment.hpp @@ -1,102 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015, 2016, 2017, 2018. -// Modifications copyright (c) 2015-2018, 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 -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_EXPAND_SEGMENT_HPP #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_EXPAND_SEGMENT_HPP -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include - - -namespace boost { namespace geometry -{ - -namespace strategy { namespace expand -{ - -template -< - typename FormulaPolicy = strategy::andoyer, - typename Spheroid = geometry::srs::spheroid, - typename CalculationType = void -> -class geographic_segment -{ -public: - inline geographic_segment() - : m_envelope_strategy() - {} - - explicit inline geographic_segment(Spheroid const& spheroid) - : m_envelope_strategy(spheroid) - {} - - template - inline void apply(Box& box, Segment const& segment) const - { - detail::segment_on_spheroid::apply(box, segment, m_envelope_strategy); - } - -private: - strategy::envelope::geographic_segment - < - FormulaPolicy, Spheroid, CalculationType - > m_envelope_strategy; -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef geographic_segment - < - strategy::andoyer, - geometry::srs::spheroid, - CalculationType - > type; -}; - -} // namespace services -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::expand +#include -}} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_EXPAND_SEGMENT_HPP diff --git a/include/boost/geometry/strategies/geographic/index.hpp b/include/boost/geometry/strategies/geographic/index.hpp index 202f0620df..216de31fff 100644 --- a/include/boost/geometry/strategies/geographic/index.hpp +++ b/include/boost/geometry/strategies/geographic/index.hpp @@ -12,6 +12,8 @@ #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INDEX_HPP #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INDEX_HPP +#include +#include #include #include // backward compatibility @@ -20,8 +22,6 @@ #include #include // backward compatibility #include // backward compatibility -#include -#include #include #include diff --git a/include/boost/geometry/strategies/geographic/intersection.hpp b/include/boost/geometry/strategies/geographic/intersection.hpp index 965e445651..aa3fff330d 100644 --- a/include/boost/geometry/strategies/geographic/intersection.hpp +++ b/include/boost/geometry/strategies/geographic/intersection.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// Copyright (c) 2016-2019, Oracle and/or its affiliates. +// Copyright (c) 2016-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, @@ -36,14 +36,16 @@ #include -#include +#include +#include +#include +#include + #include #include -#include #include #include #include -#include #include #include #include diff --git a/include/boost/geometry/strategies/geographic/side.hpp b/include/boost/geometry/strategies/geographic/side.hpp index 1a9648e74c..bbcf64f825 100644 --- a/include/boost/geometry/strategies/geographic/side.hpp +++ b/include/boost/geometry/strategies/geographic/side.hpp @@ -2,8 +2,8 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2014-2019. -// Modifications copyright (c) 2014-2019 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014-2020. +// Modifications copyright (c) 2014-2020 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -27,8 +27,9 @@ #include #include +#include + #include -#include #include #include #include diff --git a/include/boost/geometry/strategies/spherical.hpp b/include/boost/geometry/strategies/spherical.hpp new file mode 100644 index 0000000000..9d7ff7dfac --- /dev/null +++ b/include/boost/geometry/strategies/spherical.hpp @@ -0,0 +1,125 @@ +// Boost.Geometry + +// Copyright (c) 2020, 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_STRATEGIES_SPHERICAL_HPP +#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_HPP + + +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +namespace strategies +{ + + +template +< + typename RadiusTypeOrSphere = double, + typename CalculationType = void +> +class spherical : strategies::detail::spherical_base +{ + using base_t = strategies::detail::spherical_base; + +public: + spherical() + : base_t() + {} + + template + explicit spherical(RadiusOrSphere const& radius_or_sphere) + : base_t(radius_or_sphere) + {} + + // area + + template + auto area(Geometry const&) const + { + return strategy::area::spherical + < + typename base_t::radius_type, CalculationType + >(base_t::m_radius); + } + + // envelope + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::envelope::spherical_point(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_multi_point::type * = nullptr) + { + return strategy::envelope::spherical_multipoint(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::envelope::spherical_box(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_segment::type * = nullptr) + { + return strategy::envelope::spherical_segment(); + } + + template + static auto envelope(Geometry const&, Box const&, + typename strategies::detail::enable_if_non_trivial_linear_or_polygonal::type * = nullptr) + { + return strategy::envelope::spherical(); + } + + // expand + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_point::type * = nullptr) + { + return strategy::expand::spherical_point(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_box::type * = nullptr) + { + return strategy::expand::spherical_box(); + } + + template + static auto expand(Box const&, Geometry const&, + typename strategies::detail::enable_if_segment::type * = nullptr) + { + return strategy::expand::spherical_segment(); + } +}; + + +} // namespace strategies + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_HPP diff --git a/include/boost/geometry/strategies/spherical/area.hpp b/include/boost/geometry/strategies/spherical/area.hpp index d12ed9498f..e726d2392e 100644 --- a/include/boost/geometry/strategies/spherical/area.hpp +++ b/include/boost/geometry/strategies/spherical/area.hpp @@ -1,195 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2020, Oracle and/or its affiliates. -// Copyright (c) 2016-2018 Oracle and/or its affiliates. -// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle // 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_AREA_HPP #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_AREA_HPP -#include -#include -#include -#include +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -namespace boost { namespace geometry -{ +#include -namespace strategy { namespace area -{ - - -/*! -\brief Spherical area calculation -\ingroup strategies -\details Calculates area on the surface of a sphere using the trapezoidal rule -\tparam RadiusTypeOrSphere \tparam_radius_or_sphere -\tparam CalculationType \tparam_calculation - -\qbk{ -[heading See also] -[link geometry.reference.algorithms.area.area_2_with_strategy area (with strategy)] -} -*/ -template -< - typename RadiusTypeOrSphere = double, - typename CalculationType = void -> -class spherical -{ - // Enables special handling of long segments - static const bool LongSegment = false; - -public: - template - struct result_type - : strategy::area::detail::result_type - < - Geometry, - CalculationType - > - {}; - - template - class state - { - friend class spherical; - - typedef typename result_type::type return_type; - - public: - inline state() - : m_sum(0) - , m_crosses_prime_meridian(0) - {} - - private: - template - inline return_type area(RadiusType const& r) const - { - return_type result; - return_type radius = r; - - // Encircles pole - if(m_crosses_prime_meridian % 2 == 1) - { - size_t times_crosses_prime_meridian - = 1 + (m_crosses_prime_meridian / 2); - - result = return_type(2) - * geometry::math::pi() - * times_crosses_prime_meridian - - geometry::math::abs(m_sum); - - if(geometry::math::sign(m_sum) == 1) - { - result = - result; - } - - } else { - result = m_sum; - } - - result *= radius * radius; - - return result; - } - - return_type m_sum; - - // Keep track if encircles some pole - size_t m_crosses_prime_meridian; - }; - -public : - - // For backward compatibility reasons the radius is set to 1 - inline spherical() - : m_radius(1.0) - {} - - template - explicit inline spherical(RadiusOrSphere const& radius_or_sphere) - : m_radius(strategy_detail::get_radius - < - RadiusOrSphere - >::apply(radius_or_sphere)) - {} - - template - inline void apply(PointOfSegment const& p1, - PointOfSegment const& p2, - state& st) const - { - if (! geometry::math::equals(get<0>(p1), get<0>(p2))) - { - typedef geometry::formula::area_formulas - < - typename result_type::type - > area_formulas; - - st.m_sum += area_formulas::template spherical(p1, p2); - - // Keep track whenever a segment crosses the prime meridian - if (area_formulas::crosses_prime_meridian(p1, p2)) - { - st.m_crosses_prime_meridian++; - } - } - } - - template - inline typename result_type::type - result(state const& st) const - { - return st.area(m_radius); - } - -private : - typename strategy_detail::get_radius - < - RadiusTypeOrSphere - >::type m_radius; -}; - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - - -template <> -struct default_strategy -{ - typedef strategy::area::spherical<> type; -}; - -// Note: spherical polar coordinate system requires "get_as_radian_equatorial" -template <> -struct default_strategy -{ - typedef strategy::area::spherical<> type; -}; - -} // namespace services - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - - -}} // namespace strategy::area - - - - -}} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_AREA_HPP diff --git a/include/boost/geometry/strategies/spherical/envelope.hpp b/include/boost/geometry/strategies/spherical/envelope.hpp index 2632363872..7cc069b90a 100644 --- a/include/boost/geometry/strategies/spherical/envelope.hpp +++ b/include/boost/geometry/strategies/spherical/envelope.hpp @@ -1,148 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015, 2016, 2018, 2019. -// Modifications copyright (c) 2015-2019, 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. - -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_HPP #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_HPP -#include -#include - -#include - -#include -#include -#include -#include - -namespace boost { namespace geometry -{ - -namespace strategy { namespace envelope -{ - -template -class spherical -{ -public: - typedef spherical_tag cs_tag; - - typedef spherical_segment element_envelope_strategy_type; - static inline element_envelope_strategy_type get_element_envelope_strategy() - { - return element_envelope_strategy_type(); - } - - typedef expand::spherical_segment element_expand_strategy_type; - static inline element_expand_strategy_type get_element_expand_strategy() - { - return element_expand_strategy_type(); - } - - typedef strategy::expand::spherical_box box_expand_strategy_type; - static inline box_expand_strategy_type get_box_expand_strategy() - { - return box_expand_strategy_type(); - } - - // Linestring, Ring, Polygon - - template - static inline geometry::segment_iterator begin(Range const& range) - { - return geometry::segments_begin(range); - } - - template - static inline geometry::segment_iterator end(Range const& range) - { - return geometry::segments_end(range); - } - - // MultiLinestring, MultiPolygon - - template - struct multi_state - { - void apply(Box const& single_box) - { - m_boxes.push_back(single_box); - } - - void result(Box & box) - { - if (!m_boxes.empty()) - { - geometry::detail::envelope::envelope_range_of_boxes::apply(m_boxes, box); - } - else - { - geometry::detail::envelope::initialize::value>::apply(box); - } - } - - private: - std::vector m_boxes; - }; - - // Segment - - template - static inline void apply(Point1 const& point1, Point2 const& point2, - Box& box) - { - spherical_segment::apply(point1, point2, box); - } - - // Box - - template - static inline void apply(BoxIn const& box_in, Box& box) - { - spherical_box::apply(box_in, box); - } -}; - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::spherical type; -}; - -template -struct default_strategy -{ - typedef strategy::envelope::spherical type; -}; - -} -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::envelope +#include -}} //namepsace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_HPP diff --git a/include/boost/geometry/strategies/spherical/envelope_box.hpp b/include/boost/geometry/strategies/spherical/envelope_box.hpp index 2b26c629ad..ba3f848507 100644 --- a/include/boost/geometry/strategies/spherical/envelope_box.hpp +++ b/include/boost/geometry/strategies/spherical/envelope_box.hpp @@ -1,82 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015-2019. -// Modifications copyright (c) 2015-2019, 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 -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_BOX_HPP #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_BOX_HPP -#include - -#include - - -namespace boost { namespace geometry -{ - -namespace strategy { namespace envelope -{ - - -struct spherical_box - : geometry::detail::envelope::envelope_box_on_spheroid -{ - typedef spherical_tag cs_tag; - - typedef strategy::expand::spherical_box box_expand_strategy_type; - - static inline box_expand_strategy_type get_box_expand_strategy() - { - return box_expand_strategy_type(); - } -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::spherical_box type; -}; - -template -struct default_strategy -{ - typedef strategy::envelope::spherical_box type; -}; - -template -struct default_strategy -{ - typedef strategy::envelope::spherical_box type; -}; - -} - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - - -}} // namespace strategy::envelope +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace boost::geometry +#include #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_BOX_HPP diff --git a/include/boost/geometry/strategies/spherical/envelope_multipoint.hpp b/include/boost/geometry/strategies/spherical/envelope_multipoint.hpp index e7817370f1..f057566aee 100644 --- a/include/boost/geometry/strategies/spherical/envelope_multipoint.hpp +++ b/include/boost/geometry/strategies/spherical/envelope_multipoint.hpp @@ -1,379 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2015-2018, Oracle and/or its affiliates. +// Copyright (c) 2020, 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 -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_MULTIPOINT_HPP #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_MULTIPOINT_HPP -#include -#include -#include -#include -#include -#include +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -#include -#include -#include -#include -#include -#include -#include +#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - - -namespace boost { namespace geometry -{ - -namespace strategy { namespace envelope -{ - -class spherical_multipoint -{ -private: - template - struct coordinate_less - { - template - inline bool operator()(Point const& point1, Point const& point2) const - { - return math::smaller(geometry::get(point1), - geometry::get(point2)); - } - }; - - template - static inline void analyze_point_coordinates(MultiPoint const& multipoint, - bool& has_south_pole, - bool& has_north_pole, - OutputIterator oit) - { - typedef typename boost::range_value::type point_type; - typedef typename boost::range_iterator - < - MultiPoint const - >::type iterator_type; - - // analyze point coordinates: - // (1) normalize point coordinates - // (2) check if any point is the north or the south pole - // (3) put all non-pole points in a container - // - // notice that at this point in the algorithm, we have at - // least two points on the spheroid - has_south_pole = false; - has_north_pole = false; - - for (iterator_type it = boost::begin(multipoint); - it != boost::end(multipoint); - ++it) - { - point_type point; - normalize::spherical_point::apply(*it, point); - - if (math::equals(geometry::get<1>(point), - Constants::min_latitude())) - { - has_south_pole = true; - } - else if (math::equals(geometry::get<1>(point), - Constants::max_latitude())) - { - has_north_pole = true; - } - else - { - *oit++ = point; - } - } - } - - template - static inline Value maximum_gap(SortedRange const& sorted_range, - Value& max_gap_left, - Value& max_gap_right) - { - typedef typename boost::range_iterator - < - SortedRange const - >::type iterator_type; - - iterator_type it1 = boost::begin(sorted_range), it2 = it1; - ++it2; - max_gap_left = geometry::get<0>(*it1); - max_gap_right = geometry::get<0>(*it2); - - Value max_gap = max_gap_right - max_gap_left; - for (++it1, ++it2; it2 != boost::end(sorted_range); ++it1, ++it2) - { - Value gap = geometry::get<0>(*it2) - geometry::get<0>(*it1); - if (math::larger(gap, max_gap)) - { - max_gap_left = geometry::get<0>(*it1); - max_gap_right = geometry::get<0>(*it2); - max_gap = gap; - } - } - - return max_gap; - } - - template - < - typename Constants, - typename PointRange, - typename LongitudeLess, - typename CoordinateType - > - static inline void get_min_max_longitudes(PointRange& range, - LongitudeLess const& lon_less, - CoordinateType& lon_min, - CoordinateType& lon_max) - { - typedef typename boost::range_iterator - < - PointRange const - >::type iterator_type; - - // compute min and max longitude values - std::pair min_max_longitudes - = boost::minmax_element(boost::begin(range), - boost::end(range), - lon_less); - - lon_min = geometry::get<0>(*min_max_longitudes.first); - lon_max = geometry::get<0>(*min_max_longitudes.second); - - // if the longitude span is "large" compute the true maximum gap - if (math::larger(lon_max - lon_min, Constants::half_period())) - { - std::sort(boost::begin(range), boost::end(range), lon_less); - - CoordinateType max_gap_left = 0, max_gap_right = 0; - CoordinateType max_gap - = maximum_gap(range, max_gap_left, max_gap_right); - - CoordinateType complement_gap - = Constants::period() + lon_min - lon_max; - - if (math::larger(max_gap, complement_gap)) - { - lon_min = max_gap_right; - lon_max = max_gap_left + Constants::period(); - } - } - } - - template - < - typename Constants, - typename Iterator, - typename LatitudeLess, - typename CoordinateType - > - static inline void get_min_max_latitudes(Iterator const first, - Iterator const last, - LatitudeLess const& lat_less, - bool has_south_pole, - bool has_north_pole, - CoordinateType& lat_min, - CoordinateType& lat_max) - { - if (has_south_pole && has_north_pole) - { - lat_min = Constants::min_latitude(); - lat_max = Constants::max_latitude(); - } - else if (has_south_pole) - { - lat_min = Constants::min_latitude(); - lat_max - = geometry::get<1>(*std::max_element(first, last, lat_less)); - } - else if (has_north_pole) - { - lat_min - = geometry::get<1>(*std::min_element(first, last, lat_less)); - lat_max = Constants::max_latitude(); - } - else - { - std::pair min_max_latitudes - = boost::minmax_element(first, last, lat_less); - - lat_min = geometry::get<1>(*min_max_latitudes.first); - lat_max = geometry::get<1>(*min_max_latitudes.second); - } - } - -public: - template - static inline void apply(MultiPoint const& multipoint, Box& mbr) - { - typedef typename point_type::type point_type; - typedef typename coordinate_type::type coordinate_type; - typedef typename boost::range_iterator - < - MultiPoint const - >::type iterator_type; - - typedef math::detail::constants_on_spheroid - < - coordinate_type, - typename geometry::detail::cs_angular_units::type - > constants; - - if (boost::empty(multipoint)) - { - geometry::detail::envelope::initialize::value>::apply(mbr); - return; - } - - geometry::detail::envelope::initialize::apply(mbr); - - if (boost::size(multipoint) == 1) - { - return dispatch::envelope - < - typename boost::range_value::type - >::apply(range::front(multipoint), mbr, strategy::envelope::spherical_point()); - } - - // analyze the points and put the non-pole ones in the - // points vector - std::vector points; - bool has_north_pole = false, has_south_pole = false; - - analyze_point_coordinates(multipoint, - has_south_pole, has_north_pole, - std::back_inserter(points)); - - coordinate_type lon_min, lat_min, lon_max, lat_max; - if (points.size() == 1) - { - // we have one non-pole point and at least one pole point - lon_min = geometry::get<0>(range::front(points)); - lon_max = geometry::get<0>(range::front(points)); - lat_min = has_south_pole - ? constants::min_latitude() - : constants::max_latitude(); - lat_max = has_north_pole - ? constants::max_latitude() - : constants::min_latitude(); - } - else if (points.empty()) - { - // all points are pole points - BOOST_GEOMETRY_ASSERT(has_south_pole || has_north_pole); - lon_min = coordinate_type(0); - lon_max = coordinate_type(0); - lat_min = has_south_pole - ? constants::min_latitude() - : constants::max_latitude(); - lat_max = (has_north_pole) - ? constants::max_latitude() - : constants::min_latitude(); - } - else - { - get_min_max_longitudes(points, - coordinate_less<0>(), - lon_min, - lon_max); - - get_min_max_latitudes(points.begin(), - points.end(), - coordinate_less<1>(), - has_south_pole, - has_north_pole, - lat_min, - lat_max); - } - - typedef typename helper_geometry - < - Box, - coordinate_type, - typename geometry::detail::cs_angular_units::type - >::type helper_box_type; - - helper_box_type helper_mbr; - - geometry::set(helper_mbr, lon_min); - geometry::set(helper_mbr, lat_min); - geometry::set(helper_mbr, lon_max); - geometry::set(helper_mbr, lat_max); - - // now transform to output MBR (per index) - geometry::detail::envelope::envelope_indexed_box_on_spheroid::apply(helper_mbr, mbr); - geometry::detail::envelope::envelope_indexed_box_on_spheroid::apply(helper_mbr, mbr); - - // compute envelope for higher coordinates - iterator_type it = boost::begin(multipoint); - geometry::detail::envelope::envelope_one_point<2, dimension::value>::apply(*it, mbr); - - for (++it; it != boost::end(multipoint); ++it) - { - strategy::expand::detail::point_loop - < - 2, dimension::value - >::apply(mbr, *it); - } - } -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::spherical_multipoint type; -}; - -template -struct default_strategy -{ - typedef strategy::envelope::spherical_multipoint type; -}; - -template -struct default_strategy -{ - typedef strategy::envelope::spherical_multipoint type; -}; - -} // namespace services - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - - -}} // namespace strategy::envelope - -}} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_MULTIPOINT_HPP diff --git a/include/boost/geometry/strategies/spherical/envelope_point.hpp b/include/boost/geometry/strategies/spherical/envelope_point.hpp index 8302d7e56f..cb6e2453be 100644 --- a/include/boost/geometry/strategies/spherical/envelope_point.hpp +++ b/include/boost/geometry/strategies/spherical/envelope_point.hpp @@ -1,111 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015, 2016, 2017, 2018. -// Modifications copyright (c) 2015-2018, 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 -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_POINT_HPP #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_POINT_HPP -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include - -#include - - -namespace boost { namespace geometry -{ - -namespace strategy { namespace envelope -{ - -struct spherical_point -{ - template - static inline void apply(Point const& point, Box& mbr) - { - Point normalized_point; - strategy::normalize::spherical_point::apply(point, normalized_point); - - typename point_type::type box_point; - - // transform units of input point to units of a box point - geometry::detail::envelope::transform_units(normalized_point, box_point); - - geometry::set(mbr, geometry::get<0>(box_point)); - geometry::set(mbr, geometry::get<1>(box_point)); - - geometry::set(mbr, geometry::get<0>(box_point)); - geometry::set(mbr, geometry::get<1>(box_point)); - - typedef geometry::detail::envelope::envelope_one_point - < - 2, dimension::value - > per_corner; - per_corner::template apply(normalized_point, mbr); - per_corner::template apply(normalized_point, mbr); - } -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::spherical_point type; -}; - -template -struct default_strategy -{ - typedef strategy::envelope::spherical_point type; -}; - -template -struct default_strategy -{ - typedef strategy::envelope::spherical_point type; -}; - - -} - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -}} // namespace strategy::envelope +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace boost::geometry +#include #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_POINT_HPP diff --git a/include/boost/geometry/strategies/spherical/envelope_segment.hpp b/include/boost/geometry/strategies/spherical/envelope_segment.hpp index 646d6695e1..8e9a099bbd 100644 --- a/include/boost/geometry/strategies/spherical/envelope_segment.hpp +++ b/include/boost/geometry/strategies/spherical/envelope_segment.hpp @@ -1,445 +1,22 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry + +// Copyright (c) 2020, Oracle and/or its affiliates. -// Copyright (c) 2017-2018 Oracle and/or its affiliates. -// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle // 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_SEGMENT_HPP #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_SEGMENT_HPP -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -namespace boost { namespace geometry { namespace strategy { namespace envelope -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - -template -struct envelope_segment_call_vertex_latitude -{ - template - static inline CalculationType apply(T1 const& lat1, - T2 const& alp1, - Strategy const& ) - { - return geometry::formula::vertex_latitude - ::apply(lat1, alp1); - } -}; - -template -struct envelope_segment_call_vertex_latitude -{ - template - static inline CalculationType apply(T1 const& lat1, - T2 const& alp1, - Strategy const& strategy) - { - return geometry::formula::vertex_latitude - ::apply(lat1, alp1, strategy.model()); - } -}; - -template -struct envelope_segment_convert_polar -{ - template - static inline void pre(T & , T & ) {} - - template - static inline void post(T & , T & ) {} -}; - -template -struct envelope_segment_convert_polar -{ - template - static inline void pre(T & lat1, T & lat2) - { - lat1 = math::latitude_convert_ep(lat1); - lat2 = math::latitude_convert_ep(lat2); - } - - template - static inline void post(T & lat1, T & lat2) - { - lat1 = math::latitude_convert_ep(lat1); - lat2 = math::latitude_convert_ep(lat2); - std::swap(lat1, lat2); - } -}; - -template -class envelope_segment_impl -{ -private: - - // degrees or radians - template - static inline void swap(CalculationType& lon1, - CalculationType& lat1, - CalculationType& lon2, - CalculationType& lat2) - { - std::swap(lon1, lon2); - std::swap(lat1, lat2); - } - - // radians - template - static inline bool contains_pi_half(CalculationType const& a1, - CalculationType const& a2) - { - // azimuths a1 and a2 are assumed to be in radians - BOOST_GEOMETRY_ASSERT(! math::equals(a1, a2)); - - static CalculationType const pi_half = math::half_pi(); - - return (a1 < a2) - ? (a1 < pi_half && pi_half < a2) - : (a1 > pi_half && pi_half > a2); - } - - // radians or degrees - template - static inline bool crosses_antimeridian(CoordinateType const& lon1, - CoordinateType const& lon2) - { - typedef math::detail::constants_on_spheroid - < - CoordinateType, Units - > constants; - - return math::abs(lon1 - lon2) > constants::half_period(); // > pi - } - - // degrees or radians - template - static inline void compute_box_corners(CalculationType& lon1, - CalculationType& lat1, - CalculationType& lon2, - CalculationType& lat2, - CalculationType a1, - CalculationType a2, - Strategy const& strategy) - { - // coordinates are assumed to be in radians - BOOST_GEOMETRY_ASSERT(lon1 <= lon2); - boost::ignore_unused(lon1, lon2); - - CalculationType lat1_rad = math::as_radian(lat1); - CalculationType lat2_rad = math::as_radian(lat2); - - if (math::equals(a1, a2)) - { - // the segment must lie on the equator or is very short or is meridian - return; - } - - if (lat1 > lat2) - { - std::swap(lat1, lat2); - std::swap(lat1_rad, lat2_rad); - std::swap(a1, a2); - } - - if (contains_pi_half(a1, a2)) - { - CalculationType p_max = envelope_segment_call_vertex_latitude - ::apply(lat1_rad, a1, strategy); - - CalculationType const mid_lat = lat1 + lat2; - if (mid_lat < 0) - { - // update using min latitude - CalculationType const lat_min_rad = -p_max; - CalculationType const lat_min - = math::from_radian(lat_min_rad); - - if (lat1 > lat_min) - { - lat1 = lat_min; - } - } - else - { - // update using max latitude - CalculationType const lat_max_rad = p_max; - CalculationType const lat_max - = math::from_radian(lat_max_rad); - - if (lat2 < lat_max) - { - lat2 = lat_max; - } - } - } - } - - template - static inline void special_cases(CalculationType& lon1, - CalculationType& lat1, - CalculationType& lon2, - CalculationType& lat2) - { - typedef math::detail::constants_on_spheroid - < - CalculationType, Units - > constants; - - bool is_pole1 = math::equals(math::abs(lat1), constants::max_latitude()); - bool is_pole2 = math::equals(math::abs(lat2), constants::max_latitude()); - - if (is_pole1 && is_pole2) - { - // both points are poles; nothing more to do: - // longitudes are already normalized to 0 - // but just in case - lon1 = 0; - lon2 = 0; - } - else if (is_pole1 && !is_pole2) - { - // first point is a pole, second point is not: - // make the longitude of the first point the same as that - // of the second point - lon1 = lon2; - } - else if (!is_pole1 && is_pole2) - { - // second point is a pole, first point is not: - // make the longitude of the second point the same as that - // of the first point - lon2 = lon1; - } - - if (lon1 == lon2) - { - // segment lies on a meridian - if (lat1 > lat2) - { - std::swap(lat1, lat2); - } - return; - } - - BOOST_GEOMETRY_ASSERT(!is_pole1 && !is_pole2); - - if (lon1 > lon2) - { - swap(lon1, lat1, lon2, lat2); - } - - if (crosses_antimeridian(lon1, lon2)) - { - lon1 += constants::period(); - swap(lon1, lat1, lon2, lat2); - } - } - - template - < - typename Units, - typename CalculationType, - typename Box - > - static inline void create_box(CalculationType lon1, - CalculationType lat1, - CalculationType lon2, - CalculationType lat2, - Box& mbr) - { - typedef typename coordinate_type::type box_coordinate_type; - - typedef typename helper_geometry - < - Box, box_coordinate_type, Units - >::type helper_box_type; - - helper_box_type helper_mbr; - - geometry::set - < - min_corner, 0 - >(helper_mbr, boost::numeric_cast(lon1)); - - geometry::set - < - min_corner, 1 - >(helper_mbr, boost::numeric_cast(lat1)); - - geometry::set - < - max_corner, 0 - >(helper_mbr, boost::numeric_cast(lon2)); - - geometry::set - < - max_corner, 1 - >(helper_mbr, boost::numeric_cast(lat2)); - - geometry::detail::envelope::transform_units(helper_mbr, mbr); - } - - - template - static inline void apply(CalculationType& lon1, - CalculationType& lat1, - CalculationType& lon2, - CalculationType& lat2, - Strategy const& strategy) - { - special_cases(lon1, lat1, lon2, lat2); - - CalculationType lon1_rad = math::as_radian(lon1); - CalculationType lat1_rad = math::as_radian(lat1); - CalculationType lon2_rad = math::as_radian(lon2); - CalculationType lat2_rad = math::as_radian(lat2); - CalculationType alp1, alp2; - strategy.apply(lon1_rad, lat1_rad, lon2_rad, lat2_rad, alp1, alp2); - - compute_box_corners(lon1, lat1, lon2, lat2, alp1, alp2, strategy); - } - -public: - template - < - typename Units, - typename CalculationType, - typename Box, - typename Strategy - > - static inline void apply(CalculationType lon1, - CalculationType lat1, - CalculationType lon2, - CalculationType lat2, - Box& mbr, - Strategy const& strategy) - { - typedef envelope_segment_convert_polar::type> convert_polar; - - convert_polar::pre(lat1, lat2); - - apply(lon1, lat1, lon2, lat2, strategy); - - convert_polar::post(lat1, lat2); - - create_box(lon1, lat1, lon2, lat2, mbr); - } - -}; - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - - -template -< - typename CalculationType = void -> -class spherical_segment -{ -public: - typedef strategy::expand::spherical_box box_expand_strategy_type; - static inline box_expand_strategy_type get_box_expand_strategy() - { - return box_expand_strategy_type(); - } - - template - static inline void apply(Point const& point1, Point const& point2, - Box& box) - { - Point p1_normalized, p2_normalized; - strategy::normalize::spherical_point::apply(point1, p1_normalized); - strategy::normalize::spherical_point::apply(point2, p2_normalized); - - geometry::strategy::azimuth::spherical azimuth_spherical; - - typedef typename geometry::detail::cs_angular_units::type units_type; - - // first compute the envelope range for the first two coordinates - strategy::envelope::detail::envelope_segment_impl - < - spherical_equatorial_tag - >::template apply(geometry::get<0>(p1_normalized), - geometry::get<1>(p1_normalized), - geometry::get<0>(p2_normalized), - geometry::get<1>(p2_normalized), - box, - azimuth_spherical); - - // now compute the envelope range for coordinates of - // dimension 2 and higher - strategy::envelope::detail::envelope_one_segment - < - 2, dimension::value - >::apply(point1, point2, box); - } -}; - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef strategy::envelope::spherical_segment type; -}; - - -template -struct default_strategy -{ - typedef strategy::envelope::spherical_segment type; -}; - -} - -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::envelope +#include -}} //namepsace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_SEGMENT_HPP diff --git a/include/boost/geometry/strategies/spherical/expand_box.hpp b/include/boost/geometry/strategies/spherical/expand_box.hpp index e4bfafadd5..123542244d 100644 --- a/include/boost/geometry/strategies/spherical/expand_box.hpp +++ b/include/boost/geometry/strategies/spherical/expand_box.hpp @@ -1,175 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015, 2016, 2017, 2018, 2019. -// Modifications copyright (c) 2015-2019, 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 -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_BOX_HPP #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_BOX_HPP -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -namespace boost { namespace geometry -{ - - -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace envelope -{ - -template -< - std::size_t Index, - std::size_t DimensionCount -> -struct envelope_indexed_box_on_spheroid -{ - template - static inline void apply(BoxIn const& box_in, BoxOut& mbr) - { - // transform() does not work with boxes of dimension higher - // than 2; to account for such boxes we transform the min/max - // points of the boxes using the indexed_point_view - detail::indexed_point_view box_in_corner(box_in); - detail::indexed_point_view mbr_corner(mbr); - - // first transform the units - transform_units(box_in_corner, mbr_corner); - - // now transform the remaining coordinates - detail::conversion::point_to_point - < - detail::indexed_point_view, - detail::indexed_point_view, - 2, - DimensionCount - >::apply(box_in_corner, mbr_corner); - } -}; - -struct envelope_box_on_spheroid -{ - template - static inline void apply(BoxIn const& box_in, BoxOut& mbr) - { - // BoxIn can be non-mutable - typename helper_geometry::type box_in_normalized; - geometry::convert(box_in, box_in_normalized); - - if (! is_inverse_spheroidal_coordinates(box_in)) - { - strategy::normalize::spherical_box::apply(box_in, box_in_normalized); - } - - geometry::detail::envelope::envelope_indexed_box_on_spheroid - < - min_corner, dimension::value - >::apply(box_in_normalized, mbr); - - geometry::detail::envelope::envelope_indexed_box_on_spheroid - < - max_corner, dimension::value - >::apply(box_in_normalized, mbr); - } -}; - -}} // namespace detail::envelope -#endif // DOXYGEN_NO_DETAIL - - -namespace strategy { namespace expand -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - -struct box_on_spheroid -{ - template - static inline void apply(BoxOut& box_out, BoxIn const& box_in) - { - // normalize both boxes and convert box-in to be of type of box-out - BoxOut mbrs[2]; - geometry::detail::envelope::envelope_box_on_spheroid::apply(box_in, mbrs[0]); - geometry::detail::envelope::envelope_box_on_spheroid::apply(box_out, mbrs[1]); - - // compute the envelope of the two boxes - geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box_out); - } -}; - - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - - -struct spherical_box - : detail::box_on_spheroid -{}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef spherical_box type; -}; - -template -struct default_strategy -{ - typedef spherical_box type; -}; - -template -struct default_strategy -{ - typedef spherical_box type; -}; - -} // namespace services -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::expand +#include -}} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_BOX_HPP diff --git a/include/boost/geometry/strategies/spherical/expand_point.hpp b/include/boost/geometry/strategies/spherical/expand_point.hpp index b2cff013ae..b56d9fd186 100644 --- a/include/boost/geometry/strategies/spherical/expand_point.hpp +++ b/include/boost/geometry/strategies/spherical/expand_point.hpp @@ -1,233 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015-2018. -// Modifications copyright (c) 2015-2018, 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. - -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_POINT_HPP #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_POINT_HPP -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include - - -namespace boost { namespace geometry -{ - -namespace strategy { namespace expand -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - -// implementation for the spherical and geographic coordinate systems -template -struct point_loop_on_spheroid -{ - template - static inline void apply(Box& box, Point const& point) - { - typedef typename point_type::type box_point_type; - typedef typename coordinate_type::type box_coordinate_type; - typedef typename geometry::detail::cs_angular_units::type units_type; - - typedef math::detail::constants_on_spheroid - < - box_coordinate_type, - units_type - > constants; - - // normalize input point and input box - Point p_normalized; - strategy::normalize::spherical_point::apply(point, p_normalized); - - // transform input point to be of the same type as the box point - box_point_type box_point; - geometry::detail::envelope::transform_units(p_normalized, box_point); - - if (is_inverse_spheroidal_coordinates(box)) - { - geometry::set_from_radian(box, geometry::get_as_radian<0>(p_normalized)); - geometry::set_from_radian(box, geometry::get_as_radian<1>(p_normalized)); - geometry::set_from_radian(box, geometry::get_as_radian<0>(p_normalized)); - geometry::set_from_radian(box, geometry::get_as_radian<1>(p_normalized)); - - } else { - - strategy::normalize::spherical_box::apply(box, box); - - box_coordinate_type p_lon = geometry::get<0>(box_point); - box_coordinate_type p_lat = geometry::get<1>(box_point); - - typename coordinate_type::type - b_lon_min = geometry::get(box), - b_lat_min = geometry::get(box), - b_lon_max = geometry::get(box), - b_lat_max = geometry::get(box); - - if (math::is_latitude_pole(p_lat)) - { - // the point of expansion is the either the north or the - // south pole; the only important coordinate here is the - // pole's latitude, as the longitude can be anything; - // we, thus, take into account the point's latitude only and return - geometry::set(box, (std::min)(p_lat, b_lat_min)); - geometry::set(box, (std::max)(p_lat, b_lat_max)); - return; - } - - if (math::equals(b_lat_min, b_lat_max) - && math::is_latitude_pole(b_lat_min)) - { - // the box degenerates to either the north or the south pole; - // the only important coordinate here is the pole's latitude, - // as the longitude can be anything; - // we thus take into account the box's latitude only and return - geometry::set(box, p_lon); - geometry::set(box, (std::min)(p_lat, b_lat_min)); - geometry::set(box, p_lon); - geometry::set(box, (std::max)(p_lat, b_lat_max)); - return; - } - - // update latitudes - b_lat_min = (std::min)(b_lat_min, p_lat); - b_lat_max = (std::max)(b_lat_max, p_lat); - - // update longitudes - if (math::smaller(p_lon, b_lon_min)) - { - box_coordinate_type p_lon_shifted = p_lon + constants::period(); - - if (math::larger(p_lon_shifted, b_lon_max)) - { - // here we could check using: ! math::larger(.., ..) - if (math::smaller(b_lon_min - p_lon, p_lon_shifted - b_lon_max)) - { - b_lon_min = p_lon; - } - else - { - b_lon_max = p_lon_shifted; - } - } - } - else if (math::larger(p_lon, b_lon_max)) - { - // in this case, and since p_lon is normalized in the range - // (-180, 180], we must have that b_lon_max <= 180 - if (b_lon_min < 0 - && math::larger(p_lon - b_lon_max, - constants::period() - p_lon + b_lon_min)) - { - b_lon_min = p_lon; - b_lon_max += constants::period(); - } - else - { - b_lon_max = p_lon; - } - } - - geometry::set(box, b_lon_min); - geometry::set(box, b_lat_min); - geometry::set(box, b_lon_max); - geometry::set(box, b_lat_max); - } - - point_loop - < - 2, DimensionCount - >::apply(box, point); - } -}; - - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - - -struct spherical_point -{ - template - static void apply(Box & box, Point const& point) - { - expand::detail::point_loop_on_spheroid - < - dimension::value, - ! boost::is_same::type, spherical_polar_tag>::value - >::apply(box, point); - } -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef spherical_point type; -}; - -template -struct default_strategy -{ - typedef spherical_point type; -}; - -template -struct default_strategy -{ - typedef spherical_point type; -}; - - -} // namespace services -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::expand +#include -}} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_POINT_HPP diff --git a/include/boost/geometry/strategies/spherical/expand_segment.hpp b/include/boost/geometry/strategies/spherical/expand_segment.hpp index 75f4698ff0..19211e5dfb 100644 --- a/include/boost/geometry/strategies/spherical/expand_segment.hpp +++ b/include/boost/geometry/strategies/spherical/expand_segment.hpp @@ -1,118 +1,21 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. +// Copyright (c) 2020, Oracle and/or its affiliates. -// This file was modified by Oracle on 2015, 2016, 2017, 2018. -// Modifications copyright (c) 2015-2018, 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 -// 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) +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_SEGMENT_HPP #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_SEGMENT_HPP -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include - - -namespace boost { namespace geometry -{ - -namespace strategy { namespace expand -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - -struct segment_on_spheroid -{ - template - static inline void apply(Box& box, Segment const& segment, EnvelopeStrategy const& strategy) - { - Box mbrs[2]; - - // compute the envelope of the segment - typename point_type::type p[2]; - geometry::detail::assign_point_from_index<0>(segment, p[0]); - geometry::detail::assign_point_from_index<1>(segment, p[1]); - geometry::detail::envelope::envelope_segment - < - dimension::value - >::apply(p[0], p[1], mbrs[0], strategy); - - // normalize the box - strategy::envelope::spherical_box::apply(box, mbrs[1]); - - // compute the envelope of the two boxes - geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box); - } -}; - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - - -template -< - typename CalculationType = void -> -class spherical_segment -{ -public: - template - static inline void apply(Box& box, Segment const& segment) - { - detail::segment_on_spheroid::apply(box, segment, - strategy::envelope::spherical_segment()); - } -}; - - -#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS - -namespace services -{ - -template -struct default_strategy -{ - typedef spherical_segment type; -}; - -template -struct default_strategy -{ - typedef spherical_segment type; -}; - -} // namespace services -#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +#include +BOOST_PRAGMA_MESSAGE("This include file is deprecated and will be removed in the future.") -}} // namespace strategy::expand +#include -}} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_SEGMENT_HPP diff --git a/include/boost/geometry/strategies/spherical/index.hpp b/include/boost/geometry/strategies/spherical/index.hpp index cd1734e944..909f1ed8d6 100644 --- a/include/boost/geometry/strategies/spherical/index.hpp +++ b/include/boost/geometry/strategies/spherical/index.hpp @@ -2,7 +2,7 @@ // // R-tree strategies // -// Copyright (c) 2019, Oracle and/or its affiliates. +// Copyright (c) 2019-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, @@ -12,16 +12,17 @@ #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_INDEX_HPP #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_INDEX_HPP +#include +#include +#include +#include +#include +#include + #include #include #include #include -#include -#include -#include -#include -#include -#include #include #include diff --git a/include/boost/geometry/strategies/spherical/intersection.hpp b/include/boost/geometry/strategies/spherical/intersection.hpp index e9a9cc3dbe..5e9baf6a19 100644 --- a/include/boost/geometry/strategies/spherical/intersection.hpp +++ b/include/boost/geometry/strategies/spherical/intersection.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// Copyright (c) 2016-2019, Oracle and/or its affiliates. +// Copyright (c) 2016-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, @@ -35,17 +35,19 @@ #include +#include +#include +#include +#include + #include #include #include #include #include -#include #include #include #include -#include -#include #include #include #include diff --git a/include/boost/geometry/strategies/spherical/point_in_poly_winding.hpp b/include/boost/geometry/strategies/spherical/point_in_poly_winding.hpp index 1917869ed1..1b0216a76b 100644 --- a/include/boost/geometry/strategies/spherical/point_in_poly_winding.hpp +++ b/include/boost/geometry/strategies/spherical/point_in_poly_winding.hpp @@ -3,8 +3,8 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2013-2017 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013, 2014, 2016, 2017, 2018, 2019. -// Modifications copyright (c) 2013-2019 Oracle and/or its affiliates. +// This file was modified by Oracle on 2013-2020. +// Modifications copyright (c) 2013-2020 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 @@ -27,6 +27,8 @@ #include #include +#include + #include #include #include diff --git a/include/boost/geometry/strategies/spherical/point_order.hpp b/include/boost/geometry/strategies/spherical/point_order.hpp index ad294aa386..b845d5ab9a 100644 --- a/include/boost/geometry/strategies/spherical/point_order.hpp +++ b/include/boost/geometry/strategies/spherical/point_order.hpp @@ -1,6 +1,6 @@ // Boost.Geometry -// Copyright (c) 2019, Oracle and/or its affiliates. +// Copyright (c) 2019-2020, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -18,7 +18,7 @@ #include -#include +#include #include #include @@ -114,6 +114,12 @@ struct spherical : strategy::area::spherical { typedef area_tag version_tag; + + // TEMP + static strategy::area::spherical get_area_strategy() + { + return strategy::area::spherical(); + } }; namespace services diff --git a/include/boost/geometry/strategies/spherical/ssf.hpp b/include/boost/geometry/strategies/spherical/ssf.hpp index 2567cf56c2..c787c074e3 100644 --- a/include/boost/geometry/strategies/spherical/ssf.hpp +++ b/include/boost/geometry/strategies/spherical/ssf.hpp @@ -2,8 +2,8 @@ // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2016, 2018, 2019. -// Modifications copyright (c) 2016-2019, Oracle and/or its affiliates. +// This file was modified by Oracle on 2016-2020. +// Modifications copyright (c) 2016-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, @@ -22,9 +22,10 @@ #include #include +#include + #include #include -#include //#include #include diff --git a/include/boost/geometry/strategies/strategies.hpp b/include/boost/geometry/strategies/strategies.hpp index 65127f8257..f02b9adbe2 100644 --- a/include/boost/geometry/strategies/strategies.hpp +++ b/include/boost/geometry/strategies/strategies.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014-2019. -// Modifications copyright (c) 2014-2019 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014-2020. +// Modifications copyright (c) 2014-2020 Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -24,7 +24,6 @@ #include -#include #include #include #include @@ -34,7 +33,6 @@ #include #include #include -#include #include #include // for backward compatibility #include @@ -42,7 +40,6 @@ #include #include -#include #include #include #include @@ -64,13 +61,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -81,7 +71,6 @@ #include #include -#include #include #include #include @@ -91,13 +80,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -105,7 +87,6 @@ #include #include -#include #include #include #include @@ -119,8 +100,6 @@ #include #include //#include -#include -#include #include #include //#include @@ -145,5 +124,40 @@ #include #include +// TEMP + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + #endif // BOOST_GEOMETRY_STRATEGIES_STRATEGIES_HPP diff --git a/include/boost/geometry/strategy/area.hpp b/include/boost/geometry/strategy/area.hpp new file mode 100644 index 0000000000..e3e781d1ed --- /dev/null +++ b/include/boost/geometry/strategy/area.hpp @@ -0,0 +1,97 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2020. +// Modifications copyright (c) 2020 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. + +// 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) + +#ifndef BOOST_GEOMETRY_STRATEGY_AREA_HPP +#define BOOST_GEOMETRY_STRATEGY_AREA_HPP + + +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + + +namespace strategy { namespace area +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +// If user specified a CalculationType, use that type, whatever it is +// and whatever the Geometry is. +// Else, use Geometry's coordinate-type promoted to double if needed. +template +< + typename Geometry, + typename CalculationType +> +struct result_type +{ + typedef CalculationType type; +}; + +template +< + typename Geometry +> +struct result_type + : select_most_precise + < + typename coordinate_type::type, + double + > +{}; + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +namespace services +{ + +/*! + \brief Traits class binding a default area strategy to a coordinate system + \ingroup area + \tparam Tag tag of coordinate system +*/ +template +struct default_strategy +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_COORDINATE_SYSTEM + , (types) + ); +}; + + +} // namespace services + +}} // namespace strategy::area + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_AREA_HPP diff --git a/include/boost/geometry/strategy/cartesian/area.hpp b/include/boost/geometry/strategy/cartesian/area.hpp new file mode 100644 index 0000000000..130df46512 --- /dev/null +++ b/include/boost/geometry/strategy/cartesian/area.hpp @@ -0,0 +1,147 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2016-2020. +// Modifications copyright (c) 2016-2020, 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. + +// 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) + +#ifndef BOOST_GEOMETRY_STRATEGY_CARTESIAN_AREA_HPP +#define BOOST_GEOMETRY_STRATEGY_CARTESIAN_AREA_HPP + + +#include + +//#include +#include +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace area +{ + +/*! +\brief Cartesian area calculation +\ingroup strategies +\details Calculates cartesian area using the trapezoidal rule +\tparam CalculationType \tparam_calculation + +\qbk{ +[heading See also] +[link geometry.reference.algorithms.area.area_2_with_strategy area (with strategy)] +} + +*/ +template +< + typename CalculationType = void +> +class cartesian +{ +public : + template + struct result_type + : strategy::area::detail::result_type + < + Geometry, + CalculationType + > + {}; + + template + class state + { + friend class cartesian; + + typedef typename result_type::type return_type; + + public: + inline state() + : sum(0) + { + // Strategy supports only 2D areas + assert_dimension(); + } + + private: + inline return_type area() const + { + return_type const two = 2; + return sum / two; + } + + return_type sum; + }; + + template + static inline void apply(PointOfSegment const& p1, + PointOfSegment const& p2, + state& st) + { + typedef typename state::return_type return_type; + + // Below formulas are equivalent, however the two lower ones + // suffer less from accuracy loss for great values of coordinates. + // See: https://svn.boost.org/trac/boost/ticket/11928 + + // SUM += x2 * y1 - x1 * y2; + // state.sum += detail::determinant(p2, p1); + + // SUM += (x2 - x1) * (y2 + y1) + //state.sum += (return_type(get<0>(p2)) - return_type(get<0>(p1))) + // * (return_type(get<1>(p2)) + return_type(get<1>(p1))); + + // SUM += (x1 + x2) * (y1 - y2) + st.sum += (return_type(get<0>(p1)) + return_type(get<0>(p2))) + * (return_type(get<1>(p1)) - return_type(get<1>(p2))); + } + + template + static inline typename result_type::type + result(state& st) + { + return st.area(); + } + +}; + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + template <> + struct default_strategy + { + typedef strategy::area::cartesian<> type; + }; + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::area + + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_AREA_HPP diff --git a/include/boost/geometry/strategy/cartesian/envelope.hpp b/include/boost/geometry/strategy/cartesian/envelope.hpp new file mode 100644 index 0000000000..f779073425 --- /dev/null +++ b/include/boost/geometry/strategy/cartesian/envelope.hpp @@ -0,0 +1,120 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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. + +// 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_STRATEGY_CARTESIAN_ENVELOPE_HPP +#define BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_HPP + +#include +#include + +#include + +#include +#include +#include +#include + +namespace boost { namespace geometry +{ + +namespace strategy { namespace envelope +{ + +template +class cartesian +{ +public: + typedef cartesian_tag cs_tag; + + // Linestring, Ring, Polygon + + template + static inline typename boost::range_iterator::type begin(Range const& range) + { + return boost::begin(range); + } + + template + static inline typename boost::range_iterator::type end(Range const& range) + { + return boost::end(range); + } + + // MultiLinestring, MultiPolygon + + template + struct multi_state + { + multi_state() + : m_initialized(false) + {} + + void apply(Box const& single_box) + { + if (! m_initialized) + { + m_box = single_box; + m_initialized = true; + } + else + { + strategy::expand::cartesian_box::apply(m_box, single_box); + } + } + + void result(Box & box) + { + if (m_initialized) + { + box = m_box; + } + else + { + geometry::detail::envelope::initialize::value>::apply(box); + } + } + + private: + bool m_initialized; + Box m_box; + }; +}; + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::cartesian type; +}; + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + +}} //namepsace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_HPP diff --git a/include/boost/geometry/strategy/cartesian/envelope_box.hpp b/include/boost/geometry/strategy/cartesian/envelope_box.hpp new file mode 100644 index 0000000000..c4e808dd30 --- /dev/null +++ b/include/boost/geometry/strategy/cartesian/envelope_box.hpp @@ -0,0 +1,123 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 + +// 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_STRATEGY_CARTESIAN_ENVELOPE_BOX_HPP +#define BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_BOX_HPP + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace envelope +{ + + +template +< + std::size_t Index, + std::size_t Dimension, + std::size_t DimensionCount +> +struct envelope_indexed_box +{ + template + static inline void apply(BoxIn const& box_in, BoxOut& mbr) + { + detail::indexed_point_view box_in_corner(box_in); + detail::indexed_point_view mbr_corner(mbr); + + detail::conversion::point_to_point + < + detail::indexed_point_view, + detail::indexed_point_view, + Dimension, + DimensionCount + >::apply(box_in_corner, mbr_corner); + } +}; + + +}} // namespace detail::envelope +#endif // DOXYGEN_NO_DETAIL + + +namespace strategy { namespace envelope +{ + + +struct cartesian_box +{ + typedef cartesian_tag cs_tag; + + template + static inline void apply(BoxIn const& box_in, BoxOut& mbr) + { + geometry::detail::envelope::envelope_indexed_box + < + min_corner, 0, dimension::value + >::apply(box_in, mbr); + + geometry::detail::envelope::envelope_indexed_box + < + max_corner, 0, dimension::value + >::apply(box_in, mbr); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::cartesian_box type; +}; + +} + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_BOX_HPP diff --git a/include/boost/geometry/strategy/cartesian/envelope_multipoint.hpp b/include/boost/geometry/strategy/cartesian/envelope_multipoint.hpp new file mode 100644 index 0000000000..aaf914943c --- /dev/null +++ b/include/boost/geometry/strategy/cartesian/envelope_multipoint.hpp @@ -0,0 +1,83 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2018-2020, 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_STRATEGY_CARTESIAN_ENVELOPE_MULTIPOINT_HPP +#define BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_MULTIPOINT_HPP + +#include +#include + +#include + +#include + +#include +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace envelope +{ + +class cartesian_multipoint +{ +public: + template + static inline void apply(MultiPoint const& multipoint, Box& mbr) + { + apply(boost::begin(multipoint), boost::end(multipoint), mbr); + } + +private: + template + static inline void apply(Iterator it, + Iterator last, + Box& mbr) + { + geometry::detail::envelope::initialize::value>::apply(mbr); + + if (it != last) + { + strategy::envelope::cartesian_point::apply(*it, mbr); + + for (++it; it != last; ++it) + { + strategy::expand::cartesian_point::apply(mbr, *it); + } + } + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::cartesian_multipoint type; +}; + + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_MULTIPOINT_HPP diff --git a/include/boost/geometry/strategy/cartesian/envelope_point.hpp b/include/boost/geometry/strategy/cartesian/envelope_point.hpp new file mode 100644 index 0000000000..144dc9a185 --- /dev/null +++ b/include/boost/geometry/strategy/cartesian/envelope_point.hpp @@ -0,0 +1,111 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015, 2016, 2017, 2018. +// Modifications copyright (c) 2015-2018, 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 + +// 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_STRATEGY_CARTESIAN_ENVELOPE_POINT_HPP +#define BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_POINT_HPP + +#include + +#include +#include +#include +#include +#include + +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace envelope +{ + +template +struct envelope_one_point +{ + template + static inline void apply(Point const& point, Box& mbr) + { + detail::indexed_point_view box_corner(mbr); + detail::conversion::point_to_point + < + Point, + detail::indexed_point_view, + Dimension, + DimensionCount + >::apply(point, box_corner); + } + + template + static inline void apply(Point const& point, Box& mbr) + { + apply(point, mbr); + apply(point, mbr); + } +}; + + +}} // namespace detail::envelope +#endif // DOXYGEN_NO_DETAIL + + +namespace strategy { namespace envelope +{ + +struct cartesian_point +{ + template + static inline void apply(Point const& point, Box& mbr) + { + geometry::detail::envelope::envelope_one_point + < + 0, dimension::value + >::apply(point, mbr); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::cartesian_point type; +}; + + +} + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_POINT_HPP diff --git a/include/boost/geometry/strategy/cartesian/envelope_segment.hpp b/include/boost/geometry/strategy/cartesian/envelope_segment.hpp new file mode 100644 index 0000000000..08fbc09217 --- /dev/null +++ b/include/boost/geometry/strategy/cartesian/envelope_segment.hpp @@ -0,0 +1,93 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2017-2018 Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle +// 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) + +#ifndef BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_SEGMENT_HPP +#define BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_SEGMENT_HPP + +#include + +#include +#include + +#include +#include +#include + +namespace boost { namespace geometry { namespace strategy { namespace envelope +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +template +struct envelope_one_segment +{ + template + static inline void apply(Point const& p1, + Point const& p2, + Box& mbr) + { + geometry::detail::envelope::envelope_one_point + < + Dimension, DimensionCount + >::apply(p1, mbr); + + strategy::expand::detail::point_loop + < + Dimension, DimensionCount + >::apply(mbr, p2); + } +}; + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +template +< + typename CalculationType = void +> +class cartesian_segment +{ +public: + template + static inline void apply(Point const& point1, Point const& point2, Box& box) + { + strategy::envelope::detail::envelope_one_segment + < + 0, + dimension::value + >::apply(point1, point2, box); + } + +}; + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::cartesian_segment type; +}; + +} + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + +}} //namepsace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_SEGMENT_HPP diff --git a/include/boost/geometry/strategy/cartesian/expand_box.hpp b/include/boost/geometry/strategy/cartesian/expand_box.hpp new file mode 100644 index 0000000000..271752dd37 --- /dev/null +++ b/include/boost/geometry/strategy/cartesian/expand_box.hpp @@ -0,0 +1,69 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. + +// This file was modified by Oracle on 2015, 2016, 2017. +// Modifications copyright (c) 2015-2017, 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 + +// 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_STRATEGY_CARTESIAN_EXPAND_BOX_HPP +#define BOOST_GEOMETRY_STRATEGY_CARTESIAN_EXPAND_BOX_HPP + +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace expand +{ + +struct cartesian_box +{ + template + static void apply(BoxOut & box_out, BoxIn const& box_in) + { + geometry::detail::expand::expand_indexed + < + 0, dimension::value + >::apply(box_out, box_in); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef cartesian_box type; +}; + + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::expand + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_EXPAND_BOX_HPP diff --git a/include/boost/geometry/strategy/cartesian/expand_point.hpp b/include/boost/geometry/strategy/cartesian/expand_point.hpp new file mode 100644 index 0000000000..96627647a8 --- /dev/null +++ b/include/boost/geometry/strategy/cartesian/expand_point.hpp @@ -0,0 +1,125 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. + +// This file was modified by Oracle on 2015-2018. +// Modifications copyright (c) 2015-2018, 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. + +// 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_STRATEGY_CARTESIAN_EXPAND_POINT_HPP +#define BOOST_GEOMETRY_STRATEGY_CARTESIAN_EXPAND_POINT_HPP + +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include + +namespace boost { namespace geometry +{ + +namespace strategy { namespace expand +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +template +struct point_loop +{ + template + static inline void apply(Box& box, Point const& source) + { + typedef typename select_coordinate_type + < + Point, Box + >::type coordinate_type; + + std::less less; + std::greater greater; + + coordinate_type const coord = get(source); + + if (less(coord, get(box))) + { + set(box, coord); + } + + if (greater(coord, get(box))) + { + set(box, coord); + } + + point_loop::apply(box, source); + } +}; + + +template +struct point_loop +{ + template + static inline void apply(Box&, Point const&) {} +}; + + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +struct cartesian_point +{ + template + static void apply(Box & box, Point const& point) + { + expand::detail::point_loop + < + 0, dimension::value + >::apply(box, point); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef cartesian_point type; +}; + + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::expand + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_EXPAND_POINT_HPP diff --git a/include/boost/geometry/strategy/cartesian/expand_segment.hpp b/include/boost/geometry/strategy/cartesian/expand_segment.hpp new file mode 100644 index 0000000000..bed4d7056a --- /dev/null +++ b/include/boost/geometry/strategy/cartesian/expand_segment.hpp @@ -0,0 +1,71 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. + +// This file was modified by Oracle on 2015, 2016, 2017, 2018. +// Modifications copyright (c) 2015-2018, 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 + +// 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_STRATEGY_CARTESIAN_EXPAND_SEGMENT_HPP +#define BOOST_GEOMETRY_STRATEGY_CARTESIAN_EXPAND_SEGMENT_HPP + + +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace expand +{ + +class cartesian_segment +{ +public: + template + static void apply(Box & box, Segment const& segment) + { + geometry::detail::expand::expand_indexed + < + 0, dimension::value + >::apply(box, segment); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef cartesian_segment type; +}; + + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::expand + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_EXPAND_SEGMENT_HPP diff --git a/include/boost/geometry/strategy/envelope.hpp b/include/boost/geometry/strategy/envelope.hpp new file mode 100644 index 0000000000..1b2072da5f --- /dev/null +++ b/include/boost/geometry/strategy/envelope.hpp @@ -0,0 +1,46 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2016-2020 Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle +// 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) + +#ifndef BOOST_GEOMETRY_STRATEGY_ENVELOPE_HPP +#define BOOST_GEOMETRY_STRATEGY_ENVELOPE_HPP + +#include + +namespace boost { namespace geometry +{ + + +namespace strategy { namespace envelope { namespace services +{ + +/*! +\brief Traits class binding a default envelope strategy to a coordinate system +\ingroup util +\tparam Tag tag of geometry +\tparam CSTag tag of coordinate system +\tparam CalculationType \tparam_calculation +*/ +template +struct default_strategy +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_TYPE + , (types) + ); +}; + +}}} // namespace strategy::envelope::services + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_ENVELOPE_HPP + diff --git a/include/boost/geometry/strategy/expand.hpp b/include/boost/geometry/strategy/expand.hpp new file mode 100644 index 0000000000..7c7a824c58 --- /dev/null +++ b/include/boost/geometry/strategy/expand.hpp @@ -0,0 +1,45 @@ +// Boost.Geometry + +// Copyright (c) 2018-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, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_STRATEGY_EXPAND_HPP +#define BOOST_GEOMETRY_STRATEGY_EXPAND_HPP + +#include + +namespace boost { namespace geometry +{ + + +namespace strategy { namespace expand { namespace services +{ + +/*! +\brief Traits class binding a default envelope strategy to a coordinate system +\ingroup util +\tparam Tag tag of geometry +\tparam CSTag tag of coordinate system +\tparam CalculationType \tparam_calculation +*/ +template +struct default_strategy +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_TYPE + , (types) + ); +}; + +}}} // namespace strategy::expand::services + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_EXPAND_HPP + diff --git a/include/boost/geometry/strategy/geographic/area.hpp b/include/boost/geometry/strategy/geographic/area.hpp new file mode 100644 index 0000000000..9fdbcd4dd6 --- /dev/null +++ b/include/boost/geometry/strategy/geographic/area.hpp @@ -0,0 +1,237 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. + +// Copyright (c) 2016-2020 Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle +// 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) + +#ifndef BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_AREA_HPP +#define BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_AREA_HPP + + +#include + +#include +#include +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace area +{ + +/*! +\brief Geographic area calculation +\ingroup strategies +\details Geographic area calculation by trapezoidal rule plus integral + approximation that gives the ellipsoidal correction +\tparam FormulaPolicy Formula used to calculate azimuths +\tparam SeriesOrder The order of approximation of the geodesic integral +\tparam Spheroid The spheroid model +\tparam CalculationType \tparam_calculation +\author See +- Danielsen JS, The area under the geodesic. Surv Rev 30(232): 61–66, 1989 +- Charles F.F Karney, Algorithms for geodesics, 2011 https://arxiv.org/pdf/1109.4448.pdf + +\qbk{ +[heading See also] +\* [link geometry.reference.algorithms.area.area_2_with_strategy area (with strategy)] +\* [link geometry.reference.srs.srs_spheroid srs::spheroid] +} +*/ +template +< + typename FormulaPolicy = strategy::andoyer, + std::size_t SeriesOrder = strategy::default_order::value, + typename Spheroid = srs::spheroid, + typename CalculationType = void +> +class geographic +{ + // Switch between two kinds of approximation(series in eps and n v.s.series in k ^ 2 and e'^2) + static const bool ExpandEpsN = true; + // LongSegment Enables special handling of long segments + static const bool LongSegment = false; + + //Select default types in case they are not set + +public: + template + struct result_type + : strategy::area::detail::result_type + < + Geometry, + CalculationType + > + {}; + +protected : + struct spheroid_constants + { + typedef typename boost::mpl::if_c + < + boost::is_void::value, + typename geometry::radius_type::type, + CalculationType + >::type calc_t; + + Spheroid m_spheroid; + calc_t const m_a2; // squared equatorial radius + calc_t const m_e2; // squared eccentricity + calc_t const m_ep2; // squared second eccentricity + calc_t const m_ep; // second eccentricity + calc_t const m_c2; // squared authalic radius + + inline spheroid_constants(Spheroid const& spheroid) + : m_spheroid(spheroid) + , m_a2(math::sqr(get_radius<0>(spheroid))) + , m_e2(formula::eccentricity_sqr(spheroid)) + , m_ep2(m_e2 / (calc_t(1.0) - m_e2)) + , m_ep(math::sqrt(m_ep2)) + , m_c2(formula_dispatch::authalic_radius_sqr + < + calc_t, Spheroid, srs_spheroid_tag + >::apply(m_a2, m_e2)) + {} + }; + +public: + template + class state + { + friend class geographic; + + typedef typename result_type::type return_type; + + public: + inline state() + : m_excess_sum(0) + , m_correction_sum(0) + , m_crosses_prime_meridian(0) + {} + + private: + inline return_type area(spheroid_constants const& spheroid_const) const + { + return_type result; + + return_type sum = spheroid_const.m_c2 * m_excess_sum + + spheroid_const.m_e2 * spheroid_const.m_a2 * m_correction_sum; + + // If encircles some pole + if (m_crosses_prime_meridian % 2 == 1) + { + std::size_t times_crosses_prime_meridian + = 1 + (m_crosses_prime_meridian / 2); + + result = return_type(2.0) + * geometry::math::pi() + * spheroid_const.m_c2 + * return_type(times_crosses_prime_meridian) + - geometry::math::abs(sum); + + if (geometry::math::sign(sum) == 1) + { + result = - result; + } + + } + else + { + result = sum; + } + + return result; + } + + return_type m_excess_sum; + return_type m_correction_sum; + + // Keep track if encircles some pole + std::size_t m_crosses_prime_meridian; + }; + +public : + explicit inline geographic(Spheroid const& spheroid = Spheroid()) + : m_spheroid_constants(spheroid) + {} + + template + inline void apply(PointOfSegment const& p1, + PointOfSegment const& p2, + state& st) const + { + if (! geometry::math::equals(get<0>(p1), get<0>(p2))) + { + typedef geometry::formula::area_formulas + < + typename result_type::type, + SeriesOrder, ExpandEpsN + > area_formulas; + + typename area_formulas::return_type_ellipsoidal result = + area_formulas::template ellipsoidal + (p1, p2, m_spheroid_constants); + + st.m_excess_sum += result.spherical_term; + st.m_correction_sum += result.ellipsoidal_term; + + // Keep track whenever a segment crosses the prime meridian + if (area_formulas::crosses_prime_meridian(p1, p2)) + { + st.m_crosses_prime_meridian++; + } + } + } + + template + inline typename result_type::type + result(state const& st) const + { + return st.area(m_spheroid_constants); + } + + Spheroid model() const + { + return m_spheroid_constants.m_spheroid; + } + +private: + spheroid_constants m_spheroid_constants; + +}; + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + + +template <> +struct default_strategy +{ + typedef strategy::area::geographic<> type; +}; + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +} + +}} // namespace strategy::area + + + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_AREA_HPP diff --git a/include/boost/geometry/strategy/geographic/envelope.hpp b/include/boost/geometry/strategy/geographic/envelope.hpp new file mode 100644 index 0000000000..fb61a4595b --- /dev/null +++ b/include/boost/geometry/strategy/geographic/envelope.hpp @@ -0,0 +1,94 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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. + +// 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_STRATEGY_GEOGRAPHIC_ENVELOPE_HPP +#define BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_HPP + +#include + +#include +#include +#include +#include + +namespace boost { namespace geometry +{ + +namespace strategy { namespace envelope +{ + + +template +< + typename FormulaPolicy = strategy::andoyer, + typename Spheroid = geometry::srs::spheroid, + typename CalculationType = void +> +class geographic + : public spherical +{ +public: + typedef geographic_tag cs_tag; + + typedef Spheroid model_type; + + inline geographic() + : m_spheroid() + {} + + explicit inline geographic(Spheroid const& spheroid) + : m_spheroid(spheroid) + {} + + Spheroid model() const + { + return m_spheroid; + } + +private: + Spheroid m_spheroid; +}; + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::geographic + < + strategy::andoyer, + geometry::srs::spheroid, + CalculationType + > type; +}; + +} + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + +}} //namepsace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_HPP diff --git a/include/boost/geometry/strategy/geographic/envelope_segment.hpp b/include/boost/geometry/strategy/geographic/envelope_segment.hpp new file mode 100644 index 0000000000..71abb4f601 --- /dev/null +++ b/include/boost/geometry/strategy/geographic/envelope_segment.hpp @@ -0,0 +1,122 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2017-2020 Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle +// 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) + +#ifndef BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP +#define BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP + + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace geometry +{ + +namespace strategy { namespace envelope +{ + +template +< + typename FormulaPolicy = strategy::andoyer, + typename Spheroid = geometry::srs::spheroid, + typename CalculationType = void +> +class geographic_segment +{ +public: + typedef Spheroid model_type; + + inline geographic_segment() + : m_spheroid() + {} + + explicit inline geographic_segment(Spheroid const& spheroid) + : m_spheroid(spheroid) + {} + + template + inline void apply(Point const& point1, Point const& point2, Box& box) const + { + Point p1_normalized, p2_normalized; + strategy::normalize::spherical_point::apply(point1, p1_normalized); + strategy::normalize::spherical_point::apply(point2, p2_normalized); + + geometry::strategy::azimuth::geographic + < + FormulaPolicy, + Spheroid, + CalculationType + > azimuth_geographic(m_spheroid); + + typedef typename geometry::detail::cs_angular_units + < + Point + >::type units_type; + + // first compute the envelope range for the first two coordinates + strategy::envelope::detail::envelope_segment_impl + < + geographic_tag + >::template apply(geometry::get<0>(p1_normalized), + geometry::get<1>(p1_normalized), + geometry::get<0>(p2_normalized), + geometry::get<1>(p2_normalized), + box, + azimuth_geographic); + + // now compute the envelope range for coordinates of + // dimension 2 and higher + strategy::envelope::detail::envelope_one_segment + < + 2, dimension::value + >::apply(point1, point2, box); + } + + Spheroid model() const + { + return m_spheroid; + } + +private: + Spheroid m_spheroid; +}; + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::geographic_segment + < + strategy::andoyer, + srs::spheroid, + CalculationType + > type; +}; + +} + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + +}} //namepsace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP diff --git a/include/boost/geometry/strategy/geographic/expand_segment.hpp b/include/boost/geometry/strategy/geographic/expand_segment.hpp new file mode 100644 index 0000000000..132f69eb0c --- /dev/null +++ b/include/boost/geometry/strategy/geographic/expand_segment.hpp @@ -0,0 +1,107 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. + +// This file was modified by Oracle on 2015, 2016, 2017, 2018. +// Modifications copyright (c) 2015-2018, 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 + +// 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_STRATEGY_GEOGRAPHIC_EXPAND_SEGMENT_HPP +#define BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_EXPAND_SEGMENT_HPP + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace expand +{ + +template +< + typename FormulaPolicy = strategy::andoyer, + typename Spheroid = geometry::srs::spheroid, + typename CalculationType = void +> +class geographic_segment +{ +public: + inline geographic_segment() + : m_envelope_strategy() + {} + + explicit inline geographic_segment(Spheroid const& spheroid) + : m_envelope_strategy(spheroid) + {} + + template + inline void apply(Box& box, Segment const& segment) const + { + detail::segment_on_spheroid::apply(box, segment, m_envelope_strategy); + } + + Spheroid model() const + { + return m_envelope_strategy.model(); + } + +private: + strategy::envelope::geographic_segment + < + FormulaPolicy, Spheroid, CalculationType + > m_envelope_strategy; +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef geographic_segment + < + strategy::andoyer, + geometry::srs::spheroid, + CalculationType + > type; +}; + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::expand + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_EXPAND_SEGMENT_HPP diff --git a/include/boost/geometry/strategy/spherical/area.hpp b/include/boost/geometry/strategy/spherical/area.hpp new file mode 100644 index 0000000000..5019899873 --- /dev/null +++ b/include/boost/geometry/strategy/spherical/area.hpp @@ -0,0 +1,202 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. + +// Copyright (c) 2016-2020 Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle +// 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) + +#ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_AREA_HPP +#define BOOST_GEOMETRY_STRATEGY_SPHERICAL_AREA_HPP + + +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace area +{ + + +/*! +\brief Spherical area calculation +\ingroup strategies +\details Calculates area on the surface of a sphere using the trapezoidal rule +\tparam RadiusTypeOrSphere \tparam_radius_or_sphere +\tparam CalculationType \tparam_calculation + +\qbk{ +[heading See also] +[link geometry.reference.algorithms.area.area_2_with_strategy area (with strategy)] +} +*/ +template +< + typename RadiusTypeOrSphere = double, + typename CalculationType = void +> +class spherical +{ + typedef typename strategy_detail::get_radius + < + RadiusTypeOrSphere + >::type radius_type; + + // Enables special handling of long segments + static const bool LongSegment = false; + +public: + template + struct result_type + : strategy::area::detail::result_type + < + Geometry, + CalculationType + > + {}; + + template + class state + { + friend class spherical; + + typedef typename result_type::type return_type; + + public: + inline state() + : m_sum(0) + , m_crosses_prime_meridian(0) + {} + + private: + template + inline return_type area(RadiusType const& r) const + { + return_type result; + return_type radius = r; + + // Encircles pole + if(m_crosses_prime_meridian % 2 == 1) + { + size_t times_crosses_prime_meridian + = 1 + (m_crosses_prime_meridian / 2); + + result = return_type(2) + * geometry::math::pi() + * times_crosses_prime_meridian + - geometry::math::abs(m_sum); + + if(geometry::math::sign(m_sum) == 1) + { + result = - result; + } + + } else { + result = m_sum; + } + + result *= radius * radius; + + return result; + } + + return_type m_sum; + + // Keep track if encircles some pole + size_t m_crosses_prime_meridian; + }; + +public : + + // For backward compatibility reasons the radius is set to 1 + inline spherical() + : m_radius(1.0) + {} + + template + explicit inline spherical(RadiusOrSphere const& radius_or_sphere) + : m_radius(strategy_detail::get_radius + < + RadiusOrSphere + >::apply(radius_or_sphere)) + {} + + template + inline void apply(PointOfSegment const& p1, + PointOfSegment const& p2, + state& st) const + { + if (! geometry::math::equals(get<0>(p1), get<0>(p2))) + { + typedef geometry::formula::area_formulas + < + typename result_type::type + > area_formulas; + + st.m_sum += area_formulas::template spherical(p1, p2); + + // Keep track whenever a segment crosses the prime meridian + if (area_formulas::crosses_prime_meridian(p1, p2)) + { + st.m_crosses_prime_meridian++; + } + } + } + + template + inline typename result_type::type + result(state const& st) const + { + return st.area(m_radius); + } + + srs::sphere model() const + { + return srs::sphere(m_radius); + } + +private : + radius_type m_radius; +}; + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + + +template <> +struct default_strategy +{ + typedef strategy::area::spherical<> type; +}; + +// Note: spherical polar coordinate system requires "get_as_radian_equatorial" +template <> +struct default_strategy +{ + typedef strategy::area::spherical<> type; +}; + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::area + + + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_AREA_HPP diff --git a/include/boost/geometry/strategy/spherical/envelope.hpp b/include/boost/geometry/strategy/spherical/envelope.hpp new file mode 100644 index 0000000000..fe225ba72d --- /dev/null +++ b/include/boost/geometry/strategy/spherical/envelope.hpp @@ -0,0 +1,113 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015, 2016, 2018, 2019. +// Modifications copyright (c) 2015-2019, 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. + +// 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_STRATEGY_SPHERICAL_ENVELOPE_HPP +#define BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_HPP + +#include +#include + +#include + +#include +#include +#include +#include + +namespace boost { namespace geometry +{ + +namespace strategy { namespace envelope +{ + +template +class spherical +{ +public: + typedef spherical_tag cs_tag; + + // Linestring, Ring, Polygon + + template + static inline geometry::segment_iterator begin(Range const& range) + { + return geometry::segments_begin(range); + } + + template + static inline geometry::segment_iterator end(Range const& range) + { + return geometry::segments_end(range); + } + + // MultiLinestring, MultiPolygon + + template + struct multi_state + { + void apply(Box const& single_box) + { + m_boxes.push_back(single_box); + } + + void result(Box & box) + { + if (!m_boxes.empty()) + { + geometry::detail::envelope::envelope_range_of_boxes::apply(m_boxes, box); + } + else + { + geometry::detail::envelope::initialize::value>::apply(box); + } + } + + private: + std::vector m_boxes; + }; +}; + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::spherical type; +}; + +template +struct default_strategy +{ + typedef strategy::envelope::spherical type; +}; + +} + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + +}} //namepsace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_HPP diff --git a/include/boost/geometry/strategy/spherical/envelope_box.hpp b/include/boost/geometry/strategy/spherical/envelope_box.hpp new file mode 100644 index 0000000000..66cddbbc1a --- /dev/null +++ b/include/boost/geometry/strategy/spherical/envelope_box.hpp @@ -0,0 +1,75 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 + +// 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_STRATEGY_SPHERICAL_ENVELOPE_BOX_HPP +#define BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_BOX_HPP + + +#include + +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace envelope +{ + + +struct spherical_box + : geometry::detail::envelope::envelope_box_on_spheroid +{ + typedef spherical_tag cs_tag; +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::spherical_box type; +}; + +template +struct default_strategy +{ + typedef strategy::envelope::spherical_box type; +}; + +template +struct default_strategy +{ + typedef strategy::envelope::spherical_box type; +}; + +} + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_BOX_HPP diff --git a/include/boost/geometry/strategy/spherical/envelope_multipoint.hpp b/include/boost/geometry/strategy/spherical/envelope_multipoint.hpp new file mode 100644 index 0000000000..fc2bd5409d --- /dev/null +++ b/include/boost/geometry/strategy/spherical/envelope_multipoint.hpp @@ -0,0 +1,377 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2015-2020, 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 + +// 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_STRATEGY_SPHERICAL_ENVELOPE_MULTIPOINT_HPP +#define BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_MULTIPOINT_HPP + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace envelope +{ + +class spherical_multipoint +{ +private: + template + struct coordinate_less + { + template + inline bool operator()(Point const& point1, Point const& point2) const + { + return math::smaller(geometry::get(point1), + geometry::get(point2)); + } + }; + + template + static inline void analyze_point_coordinates(MultiPoint const& multipoint, + bool& has_south_pole, + bool& has_north_pole, + OutputIterator oit) + { + typedef typename boost::range_value::type point_type; + typedef typename boost::range_iterator + < + MultiPoint const + >::type iterator_type; + + // analyze point coordinates: + // (1) normalize point coordinates + // (2) check if any point is the north or the south pole + // (3) put all non-pole points in a container + // + // notice that at this point in the algorithm, we have at + // least two points on the spheroid + has_south_pole = false; + has_north_pole = false; + + for (iterator_type it = boost::begin(multipoint); + it != boost::end(multipoint); + ++it) + { + point_type point; + normalize::spherical_point::apply(*it, point); + + if (math::equals(geometry::get<1>(point), + Constants::min_latitude())) + { + has_south_pole = true; + } + else if (math::equals(geometry::get<1>(point), + Constants::max_latitude())) + { + has_north_pole = true; + } + else + { + *oit++ = point; + } + } + } + + template + static inline Value maximum_gap(SortedRange const& sorted_range, + Value& max_gap_left, + Value& max_gap_right) + { + typedef typename boost::range_iterator + < + SortedRange const + >::type iterator_type; + + iterator_type it1 = boost::begin(sorted_range), it2 = it1; + ++it2; + max_gap_left = geometry::get<0>(*it1); + max_gap_right = geometry::get<0>(*it2); + + Value max_gap = max_gap_right - max_gap_left; + for (++it1, ++it2; it2 != boost::end(sorted_range); ++it1, ++it2) + { + Value gap = geometry::get<0>(*it2) - geometry::get<0>(*it1); + if (math::larger(gap, max_gap)) + { + max_gap_left = geometry::get<0>(*it1); + max_gap_right = geometry::get<0>(*it2); + max_gap = gap; + } + } + + return max_gap; + } + + template + < + typename Constants, + typename PointRange, + typename LongitudeLess, + typename CoordinateType + > + static inline void get_min_max_longitudes(PointRange& range, + LongitudeLess const& lon_less, + CoordinateType& lon_min, + CoordinateType& lon_max) + { + typedef typename boost::range_iterator + < + PointRange const + >::type iterator_type; + + // compute min and max longitude values + std::pair min_max_longitudes + = boost::minmax_element(boost::begin(range), + boost::end(range), + lon_less); + + lon_min = geometry::get<0>(*min_max_longitudes.first); + lon_max = geometry::get<0>(*min_max_longitudes.second); + + // if the longitude span is "large" compute the true maximum gap + if (math::larger(lon_max - lon_min, Constants::half_period())) + { + std::sort(boost::begin(range), boost::end(range), lon_less); + + CoordinateType max_gap_left = 0, max_gap_right = 0; + CoordinateType max_gap + = maximum_gap(range, max_gap_left, max_gap_right); + + CoordinateType complement_gap + = Constants::period() + lon_min - lon_max; + + if (math::larger(max_gap, complement_gap)) + { + lon_min = max_gap_right; + lon_max = max_gap_left + Constants::period(); + } + } + } + + template + < + typename Constants, + typename Iterator, + typename LatitudeLess, + typename CoordinateType + > + static inline void get_min_max_latitudes(Iterator const first, + Iterator const last, + LatitudeLess const& lat_less, + bool has_south_pole, + bool has_north_pole, + CoordinateType& lat_min, + CoordinateType& lat_max) + { + if (has_south_pole && has_north_pole) + { + lat_min = Constants::min_latitude(); + lat_max = Constants::max_latitude(); + } + else if (has_south_pole) + { + lat_min = Constants::min_latitude(); + lat_max + = geometry::get<1>(*std::max_element(first, last, lat_less)); + } + else if (has_north_pole) + { + lat_min + = geometry::get<1>(*std::min_element(first, last, lat_less)); + lat_max = Constants::max_latitude(); + } + else + { + std::pair min_max_latitudes + = boost::minmax_element(first, last, lat_less); + + lat_min = geometry::get<1>(*min_max_latitudes.first); + lat_max = geometry::get<1>(*min_max_latitudes.second); + } + } + +public: + template + static inline void apply(MultiPoint const& multipoint, Box& mbr) + { + typedef typename point_type::type point_type; + typedef typename coordinate_type::type coordinate_type; + typedef typename boost::range_iterator + < + MultiPoint const + >::type iterator_type; + + typedef math::detail::constants_on_spheroid + < + coordinate_type, + typename geometry::detail::cs_angular_units::type + > constants; + + if (boost::empty(multipoint)) + { + geometry::detail::envelope::initialize::value>::apply(mbr); + return; + } + + geometry::detail::envelope::initialize::apply(mbr); + + if (boost::size(multipoint) == 1) + { + spherical_point::apply(range::front(multipoint), mbr); + return; + } + + // analyze the points and put the non-pole ones in the + // points vector + std::vector points; + bool has_north_pole = false, has_south_pole = false; + + analyze_point_coordinates(multipoint, + has_south_pole, has_north_pole, + std::back_inserter(points)); + + coordinate_type lon_min, lat_min, lon_max, lat_max; + if (points.size() == 1) + { + // we have one non-pole point and at least one pole point + lon_min = geometry::get<0>(range::front(points)); + lon_max = geometry::get<0>(range::front(points)); + lat_min = has_south_pole + ? constants::min_latitude() + : constants::max_latitude(); + lat_max = has_north_pole + ? constants::max_latitude() + : constants::min_latitude(); + } + else if (points.empty()) + { + // all points are pole points + BOOST_GEOMETRY_ASSERT(has_south_pole || has_north_pole); + lon_min = coordinate_type(0); + lon_max = coordinate_type(0); + lat_min = has_south_pole + ? constants::min_latitude() + : constants::max_latitude(); + lat_max = (has_north_pole) + ? constants::max_latitude() + : constants::min_latitude(); + } + else + { + get_min_max_longitudes(points, + coordinate_less<0>(), + lon_min, + lon_max); + + get_min_max_latitudes(points.begin(), + points.end(), + coordinate_less<1>(), + has_south_pole, + has_north_pole, + lat_min, + lat_max); + } + + typedef typename helper_geometry + < + Box, + coordinate_type, + typename geometry::detail::cs_angular_units::type + >::type helper_box_type; + + helper_box_type helper_mbr; + + geometry::set(helper_mbr, lon_min); + geometry::set(helper_mbr, lat_min); + geometry::set(helper_mbr, lon_max); + geometry::set(helper_mbr, lat_max); + + // now transform to output MBR (per index) + geometry::detail::envelope::envelope_indexed_box_on_spheroid::apply(helper_mbr, mbr); + geometry::detail::envelope::envelope_indexed_box_on_spheroid::apply(helper_mbr, mbr); + + // compute envelope for higher coordinates + iterator_type it = boost::begin(multipoint); + geometry::detail::envelope::envelope_one_point<2, dimension::value>::apply(*it, mbr); + + for (++it; it != boost::end(multipoint); ++it) + { + strategy::expand::detail::point_loop + < + 2, dimension::value + >::apply(mbr, *it); + } + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::spherical_multipoint type; +}; + +template +struct default_strategy +{ + typedef strategy::envelope::spherical_multipoint type; +}; + +template +struct default_strategy +{ + typedef strategy::envelope::spherical_multipoint type; +}; + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_MULTIPOINT_HPP diff --git a/include/boost/geometry/strategy/spherical/envelope_point.hpp b/include/boost/geometry/strategy/spherical/envelope_point.hpp new file mode 100644 index 0000000000..d11b38b217 --- /dev/null +++ b/include/boost/geometry/strategy/spherical/envelope_point.hpp @@ -0,0 +1,111 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015, 2016, 2017, 2018. +// Modifications copyright (c) 2015-2018, 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 + +// 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_STRATEGY_SPHERICAL_ENVELOPE_POINT_HPP +#define BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_POINT_HPP + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace envelope +{ + +struct spherical_point +{ + template + static inline void apply(Point const& point, Box& mbr) + { + Point normalized_point; + strategy::normalize::spherical_point::apply(point, normalized_point); + + typename point_type::type box_point; + + // transform units of input point to units of a box point + geometry::detail::envelope::transform_units(normalized_point, box_point); + + geometry::set(mbr, geometry::get<0>(box_point)); + geometry::set(mbr, geometry::get<1>(box_point)); + + geometry::set(mbr, geometry::get<0>(box_point)); + geometry::set(mbr, geometry::get<1>(box_point)); + + typedef geometry::detail::envelope::envelope_one_point + < + 2, dimension::value + > per_corner; + per_corner::template apply(normalized_point, mbr); + per_corner::template apply(normalized_point, mbr); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::spherical_point type; +}; + +template +struct default_strategy +{ + typedef strategy::envelope::spherical_point type; +}; + +template +struct default_strategy +{ + typedef strategy::envelope::spherical_point type; +}; + + +} + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_POINT_HPP diff --git a/include/boost/geometry/strategy/spherical/envelope_segment.hpp b/include/boost/geometry/strategy/spherical/envelope_segment.hpp new file mode 100644 index 0000000000..2ec099e1fc --- /dev/null +++ b/include/boost/geometry/strategy/spherical/envelope_segment.hpp @@ -0,0 +1,439 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2017-2020 Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle +// 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) + +#ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_SEGMENT_HPP +#define BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_SEGMENT_HPP + + +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +namespace boost { namespace geometry { namespace strategy { namespace envelope +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +template +struct envelope_segment_call_vertex_latitude +{ + template + static inline CalculationType apply(T1 const& lat1, + T2 const& alp1, + Strategy const& ) + { + return geometry::formula::vertex_latitude + ::apply(lat1, alp1); + } +}; + +template +struct envelope_segment_call_vertex_latitude +{ + template + static inline CalculationType apply(T1 const& lat1, + T2 const& alp1, + Strategy const& strategy) + { + return geometry::formula::vertex_latitude + ::apply(lat1, alp1, strategy.model()); + } +}; + +template +struct envelope_segment_convert_polar +{ + template + static inline void pre(T & , T & ) {} + + template + static inline void post(T & , T & ) {} +}; + +template +struct envelope_segment_convert_polar +{ + template + static inline void pre(T & lat1, T & lat2) + { + lat1 = math::latitude_convert_ep(lat1); + lat2 = math::latitude_convert_ep(lat2); + } + + template + static inline void post(T & lat1, T & lat2) + { + lat1 = math::latitude_convert_ep(lat1); + lat2 = math::latitude_convert_ep(lat2); + std::swap(lat1, lat2); + } +}; + +template +class envelope_segment_impl +{ +private: + + // degrees or radians + template + static inline void swap(CalculationType& lon1, + CalculationType& lat1, + CalculationType& lon2, + CalculationType& lat2) + { + std::swap(lon1, lon2); + std::swap(lat1, lat2); + } + + // radians + template + static inline bool contains_pi_half(CalculationType const& a1, + CalculationType const& a2) + { + // azimuths a1 and a2 are assumed to be in radians + BOOST_GEOMETRY_ASSERT(! math::equals(a1, a2)); + + static CalculationType const pi_half = math::half_pi(); + + return (a1 < a2) + ? (a1 < pi_half && pi_half < a2) + : (a1 > pi_half && pi_half > a2); + } + + // radians or degrees + template + static inline bool crosses_antimeridian(CoordinateType const& lon1, + CoordinateType const& lon2) + { + typedef math::detail::constants_on_spheroid + < + CoordinateType, Units + > constants; + + return math::abs(lon1 - lon2) > constants::half_period(); // > pi + } + + // degrees or radians + template + static inline void compute_box_corners(CalculationType& lon1, + CalculationType& lat1, + CalculationType& lon2, + CalculationType& lat2, + CalculationType a1, + CalculationType a2, + Strategy const& strategy) + { + // coordinates are assumed to be in radians + BOOST_GEOMETRY_ASSERT(lon1 <= lon2); + boost::ignore_unused(lon1, lon2); + + CalculationType lat1_rad = math::as_radian(lat1); + CalculationType lat2_rad = math::as_radian(lat2); + + if (math::equals(a1, a2)) + { + // the segment must lie on the equator or is very short or is meridian + return; + } + + if (lat1 > lat2) + { + std::swap(lat1, lat2); + std::swap(lat1_rad, lat2_rad); + std::swap(a1, a2); + } + + if (contains_pi_half(a1, a2)) + { + CalculationType p_max = envelope_segment_call_vertex_latitude + ::apply(lat1_rad, a1, strategy); + + CalculationType const mid_lat = lat1 + lat2; + if (mid_lat < 0) + { + // update using min latitude + CalculationType const lat_min_rad = -p_max; + CalculationType const lat_min + = math::from_radian(lat_min_rad); + + if (lat1 > lat_min) + { + lat1 = lat_min; + } + } + else + { + // update using max latitude + CalculationType const lat_max_rad = p_max; + CalculationType const lat_max + = math::from_radian(lat_max_rad); + + if (lat2 < lat_max) + { + lat2 = lat_max; + } + } + } + } + + template + static inline void special_cases(CalculationType& lon1, + CalculationType& lat1, + CalculationType& lon2, + CalculationType& lat2) + { + typedef math::detail::constants_on_spheroid + < + CalculationType, Units + > constants; + + bool is_pole1 = math::equals(math::abs(lat1), constants::max_latitude()); + bool is_pole2 = math::equals(math::abs(lat2), constants::max_latitude()); + + if (is_pole1 && is_pole2) + { + // both points are poles; nothing more to do: + // longitudes are already normalized to 0 + // but just in case + lon1 = 0; + lon2 = 0; + } + else if (is_pole1 && !is_pole2) + { + // first point is a pole, second point is not: + // make the longitude of the first point the same as that + // of the second point + lon1 = lon2; + } + else if (!is_pole1 && is_pole2) + { + // second point is a pole, first point is not: + // make the longitude of the second point the same as that + // of the first point + lon2 = lon1; + } + + if (lon1 == lon2) + { + // segment lies on a meridian + if (lat1 > lat2) + { + std::swap(lat1, lat2); + } + return; + } + + BOOST_GEOMETRY_ASSERT(!is_pole1 && !is_pole2); + + if (lon1 > lon2) + { + swap(lon1, lat1, lon2, lat2); + } + + if (crosses_antimeridian(lon1, lon2)) + { + lon1 += constants::period(); + swap(lon1, lat1, lon2, lat2); + } + } + + template + < + typename Units, + typename CalculationType, + typename Box + > + static inline void create_box(CalculationType lon1, + CalculationType lat1, + CalculationType lon2, + CalculationType lat2, + Box& mbr) + { + typedef typename coordinate_type::type box_coordinate_type; + + typedef typename helper_geometry + < + Box, box_coordinate_type, Units + >::type helper_box_type; + + helper_box_type helper_mbr; + + geometry::set + < + min_corner, 0 + >(helper_mbr, boost::numeric_cast(lon1)); + + geometry::set + < + min_corner, 1 + >(helper_mbr, boost::numeric_cast(lat1)); + + geometry::set + < + max_corner, 0 + >(helper_mbr, boost::numeric_cast(lon2)); + + geometry::set + < + max_corner, 1 + >(helper_mbr, boost::numeric_cast(lat2)); + + geometry::detail::envelope::transform_units(helper_mbr, mbr); + } + + + template + static inline void apply(CalculationType& lon1, + CalculationType& lat1, + CalculationType& lon2, + CalculationType& lat2, + Strategy const& strategy) + { + special_cases(lon1, lat1, lon2, lat2); + + CalculationType lon1_rad = math::as_radian(lon1); + CalculationType lat1_rad = math::as_radian(lat1); + CalculationType lon2_rad = math::as_radian(lon2); + CalculationType lat2_rad = math::as_radian(lat2); + CalculationType alp1, alp2; + strategy.apply(lon1_rad, lat1_rad, lon2_rad, lat2_rad, alp1, alp2); + + compute_box_corners(lon1, lat1, lon2, lat2, alp1, alp2, strategy); + } + +public: + template + < + typename Units, + typename CalculationType, + typename Box, + typename Strategy + > + static inline void apply(CalculationType lon1, + CalculationType lat1, + CalculationType lon2, + CalculationType lat2, + Box& mbr, + Strategy const& strategy) + { + typedef envelope_segment_convert_polar::type> convert_polar; + + convert_polar::pre(lat1, lat2); + + apply(lon1, lat1, lon2, lat2, strategy); + + convert_polar::post(lat1, lat2); + + create_box(lon1, lat1, lon2, lat2, mbr); + } + +}; + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +template +< + typename CalculationType = void +> +class spherical_segment +{ +public: + template + static inline void apply(Point const& point1, Point const& point2, + Box& box) + { + Point p1_normalized, p2_normalized; + strategy::normalize::spherical_point::apply(point1, p1_normalized); + strategy::normalize::spherical_point::apply(point2, p2_normalized); + + geometry::strategy::azimuth::spherical azimuth_spherical; + + typedef typename geometry::detail::cs_angular_units::type units_type; + + // first compute the envelope range for the first two coordinates + strategy::envelope::detail::envelope_segment_impl + < + spherical_equatorial_tag + >::template apply(geometry::get<0>(p1_normalized), + geometry::get<1>(p1_normalized), + geometry::get<0>(p2_normalized), + geometry::get<1>(p2_normalized), + box, + azimuth_spherical); + + // now compute the envelope range for coordinates of + // dimension 2 and higher + strategy::envelope::detail::envelope_one_segment + < + 2, dimension::value + >::apply(point1, point2, box); + } +}; + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef strategy::envelope::spherical_segment type; +}; + + +template +struct default_strategy +{ + typedef strategy::envelope::spherical_segment type; +}; + +} + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + +}} //namepsace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_SEGMENT_HPP + diff --git a/include/boost/geometry/strategy/spherical/expand_box.hpp b/include/boost/geometry/strategy/spherical/expand_box.hpp new file mode 100644 index 0000000000..67564e15a7 --- /dev/null +++ b/include/boost/geometry/strategy/spherical/expand_box.hpp @@ -0,0 +1,175 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. + +// This file was modified by Oracle on 2015, 2016, 2017, 2018, 2019. +// Modifications copyright (c) 2015-2019, 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 + +// 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_STRATEGY_SPHERICAL_EXPAND_BOX_HPP +#define BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_BOX_HPP + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace envelope +{ + +template +< + std::size_t Index, + std::size_t DimensionCount +> +struct envelope_indexed_box_on_spheroid +{ + template + static inline void apply(BoxIn const& box_in, BoxOut& mbr) + { + // transform() does not work with boxes of dimension higher + // than 2; to account for such boxes we transform the min/max + // points of the boxes using the indexed_point_view + detail::indexed_point_view box_in_corner(box_in); + detail::indexed_point_view mbr_corner(mbr); + + // first transform the units + transform_units(box_in_corner, mbr_corner); + + // now transform the remaining coordinates + detail::conversion::point_to_point + < + detail::indexed_point_view, + detail::indexed_point_view, + 2, + DimensionCount + >::apply(box_in_corner, mbr_corner); + } +}; + +struct envelope_box_on_spheroid +{ + template + static inline void apply(BoxIn const& box_in, BoxOut& mbr) + { + // BoxIn can be non-mutable + typename helper_geometry::type box_in_normalized; + geometry::convert(box_in, box_in_normalized); + + if (! is_inverse_spheroidal_coordinates(box_in)) + { + strategy::normalize::spherical_box::apply(box_in, box_in_normalized); + } + + geometry::detail::envelope::envelope_indexed_box_on_spheroid + < + min_corner, dimension::value + >::apply(box_in_normalized, mbr); + + geometry::detail::envelope::envelope_indexed_box_on_spheroid + < + max_corner, dimension::value + >::apply(box_in_normalized, mbr); + } +}; + +}} // namespace detail::envelope +#endif // DOXYGEN_NO_DETAIL + + +namespace strategy { namespace expand +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +struct box_on_spheroid +{ + template + static inline void apply(BoxOut& box_out, BoxIn const& box_in) + { + // normalize both boxes and convert box-in to be of type of box-out + BoxOut mbrs[2]; + geometry::detail::envelope::envelope_box_on_spheroid::apply(box_in, mbrs[0]); + geometry::detail::envelope::envelope_box_on_spheroid::apply(box_out, mbrs[1]); + + // compute the envelope of the two boxes + geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box_out); + } +}; + + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +struct spherical_box + : detail::box_on_spheroid +{}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef spherical_box type; +}; + +template +struct default_strategy +{ + typedef spherical_box type; +}; + +template +struct default_strategy +{ + typedef spherical_box type; +}; + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::expand + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_BOX_HPP diff --git a/include/boost/geometry/strategy/spherical/expand_point.hpp b/include/boost/geometry/strategy/spherical/expand_point.hpp new file mode 100644 index 0000000000..42d053f591 --- /dev/null +++ b/include/boost/geometry/strategy/spherical/expand_point.hpp @@ -0,0 +1,233 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. + +// This file was modified by Oracle on 2015-2018. +// Modifications copyright (c) 2015-2018, 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. + +// 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_STRATEGY_SPHERICAL_EXPAND_POINT_HPP +#define BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_POINT_HPP + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace expand +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +// implementation for the spherical and geographic coordinate systems +template +struct point_loop_on_spheroid +{ + template + static inline void apply(Box& box, Point const& point) + { + typedef typename point_type::type box_point_type; + typedef typename coordinate_type::type box_coordinate_type; + typedef typename geometry::detail::cs_angular_units::type units_type; + + typedef math::detail::constants_on_spheroid + < + box_coordinate_type, + units_type + > constants; + + // normalize input point and input box + Point p_normalized; + strategy::normalize::spherical_point::apply(point, p_normalized); + + // transform input point to be of the same type as the box point + box_point_type box_point; + geometry::detail::envelope::transform_units(p_normalized, box_point); + + if (is_inverse_spheroidal_coordinates(box)) + { + geometry::set_from_radian(box, geometry::get_as_radian<0>(p_normalized)); + geometry::set_from_radian(box, geometry::get_as_radian<1>(p_normalized)); + geometry::set_from_radian(box, geometry::get_as_radian<0>(p_normalized)); + geometry::set_from_radian(box, geometry::get_as_radian<1>(p_normalized)); + + } else { + + strategy::normalize::spherical_box::apply(box, box); + + box_coordinate_type p_lon = geometry::get<0>(box_point); + box_coordinate_type p_lat = geometry::get<1>(box_point); + + typename coordinate_type::type + b_lon_min = geometry::get(box), + b_lat_min = geometry::get(box), + b_lon_max = geometry::get(box), + b_lat_max = geometry::get(box); + + if (math::is_latitude_pole(p_lat)) + { + // the point of expansion is the either the north or the + // south pole; the only important coordinate here is the + // pole's latitude, as the longitude can be anything; + // we, thus, take into account the point's latitude only and return + geometry::set(box, (std::min)(p_lat, b_lat_min)); + geometry::set(box, (std::max)(p_lat, b_lat_max)); + return; + } + + if (math::equals(b_lat_min, b_lat_max) + && math::is_latitude_pole(b_lat_min)) + { + // the box degenerates to either the north or the south pole; + // the only important coordinate here is the pole's latitude, + // as the longitude can be anything; + // we thus take into account the box's latitude only and return + geometry::set(box, p_lon); + geometry::set(box, (std::min)(p_lat, b_lat_min)); + geometry::set(box, p_lon); + geometry::set(box, (std::max)(p_lat, b_lat_max)); + return; + } + + // update latitudes + b_lat_min = (std::min)(b_lat_min, p_lat); + b_lat_max = (std::max)(b_lat_max, p_lat); + + // update longitudes + if (math::smaller(p_lon, b_lon_min)) + { + box_coordinate_type p_lon_shifted = p_lon + constants::period(); + + if (math::larger(p_lon_shifted, b_lon_max)) + { + // here we could check using: ! math::larger(.., ..) + if (math::smaller(b_lon_min - p_lon, p_lon_shifted - b_lon_max)) + { + b_lon_min = p_lon; + } + else + { + b_lon_max = p_lon_shifted; + } + } + } + else if (math::larger(p_lon, b_lon_max)) + { + // in this case, and since p_lon is normalized in the range + // (-180, 180], we must have that b_lon_max <= 180 + if (b_lon_min < 0 + && math::larger(p_lon - b_lon_max, + constants::period() - p_lon + b_lon_min)) + { + b_lon_min = p_lon; + b_lon_max += constants::period(); + } + else + { + b_lon_max = p_lon; + } + } + + geometry::set(box, b_lon_min); + geometry::set(box, b_lat_min); + geometry::set(box, b_lon_max); + geometry::set(box, b_lat_max); + } + + point_loop + < + 2, DimensionCount + >::apply(box, point); + } +}; + + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +struct spherical_point +{ + template + static void apply(Box & box, Point const& point) + { + expand::detail::point_loop_on_spheroid + < + dimension::value, + ! boost::is_same::type, spherical_polar_tag>::value + >::apply(box, point); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef spherical_point type; +}; + +template +struct default_strategy +{ + typedef spherical_point type; +}; + +template +struct default_strategy +{ + typedef spherical_point type; +}; + + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::expand + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_POINT_HPP diff --git a/include/boost/geometry/strategy/spherical/expand_segment.hpp b/include/boost/geometry/strategy/spherical/expand_segment.hpp new file mode 100644 index 0000000000..d97e1b2b03 --- /dev/null +++ b/include/boost/geometry/strategy/spherical/expand_segment.hpp @@ -0,0 +1,113 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. + +// This file was modified by Oracle on 2015-2020. +// Modifications copyright (c) 2015-2020, 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 + +// 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_STRATEGY_SPHERICAL_EXPAND_SEGMENT_HPP +#define BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_SEGMENT_HPP + +#include +#include + +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace expand +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +struct segment_on_spheroid +{ + template + static inline void apply(Box& box, Segment const& segment, Strategy const& strategy) + { + Box mbrs[2]; + + // compute the envelope of the segment + geometry::detail::envelope::envelope_segment::apply(segment, mbrs[0], strategy); + + // normalize the box + strategy::envelope::spherical_box::apply(box, mbrs[1]); + + // compute the envelope of the two boxes + geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box); + } +}; + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +template +< + typename CalculationType = void +> +class spherical_segment +{ +public: + template + static inline void apply(Box& box, Segment const& segment) + { + detail::segment_on_spheroid::apply(box, segment, + strategy::envelope::spherical_segment()); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template +struct default_strategy +{ + typedef spherical_segment type; +}; + +template +struct default_strategy +{ + typedef spherical_segment type; +}; + +} // namespace services + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::expand + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_SEGMENT_HPP diff --git a/test/algorithms/buffer/buffer_piece_border.cpp b/test/algorithms/buffer/buffer_piece_border.cpp index 47188865ef..362085ebd9 100644 --- a/test/algorithms/buffer/buffer_piece_border.cpp +++ b/test/algorithms/buffer/buffer_piece_border.cpp @@ -3,6 +3,10 @@ // Copyright (c) 2020 Barend Gehrels, Amsterdam, the Netherlands. +// This file was modified by Oracle on 2020. +// Modifications copyright (c) 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, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // htt//www.boost.org/LICENSE_1_0.txt) @@ -21,6 +25,9 @@ #include #include +// TEMP +#include + #if defined(TEST_WITH_SVG) #include #include diff --git a/test/algorithms/detail/calculate_point_order.cpp b/test/algorithms/detail/calculate_point_order.cpp index 45ae3380b5..401136313c 100644 --- a/test/algorithms/detail/calculate_point_order.cpp +++ b/test/algorithms/detail/calculate_point_order.cpp @@ -22,6 +22,11 @@ #include #include +//TEMP +#include +#include +#include + inline const char * order_str(bg::order_selector o) { diff --git a/test/algorithms/detail/sections/range_by_section.cpp b/test/algorithms/detail/sections/range_by_section.cpp index 1263ba5ed0..45258b6ef9 100644 --- a/test/algorithms/detail/sections/range_by_section.cpp +++ b/test/algorithms/detail/sections/range_by_section.cpp @@ -3,6 +3,10 @@ // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// This file was modified by Oracle on 2020. +// Modifications copyright (c) 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, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -22,6 +26,9 @@ #include #include +// TEMP +#include + template void test_sectionalize(std::string const /*caseid*/, Geometry const& geometry, std::size_t section_count) diff --git a/test/algorithms/detail/sections/sectionalize.cpp b/test/algorithms/detail/sections/sectionalize.cpp index dd4050bf0d..a86387a60f 100644 --- a/test/algorithms/detail/sections/sectionalize.cpp +++ b/test/algorithms/detail/sections/sectionalize.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 2020. +// Modifications copyright (c) 2020, 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. @@ -34,6 +38,10 @@ # include #endif +// TEMP +#include + + template void test_sectionalize_part() { diff --git a/test/algorithms/envelope_expand/envelope_on_spheroid.cpp b/test/algorithms/envelope_expand/envelope_on_spheroid.cpp index cbc5e536e7..047955ecdd 100644 --- a/test/algorithms/envelope_expand/envelope_on_spheroid.cpp +++ b/test/algorithms/envelope_expand/envelope_on_spheroid.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2015-2018, Oracle and/or its affiliates. +// Copyright (c) 2015-2020, 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 @@ -47,6 +47,10 @@ #include "test_envelope_expand_on_spheroid.hpp" +//TEMP +#include +#include + template struct test_envelope diff --git a/test/algorithms/envelope_expand/expand_on_spheroid.cpp b/test/algorithms/envelope_expand/expand_on_spheroid.cpp index b192cf7e73..16c3a24bd0 100644 --- a/test/algorithms/envelope_expand/expand_on_spheroid.cpp +++ b/test/algorithms/envelope_expand/expand_on_spheroid.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2015-2018, Oracle and/or its affiliates. +// Copyright (c) 2015-2020, 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 @@ -47,6 +47,12 @@ #include "test_envelope_expand_on_spheroid.hpp" +// TEMP +#include +#include +#include +#include + class test_expand_on_spheroid { diff --git a/test/algorithms/set_operations/difference/difference_tupled.cpp b/test/algorithms/set_operations/difference/difference_tupled.cpp index cf7afb1ccf..7b3d9e65d8 100644 --- a/test/algorithms/set_operations/difference/difference_tupled.cpp +++ b/test/algorithms/set_operations/difference/difference_tupled.cpp @@ -21,6 +21,12 @@ #include +// TEMP +#include +#include +#include + + typedef bg::model::point Pt; typedef bg::model::linestring Ls; typedef bg::model::polygon Po; diff --git a/test/algorithms/set_operations/intersection/intersection_tupled.cpp b/test/algorithms/set_operations/intersection/intersection_tupled.cpp index 43283dddf6..3501fcaf55 100644 --- a/test/algorithms/set_operations/intersection/intersection_tupled.cpp +++ b/test/algorithms/set_operations/intersection/intersection_tupled.cpp @@ -21,6 +21,12 @@ #include +// TEMP +#include +#include +#include + + typedef bg::model::point Pt; typedef bg::model::linestring Ls; typedef bg::model::polygon Po; diff --git a/test/algorithms/set_operations/sym_difference/sym_difference_tupled.cpp b/test/algorithms/set_operations/sym_difference/sym_difference_tupled.cpp index 14864e1d6b..0bfa98bcd4 100644 --- a/test/algorithms/set_operations/sym_difference/sym_difference_tupled.cpp +++ b/test/algorithms/set_operations/sym_difference/sym_difference_tupled.cpp @@ -21,6 +21,12 @@ #include +// TEST +#include +#include +#include + + typedef bg::model::point Pt; typedef bg::model::linestring Ls; typedef bg::model::polygon Po; diff --git a/test/algorithms/set_operations/union/union_tupled.cpp b/test/algorithms/set_operations/union/union_tupled.cpp index 5ca9741efc..494fe16778 100644 --- a/test/algorithms/set_operations/union/union_tupled.cpp +++ b/test/algorithms/set_operations/union/union_tupled.cpp @@ -21,6 +21,12 @@ #include +// TEMP +#include +#include +#include + + typedef bg::model::point Pt; typedef bg::model::linestring Ls; typedef bg::model::polygon Po; diff --git a/test/strategies/pythagoras_point_box.cpp b/test/strategies/pythagoras_point_box.cpp index 4121ce02df..42fb2db4d9 100644 --- a/test/strategies/pythagoras_point_box.cpp +++ b/test/strategies/pythagoras_point_box.cpp @@ -5,10 +5,11 @@ // Copyright (c) 2008-2014 Bruno Lalande, Paris, France. // Copyright (c) 2009-2014 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014, Oracle and/or its affiliates. +// This file was modified by Oracle on 2014-2020. +// Modifications copyright (c) 2014-2020, 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 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -50,6 +51,11 @@ # include #endif +// TEST +#include +#include +#include + namespace bg = boost::geometry;