diff --git a/include/boost/geometry/algorithms/detail/as_range.hpp b/include/boost/geometry/algorithms/detail/as_range.hpp index 1d45c5e9d..fe2016be5 100644 --- a/include/boost/geometry/algorithms/detail/as_range.hpp +++ b/include/boost/geometry/algorithms/detail/as_range.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2020. -// Modifications copyright (c) 2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2020-2021. +// Modifications copyright (c) 2020-2021 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library @@ -19,7 +19,10 @@ #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_AS_RANGE_HPP +#include + #include +#include #include #include @@ -33,22 +36,30 @@ namespace dispatch { -template -struct as_range +template ::type> +struct as_range : not_implemented +{}; + +template +struct as_range { - static inline Range& get(Geometry& input) + static inline typename ring_return_type::type get(Geometry& geometry) { - return input; + return geometry; } }; +template +struct as_range + : as_range +{}; -template -struct as_range +template +struct as_range { - static inline Range& get(Geometry& input) + static inline typename ring_return_type::type get(Geometry& geometry) { - return exterior_ring(input); + return exterior_ring(geometry); } }; @@ -66,33 +77,10 @@ or the outer ring (polygon) \details Utility to handle polygon's outer ring as a range \ingroup utility */ -template -inline Range& as_range(Geometry& input) +template +inline typename ring_return_type::type as_range(Geometry& geometry) { - return dispatch::as_range - < - typename tag::type, - Geometry, - Range - >::get(input); -} - - -/*! -\brief Function getting either the range (ring, linestring) itself -or the outer ring (polygon), const version -\details Utility to handle polygon's outer ring as a range -\ingroup utility -*/ -template -inline Range const& as_range(Geometry const& input) -{ - return dispatch::as_range - < - typename tag::type, - Geometry const, - Range const - >::get(input); + return dispatch::as_range::get(geometry); } } diff --git a/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp b/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp index 3ee17564c..9584f6a2f 100644 --- a/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp +++ b/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp @@ -36,7 +36,6 @@ #include #include #include -#include namespace boost { namespace geometry @@ -68,7 +67,8 @@ inline void get_extremes(Geometry const& geometry, auto left_it = boost::begin(range); auto right_it = boost::begin(range); - for (auto it = ++boost::begin(range); it != boost::end(range); ++it) + auto it = boost::begin(range); + for (++it; it != boost::end(range); ++it) { if (less(*it, *left_it)) { diff --git a/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp b/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp index a07139db7..ce61c9980 100644 --- a/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp +++ b/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp @@ -27,10 +27,16 @@ #include #include -#include -#include +#include +#include +#include +#include + #include +#include #include +#include +#include #include @@ -39,13 +45,6 @@ #include -#include - -#include -#include -#include -#include - namespace boost { namespace geometry { @@ -58,7 +57,6 @@ namespace detail { namespace convex_hull template struct hull_insert { - // Member template function (to avoid inconvenient declaration // of output-iterator-type, from hull_to_geometry) template @@ -88,17 +86,18 @@ struct hull_to_geometry static inline void apply(Geometry const& geometry, OutputGeometry& out, Strategy const& strategy) { + // TODO: Why not handle multi-polygon here? + // TODO: detail::as_range() is only used in this place in the whole library + // it should probably be located here. + // NOTE: A variable is created here because this can be a proxy range + // and back_insert_iterator<> can store a pointer to it. + // Handle linestring, ring and polygon the same: + auto&& range = detail::as_range(out); hull_insert < geometry::point_order::value, geometry::closure::value - >::apply(geometry, - range::back_inserter( - // Handle linestring, ring and polygon the same: - detail::as_range - < - typename range_type::type - >(out)), strategy); + >::apply(geometry, range::back_inserter(range), strategy); } }; @@ -120,6 +119,7 @@ struct convex_hull : detail::convex_hull::hull_to_geometry {}; +// TODO: This is not correct in spherical and geographic CS template struct convex_hull { diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp index 45db3d252..239202c33 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp @@ -64,7 +64,6 @@ #include #include -#include #ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION @@ -218,12 +217,12 @@ class get_turns_in_sections { typedef typename closeable_view < - typename range_type::type const, + typename ring_type::type const, closure::value >::type cview_type1; typedef typename closeable_view < - typename range_type::type const, + typename ring_type::type const, closure::value >::type cview_type2; diff --git a/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp b/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp index 28823433a..f1c74bc4d 100644 --- a/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp +++ b/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp @@ -1218,7 +1218,7 @@ struct linear_areal typename sub_range_return_type::type range1 = sub_range(geometry1, turn.operations[op_id].seg_id); - typedef detail::normalized_view const range2_type; + typedef detail::normalized_view::type const> const range2_type; typedef typename boost::range_iterator::type range2_iterator; range2_type range2(sub_range(geometry2, turn.operations[other_op_id].seg_id)); diff --git a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp index 3ef02ca90..9c1c7c7cd 100644 --- a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013-2020. -// Modifications copyright (c) 2013-2020, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013-2021. +// Modifications copyright (c) 2013-2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library @@ -28,6 +28,7 @@ #include +#include #include #include diff --git a/include/boost/geometry/core/ring_type.hpp b/include/boost/geometry/core/ring_type.hpp index 726b14ca5..4aca0719c 100644 --- a/include/boost/geometry/core/ring_type.hpp +++ b/include/boost/geometry/core/ring_type.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-2020. -// Modifications copyright (c) 2015-2020, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2021. +// Modifications copyright (c) 2015-2021, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -139,6 +139,13 @@ struct ring_type {}; +template +struct ring_type +{ + typedef Linestring type; +}; + + template struct ring_type { diff --git a/include/boost/geometry/multi/views/detail/range_type.hpp b/include/boost/geometry/multi/views/detail/range_type.hpp deleted file mode 100644 index f8cb0e6e5..000000000 --- a/include/boost/geometry/multi/views/detail/range_type.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// 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. - -// 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_MULTI_VIEWS_DETAIL_RANGE_TYPE_HPP -#define BOOST_GEOMETRY_MULTI_VIEWS_DETAIL_RANGE_TYPE_HPP - - -#include - - -#endif // BOOST_GEOMETRY_MULTI_VIEWS_DETAIL_RANGE_TYPE_HPP diff --git a/include/boost/geometry/views/closeable_view.hpp b/include/boost/geometry/views/closeable_view.hpp index 6114bc0e2..f4ee71eb9 100644 --- a/include/boost/geometry/views/closeable_view.hpp +++ b/include/boost/geometry/views/closeable_view.hpp @@ -43,11 +43,11 @@ namespace detail template struct closing_view { - using iterator = closing_iterator; + using iterator = closing_iterator; using const_iterator = closing_iterator; // Keep this explicit, important for nested views/ranges - explicit inline closing_view(Range& r) + explicit inline closing_view(Range const& r) : m_begin(r) , m_end(r, true) {} @@ -55,12 +55,9 @@ struct closing_view inline const_iterator begin() const { return m_begin; } inline const_iterator end() const { return m_end; } - inline iterator begin() { return m_begin; } - inline iterator end() { return m_end; } - private: - iterator m_begin; - iterator m_end; + const_iterator m_begin; + const_iterator m_end; }; } diff --git a/include/boost/geometry/views/detail/normalized_view.hpp b/include/boost/geometry/views/detail/normalized_view.hpp index e0063ca4f..c4c4ae2ef 100644 --- a/include/boost/geometry/views/detail/normalized_view.hpp +++ b/include/boost/geometry/views/detail/normalized_view.hpp @@ -24,9 +24,8 @@ #include #include -#include -#include #include +#include #include #include @@ -40,41 +39,31 @@ namespace detail { template struct normalized_view { - using range_type = typename detail::range_type::type; - using range = util::transcribe_const_t; - using reversible_type = typename reversible_view < - range, + Geometry const, order_as_direction < geometry::point_order::value >::value >::type; - - using reversible = util::transcribe_const_t; using closeable_type = typename closeable_view < - reversible, + reversible_type const, geometry::closure::value >::type; - - using closeable = util::transcribe_const_t; - explicit inline normalized_view(range & r) - : m_closeable(reversible_type(r)) + explicit inline normalized_view(Geometry const& g) + : m_closeable(reversible_type(g)) {} - typedef typename boost::range_iterator::type iterator; - typedef typename boost::range_const_iterator::type const_iterator; + using iterator = typename boost::range_iterator::type; + using const_iterator = typename boost::range_iterator::type; inline const_iterator begin() const { return boost::begin(m_closeable); } inline const_iterator end() const { return boost::end(m_closeable); } - inline iterator begin() { return boost::begin(m_closeable); } - inline iterator end() { return boost::end(m_closeable); } - private: closeable_type m_closeable; }; diff --git a/include/boost/geometry/views/detail/range_type.hpp b/include/boost/geometry/views/detail/range_type.hpp deleted file mode 100644 index b87c0ea06..000000000 --- a/include/boost/geometry/views/detail/range_type.hpp +++ /dev/null @@ -1,132 +0,0 @@ -// 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. - -// 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_VIEWS_DETAIL_RANGE_TYPE_HPP -#define BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP - - -#include - -#include -#include -#include -#include - -#include - -namespace boost { namespace geometry -{ - - -#ifndef DOXYGEN_NO_DISPATCH -namespace dispatch -{ - - -template ::type> -struct range_type -{ - BOOST_GEOMETRY_STATIC_ASSERT_FALSE( - "Not or not yet implemented for this Geometry type.", - Geometry, Tag); -}; - - -template -struct range_type -{ - typedef Geometry type; -}; - - -template -struct range_type -{ - typedef Geometry type; -}; - - -template -struct range_type -{ - typedef typename ring_type::type type; -}; - - -template -struct range_type -{ - typedef box_view type; -}; - - -// multi-point acts itself as a range -template -struct range_type -{ - typedef Geometry type; -}; - - -template -struct range_type -{ - typedef typename boost::range_value::type type; -}; - - -template -struct range_type -{ - // Call its single-version - typedef typename dispatch::range_type - < - typename boost::range_value::type - >::type type; -}; - - -} // namespace dispatch -#endif // DOXYGEN_NO_DISPATCH - -// Will probably be replaced by the more generic "view_as", therefore in detail -namespace detail -{ - - -/*! -\brief Meta-function defining a type which is a boost-range. -\details -- For linestrings and rings, it defines the type itself. -- For polygons it defines the ring type. -- For multi-points, it defines the type itself -- For multi-polygons and multi-linestrings, it defines the single-version - (so in the end the linestring and ring-type-of-multi-polygon) -\ingroup iterators -*/ -template -struct range_type -{ - typedef typename dispatch::range_type - < - Geometry - >::type type; -}; - -} - -}} // namespace boost::geometry - - -#endif // BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP diff --git a/test/algorithms/convex_hull/convex_hull_multi.cpp b/test/algorithms/convex_hull/convex_hull_multi.cpp index a0b93a9bc..8945a5b40 100644 --- a/test/algorithms/convex_hull/convex_hull_multi.cpp +++ b/test/algorithms/convex_hull/convex_hull_multi.cpp @@ -5,9 +5,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, 2015. -// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. - +// This file was modified by Oracle on 2014-2021. +// Modifications copyright (c) 2014-2021 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library @@ -29,8 +28,6 @@ #include #include -#include - #include #include diff --git a/test/algorithms/detail/as_range.cpp b/test/algorithms/detail/as_range.cpp index dd6aabf28..f33cb49ce 100644 --- a/test/algorithms/detail/as_range.cpp +++ b/test/algorithms/detail/as_range.cpp @@ -5,6 +5,10 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -15,8 +19,6 @@ #include - -#include #include #include @@ -24,6 +26,7 @@ #include + template double sum(Range const& range) { @@ -40,17 +43,12 @@ template void test_geometry(std::string const& wkt, double expected_x, double expected_y) { G geometry; - - // Declare a range-type, compatible with boost::range, - // such that range_iterator etc could be called - typedef typename bg::detail::range_type::type range_type; - bg::read_wkt(wkt, geometry); - double s = sum<0>(bg::detail::as_range(geometry)); + double s = sum<0>(bg::detail::as_range(geometry)); BOOST_CHECK_CLOSE(s, expected_x, 0.001); - s = sum<1>(bg::detail::as_range(geometry)); + s = sum<1>(bg::detail::as_range(geometry)); BOOST_CHECK_CLOSE(s, expected_y, 0.001); } diff --git a/test/algorithms/detail/sections/range_by_section.cpp b/test/algorithms/detail/sections/range_by_section.cpp index b8e98f533..1069c4905 100644 --- a/test/algorithms/detail/sections/range_by_section.cpp +++ b/test/algorithms/detail/sections/range_by_section.cpp @@ -3,8 +3,8 @@ // 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. +// This file was modified by Oracle on 2020-2021. +// Modifications copyright (c) 2020-2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -46,7 +45,7 @@ void test_sectionalize(std::string const /*caseid*/, Geometry const& geometry, s typedef typename bg::closeable_view < - typename bg::detail::range_type::type const, + typename bg::ring_type::type const, bg::closure::value >::type cview_type; typedef typename bg::reversible_view