diff --git a/.github/workflows/minimal-clang.yml b/.github/workflows/minimal-clang.yml
index cceca7af6..b772f0b5b 100644
--- a/.github/workflows/minimal-clang.yml
+++ b/.github/workflows/minimal-clang.yml
@@ -92,8 +92,11 @@ jobs:
- name: Install
run: |
- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421
- sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
+ # Required for compilers not available in ubuntu latest
+ sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main"
+ sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe"
+ sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ bionic main"
+ sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ bionic universe"
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt -q -y update
sudo apt -q -y install clang-${{ matrix.version }} g++-multilib
diff --git a/.github/workflows/minimal-gcc.yml b/.github/workflows/minimal-gcc.yml
index 72e8288ab..f08521486 100644
--- a/.github/workflows/minimal-gcc.yml
+++ b/.github/workflows/minimal-gcc.yml
@@ -80,9 +80,11 @@ jobs:
- name: Install
run: |
- # gcc-4.8 is not available in Bionic anymore
+ # Required for compilers not available in ubuntu latest
sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main"
sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe"
+ sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ bionic main"
+ sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ bionic universe"
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt -q -y update
sudo apt -q -y install g++-${{ matrix.version }} g++-${{ matrix.version }}-multilib
diff --git a/README.md b/README.md
index 3470ac8c4..f8350de1a 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# 
-Boost.Geometry, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), defines concepts, primitives and algorithms for solving geometry problems.
+Boost.Geometry, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), defines concepts, primitives and algorithms for solving geometry problems. Boost.Geometry is a C++14 header-only library.
[](http://www.boost.org/LICENSE_1_0.txt)
[](http://boost.org/libs/geometry)
diff --git a/doc/doxy/doxygen_input/groups/groups.hpp b/doc/doxy/doxygen_input/groups/groups.hpp
index 1caf7cf63..d2659b561 100644
--- a/doc/doxy/doxygen_input/groups/groups.hpp
+++ b/doc/doxy/doxygen_input/groups/groups.hpp
@@ -2,8 +2,8 @@
//
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
-// This file was modified by Oracle on 2018.
-// Modifications copyright (c) 2018, Oracle and/or its affiliates.
+// This file was modified by Oracle on 2018-2021.
+// Modifications copyright (c) 2018-2021, 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
@@ -20,6 +20,7 @@
\defgroup area area: calculate area of a Geometry
\defgroup arithmetic arithmetic: arithmetic operations on points
\defgroup assign assign: assign values to geometries
+\defgroup azimuth azimuth: calculate azimuth of a segment defined by a pair of points
\defgroup buffer buffer: calculate buffer of a geometry
\defgroup centroid centroid: calculate centroid (center of gravity) of a geometry
\defgroup clear clear: clear geometries
diff --git a/doc/imports.qbk b/doc/imports.qbk
index a184f1513..a5fdacf08 100644
--- a/doc/imports.qbk
+++ b/doc/imports.qbk
@@ -5,7 +5,7 @@
Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Copyright (c) 2009-2012 Bruno Lalande, Paris, France.
- Copyright (c) 2018, Oracle and/or its affiliates.
+ Copyright (c) 2018-2021, 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,6 +24,8 @@
[import src/examples/algorithms/assign_3d_point.cpp]
[import src/examples/algorithms/assign_inverse.cpp]
[import src/examples/algorithms/assign_points.cpp]
+[import src/examples/algorithms/azimuth.cpp]
+[import src/examples/algorithms/azimuth_strategy.cpp]
[import src/examples/algorithms/buffer_with_strategies.cpp]
[import src/examples/algorithms/clear.cpp]
[import src/examples/algorithms/centroid.cpp]
diff --git a/doc/make_qbk.py b/doc/make_qbk.py
index 8a5cb6100..f4d7881e3 100755
--- a/doc/make_qbk.py
+++ b/doc/make_qbk.py
@@ -6,7 +6,7 @@
# Copyright (c) 2009-2012 Mateusz Loskot (mateusz@loskot.net), London, UK
# Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland
#
-# Copyright (c) 2018, Oracle and/or its affiliates.
+# Copyright (c) 2018-2021, 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
# Use, modification and distribution is subject to the Boost Software License,
@@ -96,7 +96,7 @@ def cs_to_quickbook(section):
call_doxygen()
algorithms = ["append", "assign", "make", "clear"
- , "area", "buffer", "centroid", "convert", "correct", "covered_by"
+ , "area", "azimuth", "buffer", "centroid", "convert", "correct", "covered_by"
, "convex_hull", "crosses", "densify", "difference"
, "discrete_frechet_distance", "discrete_hausdorff_distance", "disjoint"
, "distance", "envelope", "equals", "expand", "for_each", "is_empty"
diff --git a/doc/quickref.xml b/doc/quickref.xml
index bad6b5097..092a7f2ae 100644
--- a/doc/quickref.xml
+++ b/doc/quickref.xml
@@ -364,6 +364,10 @@
coordinate values)
+ Azimuth
+
+ azimuth
+
Buffer
buffer
diff --git a/doc/reference.qbk b/doc/reference.qbk
index aa0be56c0..a9270a5fb 100644
--- a/doc/reference.qbk
+++ b/doc/reference.qbk
@@ -6,8 +6,8 @@
Copyright (c) 2009-2017 Bruno Lalande, Paris, France.
Copyright (c) 2013-2017 Adam Wulkiewicz, Lodz, Poland.
- This file was modified by Oracle on 2014, 2017, 2018.
- Modifications copyright (c) 2014-2018, 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 Vissarion Fysikopoulos, on behalf of Oracle
Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
@@ -80,6 +80,10 @@
[include generated/append.qbk]
+[section:azimuth azimuth]
+[include generated/azimuth.qbk]
+[endsect]
+
[section:buffer buffer]
[include generated/buffer.qbk]
[endsect]
diff --git a/doc/reference/algorithms/azimuth.qbk b/doc/reference/algorithms/azimuth.qbk
new file mode 100644
index 000000000..5b2606661
--- /dev/null
+++ b/doc/reference/algorithms/azimuth.qbk
@@ -0,0 +1,22 @@
+[/============================================================================
+ Boost.Geometry
+
+ Copyright (c) 2021, Oracle and/or its affiliates.
+ Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+ Use, modification and distribution is subject to the Boost Software License,
+ Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================/]
+
+[def __this_function__ azimuth]
+
+[heading_conformance_no_ogc __this_function__]
+[note PostGIS contains an algorithm ST_Azimuth with the same functionality.
+ See the [@https://postgis.net/docs/ST_Azimuth.html PostGIS documentation].
+]
+
+[heading Behavior]
+The algorithm calculates the azimuth of a segment defined by a pair of points.
+
+[note The result is in radians.]
diff --git a/doc/src/examples/algorithms/azimuth.cpp b/doc/src/examples/algorithms/azimuth.cpp
new file mode 100644
index 000000000..0f799920a
--- /dev/null
+++ b/doc/src/examples/algorithms/azimuth.cpp
@@ -0,0 +1,42 @@
+// Boost.Geometry
+// QuickBook Example
+
+// Copyright (c) 2021, Oracle and/or its affiliates
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+//[azimuth
+//` Shows how to calculate azimuth
+
+#include
+
+#include
+#include
+
+int main()
+{
+ typedef boost::geometry::model::d2::point_xy point_type;
+
+ point_type p1(0, 0);
+ point_type p2(1, 1);
+
+ auto azimuth = boost::geometry::azimuth(p1, p2);
+
+ std::cout << "azimuth: " << azimuth << std::endl;
+
+ return 0;
+}
+
+//]
+
+//[azimuth_output
+/*`
+Output:
+[pre
+azimuth: 0.785398
+]
+*/
+//]
diff --git a/doc/src/examples/algorithms/azimuth_strategy.cpp b/doc/src/examples/algorithms/azimuth_strategy.cpp
new file mode 100644
index 000000000..2a8ef5178
--- /dev/null
+++ b/doc/src/examples/algorithms/azimuth_strategy.cpp
@@ -0,0 +1,46 @@
+// Boost.Geometry
+// QuickBook Example
+
+// Copyright (c) 2021, Oracle and/or its affiliates
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+//[azimuth_strategy
+//` Shows how to calculate azimuth in geographic coordinate system
+
+#include
+
+#include
+#include
+
+int main()
+{
+ namespace bg = boost::geometry;
+ typedef bg::model::point > point_type;
+
+ point_type p1(0, 0);
+ point_type p2(1, 1);
+
+ bg::srs::spheroid spheroid(6378137.0, 6356752.3142451793);
+ bg::strategies::azimuth::geographic<> strategy(spheroid);
+
+ auto azimuth = boost::geometry::azimuth(p1, p2, strategy);
+
+ std::cout << "azimuth: " << azimuth << std::endl;
+
+ return 0;
+}
+
+//]
+
+//[azimuth_strategy_output
+/*`
+Output:
+[pre
+azimuth: 0.788674
+]
+*/
+//]
diff --git a/example/05_b_overlay_linestring_polygon_example.cpp b/example/05_b_overlay_linestring_polygon_example.cpp
index 38349decb..f37165f3e 100644
--- a/example/05_b_overlay_linestring_polygon_example.cpp
+++ b/example/05_b_overlay_linestring_polygon_example.cpp
@@ -67,12 +67,13 @@ int main(void)
#endif
// Calculate intersection points (turn points)
- typedef bg::segment_ratio_type::type segment_ratio;
+ typedef bg::detail::segment_ratio_type::type segment_ratio;
typedef bg::detail::overlay::turn_info turn_info;
std::vector turns;
bg::detail::get_turns::no_interrupt_policy policy;
bg::detail::no_rescale_policy rescale_policy;
- bg::get_turns(ls, p, rescale_policy, turns, policy);
+ bg::strategy::intersection::services::default_strategy::type>::type intersection_strategy;
+ bg::get_turns(ls, p, intersection_strategy, rescale_policy, turns, policy);
std::cout << "Intersection of linestring/polygon" << std::endl;
BOOST_FOREACH(turn_info const& turn, turns)
diff --git a/example/c05_custom_point_pointer_example.cpp b/example/c05_custom_point_pointer_example.cpp
index d8059fe04..a1d9dbef0 100644
--- a/example/c05_custom_point_pointer_example.cpp
+++ b/example/c05_custom_point_pointer_example.cpp
@@ -102,10 +102,11 @@ int main()
// This works because outputs to a normal struct point, no point*
typedef boost::geometry::model::linestring linestring_2d;
+ boost::geometry::detail::no_rescale_policy rescale_policy;
std::vector clipped;
boost::geometry::strategy::intersection::liang_barsky strategy;
boost::geometry::detail::intersection::clip_range_with_box(cb,
- myline, std::back_inserter(clipped), strategy);
+ myline, rescale_policy, std::back_inserter(clipped), strategy);
std::cout << boost::geometry::length(clipped.front()) << std::endl;
diff --git a/example/c08_custom_non_std_example.cpp b/example/c08_custom_non_std_example.cpp
index 0a545a3de..12bb76840 100644
--- a/example/c08_custom_non_std_example.cpp
+++ b/example/c08_custom_non_std_example.cpp
@@ -281,7 +281,7 @@ int main()
// Create (as an example) a regular polygon
const int n = 5;
- const double d = (360 / n) * boost::geometry::math::d2r;
+ const double d = (360 / n) * boost::geometry::math::d2r();
double a = 0;
for (int i = 0; i < n + 1; i++, a += d)
{
diff --git a/include/boost/geometry/algorithms/azimuth.hpp b/include/boost/geometry/algorithms/azimuth.hpp
new file mode 100644
index 000000000..2e97eed2f
--- /dev/null
+++ b/include/boost/geometry/algorithms/azimuth.hpp
@@ -0,0 +1,226 @@
+// Boost.Geometry
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// This file was modified by Oracle on 2014-2021.
+// Modifications copyright (c) 2014-2021, Oracle and/or its affiliates.
+// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
+// Contributed and/or modified by 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_ALGORITHMS_AZIMUTH_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_AZIMUTH_HPP
+
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+ typename Geometry1, typename Geometry2,
+ typename Tag1 = typename tag::type,
+ typename Tag2 = typename tag::type
+>
+struct azimuth : not_implemented
+{};
+
+template
+struct azimuth
+{
+ template
+ static auto apply(Point1 const& p1, Point2 const& p2, Strategy const& strategy)
+ {
+ typedef typename decltype(strategy.azimuth())::template result_type
+ <
+ typename coordinate_type::type,
+ typename coordinate_type::type
+ >::type calc_t;
+
+ calc_t result = 0;
+ calc_t const x1 = geometry::get_as_radian<0>(p1);
+ calc_t const y1 = geometry::get_as_radian<1>(p1);
+ calc_t const x2 = geometry::get_as_radian<0>(p2);
+ calc_t const y2 = geometry::get_as_radian<1>(p2);
+
+ strategy.azimuth().apply(x1, y1, x2, y2, result);
+
+ // NOTE: It is not clear which units we should use for the result.
+ // For now radians are always returned but a user could expect
+ // e.g. something like this:
+ /*
+ bool const both_degree = std::is_same
+ <
+ typename detail::cs_angular_units::type,
+ geometry::degree
+ >::value
+ && std::is_same
+ <
+ typename detail::cs_angular_units::type,
+ geometry::degree
+ >::value;
+ if (both_degree)
+ {
+ result *= math::r2d();
+ }
+ */
+
+ return result;
+ }
+};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+namespace resolve_strategy
+{
+
+template
+<
+ typename Strategy,
+ bool IsUmbrella = strategies::detail::is_umbrella_strategy::value
+>
+struct azimuth
+{
+ template
+ static auto apply(P1 const& p1, P2 const& p2, Strategy const& strategy)
+ {
+ return dispatch::azimuth::apply(p1, p2, strategy);
+ }
+};
+
+template
+struct azimuth
+{
+ template
+ static auto apply(P1 const& p1, P2 const& p2, Strategy const& strategy)
+ {
+ using strategies::azimuth::services::strategy_converter;
+ return dispatch::azimuth
+ <
+ P1, P2
+ >::apply(p1, p2, strategy_converter::get(strategy));
+ }
+};
+
+template <>
+struct azimuth
+{
+ template
+ static auto apply(P1 const& p1, P2 const& p2, default_strategy)
+ {
+ typedef typename strategies::azimuth::services::default_strategy
+ <
+ P1, P2
+ >::type strategy_type;
+
+ return dispatch::azimuth::apply(p1, p2, strategy_type());
+ }
+};
+
+
+} // namespace resolve_strategy
+
+
+namespace resolve_variant
+{
+} // namespace resolve_variant
+
+
+/*!
+\brief Calculate azimuth of a segment defined by a pair of points.
+\ingroup azimuth
+\tparam Point1 Type of the first point of a segment.
+\tparam Point2 Type of the second point of a segment.
+\param point1 First point of a segment.
+\param point2 Second point of a segment.
+\return Azimuth in radians.
+
+\qbk{[include reference/algorithms/azimuth.qbk]}
+
+\qbk{
+[heading Example]
+[azimuth]
+[azimuth_output]
+}
+*/
+template
+inline auto azimuth(Point1 const& point1, Point2 const& point2)
+{
+ concepts::check();
+ concepts::check();
+
+ return resolve_strategy::azimuth
+ <
+ default_strategy
+ >::apply(point1, point2, default_strategy());
+}
+
+
+/*!
+\brief Calculate azimuth of a segment defined by a pair of points.
+\ingroup azimuth
+\tparam Point1 Type of the first point of a segment.
+\tparam Point2 Type of the second point of a segment.
+\tparam Strategy Type of an umbrella strategy defining azimuth strategy.
+\param point1 First point of a segment.
+\param point2 Second point of a segment.
+\param strategy Umbrella strategy defining azimuth strategy.
+\return Azimuth in radians.
+
+\qbk{distinguish,with strategy}
+\qbk{[include reference/algorithms/azimuth.qbk]}
+
+\qbk{
+[heading Example]
+[azimuth_strategy]
+[azimuth_strategy_output]
+}
+*/
+template
+inline auto azimuth(Point1 const& point1, Point2 const& point2, Strategy const& strategy)
+{
+ concepts::check();
+ concepts::check();
+
+ return resolve_strategy::azimuth::apply(point1, point2, strategy);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_AZIMUTH_HPP
diff --git a/include/boost/geometry/algorithms/buffer.hpp b/include/boost/geometry/algorithms/buffer.hpp
index 3bf6d2fa5..453b14873 100644
--- a/include/boost/geometry/algorithms/buffer.hpp
+++ b/include/boost/geometry/algorithms/buffer.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 2017-2020.
-// Modifications copyright (c) 2017-2020 Oracle and/or its affiliates.
+// This file was modified by Oracle on 2017-2021.
+// Modifications copyright (c) 2017-2021 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
@@ -242,22 +242,23 @@ inline void buffer(GeometryIn const& geometry_in,
geometry::envelope(geometry_in, box);
geometry::buffer(box, box, distance_strategy.max_distance(join_strategy, end_strategy));
- typename strategy::intersection::services::default_strategy
+ typename strategies::relate::services::default_strategy
<
- typename cs_tag::type
- >::type intersection_strategy;
+ GeometryIn, GeometryIn
+ >::type strategies;
rescale_policy_type rescale_policy
= boost::geometry::get_rescale_policy(
- box, intersection_strategy);
+ box, strategies);
- detail::buffer::buffer_inserter(geometry_in, range::back_inserter(geometry_out),
+ detail::buffer::buffer_inserter(geometry_in,
+ range::back_inserter(geometry_out),
distance_strategy,
side_strategy,
join_strategy,
end_strategy,
point_strategy,
- intersection_strategy,
+ strategies,
rescale_policy);
}
diff --git a/include/boost/geometry/algorithms/convex_hull.hpp b/include/boost/geometry/algorithms/convex_hull.hpp
index 26bb8509e..d23f6a47f 100644
--- a/include/boost/geometry/algorithms/convex_hull.hpp
+++ b/include/boost/geometry/algorithms/convex_hull.hpp
@@ -4,11 +4,12 @@
// 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, 2015, 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 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.
@@ -20,356 +21,7 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_CONVEX_HULL_HPP
#define BOOST_GEOMETRY_ALGORITHMS_CONVEX_HULL_HPP
-#include
-
-#include
-#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 convex_hull
-{
-
-template
-struct hull_insert
-{
-
- // Member template function (to avoid inconvenient declaration
- // of output-iterator-type, from hull_to_geometry)
- template
- static inline OutputIterator apply(Geometry const& geometry,
- OutputIterator out, Strategy const& strategy)
- {
- typename Strategy::state_type state;
-
- strategy.apply(geometry, state);
- strategy.result(state, out, Order == clockwise, Closure != open);
- return out;
- }
-};
-
-struct hull_to_geometry
-{
- template
- static inline void apply(Geometry const& geometry, OutputGeometry& out,
- Strategy const& strategy)
- {
- 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);
- }
-};
-
-}} // namespace detail::convex_hull
-#endif // DOXYGEN_NO_DETAIL
-
-
-#ifndef DOXYGEN_NO_DISPATCH
-namespace dispatch
-{
-
-
-template
-<
- typename Geometry,
- typename Tag = typename tag::type
->
-struct convex_hull
- : detail::convex_hull::hull_to_geometry
-{};
-
-template
-struct convex_hull
-{
- template
- static inline void apply(Box const& box, OutputGeometry& out,
- Strategy const& )
- {
- static bool const Close
- = geometry::closure::value == closed;
- static bool const Reverse
- = geometry::point_order::value == counterclockwise;
-
- // A hull for boxes is trivial. Any strategy is (currently) skipped.
- boost::array::type, 4> range;
- geometry::detail::assign_box_corners_oriented(box, range);
- geometry::append(out, range);
- if (BOOST_GEOMETRY_CONDITION(Close))
- {
- geometry::append(out, *boost::begin(range));
- }
- }
-};
-
-
-
-template
-struct convex_hull_insert
- : detail::convex_hull::hull_insert
-{};
-
-
-} // namespace dispatch
-#endif // DOXYGEN_NO_DISPATCH
-
-
-namespace resolve_strategy {
-
-struct convex_hull
-{
- template
- static inline void apply(Geometry const& geometry,
- OutputGeometry& out,
- Strategy const& strategy)
- {
- BOOST_CONCEPT_ASSERT( (geometry::concepts::ConvexHullStrategy) );
- dispatch::convex_hull::apply(geometry, out, strategy);
- }
-
- template
- static inline void apply(Geometry const& geometry,
- OutputGeometry& out,
- default_strategy)
- {
- typedef typename strategy_convex_hull<
- Geometry,
- typename point_type::type
- >::type strategy_type;
-
- apply(geometry, out, strategy_type());
- }
-};
-
-struct convex_hull_insert
-{
- template
- static inline OutputIterator apply(Geometry const& geometry,
- OutputIterator& out,
- Strategy const& strategy)
- {
- BOOST_CONCEPT_ASSERT( (geometry::concepts::ConvexHullStrategy) );
-
- return dispatch::convex_hull_insert<
- geometry::point_order::value,
- geometry::closure::value
- >::apply(geometry, out, strategy);
- }
-
- template
- static inline OutputIterator apply(Geometry const& geometry,
- OutputIterator& out,
- default_strategy)
- {
- typedef typename strategy_convex_hull<
- Geometry,
- typename point_type::type
- >::type strategy_type;
-
- return apply(geometry, out, strategy_type());
- }
-};
-
-} // namespace resolve_strategy
-
-
-namespace resolve_variant {
-
-template
-struct convex_hull
-{
- template
- static inline void apply(Geometry const& geometry, OutputGeometry& out, Strategy const& strategy)
- {
- concepts::check_concepts_and_equal_dimensions<
- const Geometry,
- OutputGeometry
- >();
-
- resolve_strategy::convex_hull::apply(geometry, out, strategy);
- }
-};
-
-template
-struct convex_hull >
-{
- template
- struct visitor: boost::static_visitor
- {
- OutputGeometry& m_out;
- Strategy const& m_strategy;
-
- visitor(OutputGeometry& out, Strategy const& strategy)
- : m_out(out), m_strategy(strategy)
- {}
-
- template
- void operator()(Geometry const& geometry) const
- {
- convex_hull::apply(geometry, m_out, m_strategy);
- }
- };
-
- template
- static inline void
- apply(boost::variant const& geometry,
- OutputGeometry& out,
- Strategy const& strategy)
- {
- boost::apply_visitor(visitor(out, strategy), geometry);
- }
-};
-
-template
-struct convex_hull_insert
-{
- template
- static inline OutputIterator apply(Geometry const& geometry, OutputIterator& out, Strategy const& strategy)
- {
- // Concept: output point type = point type of input geometry
- concepts::check();
- concepts::check::type>();
-
- return resolve_strategy::convex_hull_insert::apply(geometry, out, strategy);
- }
-};
-
-template
-struct convex_hull_insert >
-{
- template
- struct visitor: boost::static_visitor
- {
- OutputIterator& m_out;
- Strategy const& m_strategy;
-
- visitor(OutputIterator& out, Strategy const& strategy)
- : m_out(out), m_strategy(strategy)
- {}
-
- template
- OutputIterator operator()(Geometry const& geometry) const
- {
- return convex_hull_insert::apply(geometry, m_out, m_strategy);
- }
- };
-
- template
- static inline OutputIterator
- apply(boost::variant const& geometry,
- OutputIterator& out,
- Strategy const& strategy)
- {
- return boost::apply_visitor(visitor(out, strategy), geometry);
- }
-};
-
-} // namespace resolve_variant
-
-
-template
-inline void convex_hull(Geometry const& geometry,
- OutputGeometry& out, Strategy const& strategy)
-{
- if (geometry::is_empty(geometry))
- {
- // Leave output empty
- return;
- }
-
- resolve_variant::convex_hull::apply(geometry, out, strategy);
-}
-
-
-/*!
-\brief \brief_calc{convex hull}
-\ingroup convex_hull
-\details \details_calc{convex_hull,convex hull}.
-\tparam Geometry the input geometry type
-\tparam OutputGeometry the output geometry type
-\param geometry \param_geometry, input geometry
-\param hull \param_geometry \param_set{convex hull}
-
-\qbk{[include reference/algorithms/convex_hull.qbk]}
- */
-template
-inline void convex_hull(Geometry const& geometry,
- OutputGeometry& hull)
-{
- geometry::convex_hull(geometry, hull, default_strategy());
-}
-
-#ifndef DOXYGEN_NO_DETAIL
-namespace detail { namespace convex_hull
-{
-
-
-template
-inline OutputIterator convex_hull_insert(Geometry const& geometry,
- OutputIterator out, Strategy const& strategy)
-{
- return resolve_variant::convex_hull_insert
- ::apply(geometry, out, strategy);
-}
-
-
-/*!
-\brief Calculate the convex hull of a geometry, output-iterator version
-\ingroup convex_hull
-\tparam Geometry the input geometry type
-\tparam OutputIterator: an output-iterator
-\param geometry the geometry to calculate convex hull from
-\param out an output iterator outputing points of the convex hull
-\note This overloaded version outputs to an output iterator.
-In this case, nothing is known about its point-type or
- about its clockwise order. Therefore, the input point-type
- and order are copied
-
- */
-template
-inline OutputIterator convex_hull_insert(Geometry const& geometry,
- OutputIterator out)
-{
- return convex_hull_insert(geometry, out, default_strategy());
-}
-
-
-}} // namespace detail::convex_hull
-#endif // DOXYGEN_NO_DETAIL
-
-
-}} // namespace boost::geometry
-
+#include
+#include
#endif // BOOST_GEOMETRY_ALGORITHMS_CONVEX_HULL_HPP
diff --git a/include/boost/geometry/algorithms/crosses.hpp b/include/boost/geometry/algorithms/crosses.hpp
index 6dcbdbe9d..c3656216a 100644
--- a/include/boost/geometry/algorithms/crosses.hpp
+++ b/include/boost/geometry/algorithms/crosses.hpp
@@ -5,8 +5,8 @@
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2014 Samuel Debionne, Grenoble, France.
-// This file was modified by Oracle on 2014, 2017.
-// Modifications copyright (c) 2014-2017 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
@@ -31,6 +31,8 @@
#include
#include
#include
+#include
+#include
namespace boost { namespace geometry
@@ -65,9 +67,14 @@ struct crosses
namespace resolve_strategy
{
+template
+<
+ typename Strategy,
+ bool IsUmbrella = strategies::detail::is_umbrella_strategy::value
+>
struct crosses
{
- template
+ template
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
@@ -75,21 +82,50 @@ struct crosses
concepts::check();
concepts::check();
- return dispatch::crosses::apply(geometry1, geometry2, strategy);
+ return dispatch::crosses
+ <
+ Geometry1, Geometry2
+ >::apply(geometry1, geometry2, strategy);
}
+};
+template
+struct crosses
+{
+ template
+ static inline bool apply(Geometry1 const& geometry1,
+ Geometry2 const& geometry2,
+ Strategy const& strategy)
+ {
+ //using strategies::crosses::services::strategy_converter;
+ using strategies::relate::services::strategy_converter;
+ return crosses
+ <
+ decltype(strategy_converter::get(strategy))
+ >::apply(geometry1, geometry2,
+ strategy_converter::get(strategy));
+ }
+};
+
+template <>
+struct crosses
+{
template
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
default_strategy)
{
- typedef typename strategy::relate::services::default_strategy
+ //typedef typename strategies::crosses::services::default_strategy
+ typedef typename strategies::relate::services::default_strategy
<
Geometry1,
Geometry2
>::type strategy_type;
- return apply(geometry1, geometry2, strategy_type());
+ return crosses
+ <
+ strategy_type
+ >::apply(geometry1, geometry2, strategy_type());
}
};
@@ -106,7 +142,10 @@ namespace resolve_variant
Geometry2 const& geometry2,
Strategy const& strategy)
{
- return resolve_strategy::crosses::apply(geometry1, geometry2, strategy);
+ return resolve_strategy::crosses
+ <
+ Strategy
+ >::apply(geometry1, geometry2, strategy);
}
};
diff --git a/include/boost/geometry/algorithms/detail/azimuth.hpp b/include/boost/geometry/algorithms/detail/azimuth.hpp
deleted file mode 100644
index 21007778b..000000000
--- a/include/boost/geometry/algorithms/detail/azimuth.hpp
+++ /dev/null
@@ -1,152 +0,0 @@
-// Boost.Geometry (aka GGL, Generic Geometry Library)
-
-// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
-
-// This file was modified by Oracle on 2014, 2016, 2017.
-// Modifications copyright (c) 2014-2017, 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
-
-// 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_ALGORITHMS_DETAIL_AZIMUTH_HPP
-#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_AZIMUTH_HPP
-
-
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-
-#include
-
-
-namespace boost { namespace geometry
-{
-
-// An azimuth is an angle between a vector/segment from origin to a point of
-// interest and a reference vector. Typically north-based azimuth is used.
-// North direction is used as a reference, angle is measured clockwise
-// (North - 0deg, East - 90deg). For consistency in 2d cartesian CS
-// the reference vector is Y axis, angle is measured clockwise.
-// http://en.wikipedia.org/wiki/Azimuth
-
-#ifndef DOXYGEN_NO_DISPATCH
-namespace detail_dispatch
-{
-
-template
-struct azimuth
- : not_implemented
-{};
-
-template
-struct azimuth
-{
- template
- static inline ReturnType apply(P1 const& p1, P2 const& p2, Spheroid const& spheroid)
- {
- return geometry::formula::vincenty_inverse().apply
- ( get_as_radian<0>(p1), get_as_radian<1>(p1),
- get_as_radian<0>(p2), get_as_radian<1>(p2),
- spheroid ).azimuth;
- }
-
- template
- static inline ReturnType apply(P1 const& p1, P2 const& p2)
- {
- return apply(p1, p2, srs::spheroid());
- }
-};
-
-template
-struct azimuth
-{
- template
- static inline ReturnType apply(P1 const& p1, P2 const& p2, Sphere const& /*unused*/)
- {
- return geometry::formula::spherical_azimuth
- ( get_as_radian<0>(p1), get_as_radian<1>(p1),
- get_as_radian<0>(p2), get_as_radian<1>(p2)).azimuth;
- }
-
- template
- static inline ReturnType apply(P1 const& p1, P2 const& p2)
- {
- return apply(p1, p2, 0); // dummy model
- }
-};
-
-template
-struct azimuth
- : azimuth
-{};
-
-template
-struct azimuth
-{
- template
- static inline ReturnType apply(P1 const& p1, P2 const& p2, Plane const& /*unused*/)
- {
- ReturnType x = get<0>(p2) - get<0>(p1);
- ReturnType y = get<1>(p2) - get<1>(p1);
-
- // NOTE: azimuth 0 is at Y axis, increasing right
- // as in spherical/geographic where 0 is at North axis
- return atan2(x, y);
- }
-
- template
- static inline ReturnType apply(P1 const& p1, P2 const& p2)
- {
- return apply(p1, p2, 0); // dummy model
- }
-};
-
-} // detail_dispatch
-#endif // DOXYGEN_NO_DISPATCH
-
-#ifndef DOXYGEN_NO_DETAIL
-namespace detail
-{
-
-/// Calculate azimuth between two points.
-/// The result is in radians.
-template
-inline ReturnType azimuth(Point1 const& p1, Point2 const& p2)
-{
- return detail_dispatch::azimuth
- <
- ReturnType,
- typename geometry::cs_tag::type
- >::apply(p1, p2);
-}
-
-/// Calculate azimuth between two points.
-/// The result is in radians.
-template
-inline ReturnType azimuth(Point1 const& p1, Point2 const& p2, Model const& model)
-{
- return detail_dispatch::azimuth
- <
- ReturnType,
- typename geometry::cs_tag::type
- >::apply(p1, p2, model);
-}
-
-} // namespace detail
-#endif // DOXYGEN_NO_DETAIL
-
-}} // namespace boost::geometry
-
-#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_AZIMUTH_HPP
diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp
index 685fdba66..aefa6e7a6 100644
--- a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp
+++ b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp
@@ -2,8 +2,8 @@
// Copyright (c) 2012-2020 Barend Gehrels, Amsterdam, the Netherlands.
-// This file was modified by Oracle on 2017-2020.
-// Modifications copyright (c) 2017-2020 Oracle and/or its affiliates.
+// This file was modified by Oracle on 2017-2021.
+// Modifications copyright (c) 2017-2021 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
@@ -921,7 +921,7 @@ template
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy,
- typename IntersectionStrategy,
+ typename Strategies,
typename RobustPolicy,
typename VisitPiecesPolicy
>
@@ -931,7 +931,7 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
PointStrategy const& point_strategy,
- IntersectionStrategy const& intersection_strategy,
+ Strategies const& strategies,
RobustPolicy const& robust_policy,
VisitPiecesPolicy& visit_pieces_policy
)
@@ -941,11 +941,11 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
typedef detail::buffer::buffered_piece_collection
<
typename geometry::ring_type::type,
- IntersectionStrategy,
+ Strategies,
DistanceStrategy,
RobustPolicy
> collection_type;
- collection_type collection(intersection_strategy, distance_strategy, robust_policy);
+ collection_type collection(strategies, distance_strategy, robust_policy);
collection_type const& const_collection = collection;
bool const areal = util::is_areal::value;
@@ -962,7 +962,7 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
>::apply(geometry_input, collection,
distance_strategy, side_strategy, join_strategy,
end_strategy, point_strategy,
- robust_policy, intersection_strategy.get_side_strategy());
+ robust_policy, strategies.side()); // pass strategies?
collection.get_turns();
if (BOOST_GEOMETRY_CONDITION(areal))
@@ -1029,7 +1029,7 @@ template
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy,
- typename IntersectionStrategy,
+ typename Strategies,
typename RobustPolicy
>
inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator out,
@@ -1038,14 +1038,14 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
PointStrategy const& point_strategy,
- IntersectionStrategy const& intersection_strategy,
+ Strategies const& strategies,
RobustPolicy const& robust_policy)
{
detail::buffer::visit_pieces_default_policy visitor;
buffer_inserter(geometry_input, out,
distance_strategy, side_strategy, join_strategy,
end_strategy, point_strategy,
- intersection_strategy, robust_policy, visitor);
+ strategies, robust_policy, visitor);
}
#endif // DOXYGEN_NO_DETAIL
diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp
index 7f865ecc0..05d5c6fda 100644
--- a/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp
+++ b/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp
@@ -193,30 +193,37 @@ struct buffer_less
}
};
+template
struct piece_get_box
{
+ explicit piece_get_box(Strategy const& strategy)
+ : m_strategy(strategy)
+ {}
+
template
- static inline void apply(Box& total, Piece const& piece)
+ inline void apply(Box& total, Piece const& piece) const
{
assert_coordinate_type_equal(total, piece.m_piece_border.m_envelope);
- typedef typename strategy::expand::services::default_strategy
- <
- box_tag, typename cs_tag::type
- >::type expand_strategy_type;
if (piece.m_piece_border.m_has_envelope)
{
geometry::expand(total, piece.m_piece_border.m_envelope,
- expand_strategy_type());
+ m_strategy);
}
}
+
+ Strategy const& m_strategy;
};
-template
+template
struct piece_overlaps_box
{
+ explicit piece_overlaps_box(Strategy const& strategy)
+ : m_strategy(strategy)
+ {}
+
template
- static inline bool apply(Box const& box, Piece const& piece)
+ inline bool apply(Box const& box, Piece const& piece) const
{
assert_coordinate_type_equal(box, piece.m_piece_border.m_envelope);
@@ -235,34 +242,45 @@ struct piece_overlaps_box
}
return ! geometry::detail::disjoint::disjoint_box_box(box, piece.m_piece_border.m_envelope,
- DisjointBoxBoxStrategy());
+ m_strategy);
}
+
+ Strategy const& m_strategy;
};
+template
struct turn_get_box
{
+ explicit turn_get_box(Strategy const& strategy)
+ : m_strategy(strategy)
+ {}
+
template
- static inline void apply(Box& total, Turn const& turn)
+ inline void apply(Box& total, Turn const& turn) const
{
- typedef typename strategy::expand::services::default_strategy
- <
- point_tag, typename cs_tag::type
- >::type expand_strategy_type;
assert_coordinate_type_equal(total, turn.point);
- geometry::expand(total, turn.point, expand_strategy_type());
+ geometry::expand(total, turn.point, m_strategy);
}
+
+ Strategy const& m_strategy;
};
-template
+template
struct turn_overlaps_box
{
+ explicit turn_overlaps_box(Strategy const& strategy)
+ : m_strategy(strategy)
+ {}
+
template
- static inline bool apply(Box const& box, Turn const& turn)
+ inline bool apply(Box const& box, Turn const& turn) const
{
assert_coordinate_type_equal(turn.point, box);
return ! geometry::detail::disjoint::disjoint_point_box(turn.point, box,
- DisjointPointBoxStrategy());
+ m_strategy);
}
+
+ Strategy const& m_strategy;
};
struct enriched_map_buffer_include_policy
diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp
index 3995f78da..6c852bd65 100644
--- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp
+++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp
@@ -3,8 +3,8 @@
// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
// 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.
+// This file was modified by Oracle on 2016-2021.
+// Modifications copyright (c) 2016-2021 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
@@ -117,7 +117,7 @@ namespace detail { namespace buffer
template
<
typename Ring,
- typename IntersectionStrategy,
+ typename Strategy,
typename DistanceStrategy,
typename RobustPolicy
>
@@ -131,27 +131,6 @@ struct buffered_piece_collection
typedef geometry::model::box box_type;
- typedef typename IntersectionStrategy::side_strategy_type side_strategy_type;
- typedef typename IntersectionStrategy::envelope_strategy_type envelope_strategy_type;
- typedef typename IntersectionStrategy::expand_strategy_type expand_strategy_type;
-
- typedef typename IntersectionStrategy::template area_strategy
- <
- point_type
- >::type area_strategy_type;
-
- typedef typename area_strategy_type::template result_type
- <
- point_type
- >::type area_result_type;
-
- typedef typename IntersectionStrategy::template point_in_geometry_strategy
- <
- point_type,
- clockwise_ring_type
- >::type point_in_geometry_strategy_type;
-
-
typedef buffer_turn_info
<
point_type,
@@ -232,23 +211,23 @@ struct buffered_piece_collection
{}
inline original_ring(clockwise_ring_type const& ring,
- bool is_interior, bool has_interiors,
- envelope_strategy_type const& envelope_strategy,
- expand_strategy_type const& expand_strategy)
+ bool is_interior, bool has_interiors,
+ Strategy const& strategy)
: m_ring(ring)
, m_is_interior(is_interior)
, m_has_interiors(has_interiors)
{
- geometry::envelope(m_ring, m_box, envelope_strategy);
+ geometry::envelope(m_ring, m_box, strategy);
// create monotonic sections in x-dimension
// The dimension is critical because the direction is later used
// in the optimization for within checks using winding strategy
// and this strategy is scanning in x direction.
typedef std::integer_sequence dimensions;
- geometry::sectionalize(m_ring,
- detail::no_rescale_policy(), m_sections,
- envelope_strategy, expand_strategy);
+ geometry::sectionalize
+ <
+ false, dimensions
+ >(m_ring, detail::no_rescale_policy(), m_sections, strategy);
}
clockwise_ring_type m_ring;
@@ -295,31 +274,18 @@ struct buffered_piece_collection
cluster_type m_clusters;
- IntersectionStrategy m_intersection_strategy;
+ Strategy m_strategy;
DistanceStrategy m_distance_strategy;
- side_strategy_type m_side_strategy;
- area_strategy_type m_area_strategy;
- envelope_strategy_type m_envelope_strategy;
- expand_strategy_type m_expand_strategy;
- point_in_geometry_strategy_type m_point_in_geometry_strategy;
-
RobustPolicy const& m_robust_policy;
- buffered_piece_collection(IntersectionStrategy const& intersection_strategy,
+ buffered_piece_collection(Strategy const& strategy,
DistanceStrategy const& distance_strategy,
RobustPolicy const& robust_policy)
: m_first_piece_index(-1)
, m_deflate(false)
, m_has_deflated(false)
- , m_intersection_strategy(intersection_strategy)
+ , m_strategy(strategy)
, m_distance_strategy(distance_strategy)
- , m_side_strategy(intersection_strategy.get_side_strategy())
- , m_area_strategy(intersection_strategy
- .template get_area_strategy())
- , m_envelope_strategy(intersection_strategy.get_envelope_strategy())
- , m_expand_strategy(intersection_strategy.get_expand_strategy())
- , m_point_in_geometry_strategy(intersection_strategy
- .template get_point_in_geometry_strategy())
, m_robust_policy(robust_policy)
{}
@@ -393,8 +359,7 @@ struct buffered_piece_collection
it != boost::end(m_linear_end_points);
++it)
{
- if (detail::equals::equals_point_point(turn.point, *it,
- m_intersection_strategy.get_equals_point_point_strategy()))
+ if (detail::equals::equals_point_point(turn.point, *it, m_strategy))
{
turn.is_linear_end_point = true;
}
@@ -468,20 +433,11 @@ struct buffered_piece_collection
// Check if a turn is inside any of the originals
inline void check_turn_in_original()
{
- typedef turn_in_original_overlaps_box
- <
- typename IntersectionStrategy::disjoint_point_box_strategy_type
- > turn_in_original_overlaps_box_type;
- typedef original_overlaps_box
- <
- typename IntersectionStrategy::disjoint_box_box_strategy_type
- > original_overlaps_box_type;
-
turn_in_original_visitor
<
turn_vector_type,
- point_in_geometry_strategy_type
- > visitor(m_turns, m_point_in_geometry_strategy);
+ Strategy
+ > visitor(m_turns, m_strategy);
geometry::partition
<
@@ -489,8 +445,10 @@ struct buffered_piece_collection
include_turn_policy,
detail::partition::include_all_policy
>::apply(m_turns, original_rings, visitor,
- turn_get_box(), turn_in_original_overlaps_box_type(),
- original_get_box(), original_overlaps_box_type());
+ turn_get_box(m_strategy),
+ turn_in_original_overlaps_box(m_strategy),
+ original_get_box(m_strategy),
+ original_overlaps_box(m_strategy));
bool const deflate = m_distance_strategy.negative();
@@ -560,10 +518,11 @@ struct buffered_piece_collection
}
// Calculate envelopes for piece borders
- border.get_properties_of_border(pc.type == geometry::strategy::buffer::buffered_point, pc.m_center);
+ border.get_properties_of_border(pc.type == geometry::strategy::buffer::buffered_point,
+ pc.m_center, m_strategy);
if (! pc.is_flat_end && ! pc.is_flat_start)
{
- border.get_properties_of_offsetted_ring_part(m_side_strategy);
+ border.get_properties_of_offsetted_ring_part(m_strategy);
}
}
}
@@ -580,28 +539,19 @@ struct buffered_piece_collection
piece_vector_type,
buffered_ring_collection >,
turn_vector_type,
- IntersectionStrategy,
+ Strategy,
RobustPolicy
> visitor(m_pieces, offsetted_rings, m_turns,
- m_intersection_strategy, m_robust_policy);
+ m_strategy, m_robust_policy);
- typedef detail::section::get_section_box
- <
- typename IntersectionStrategy::expand_box_strategy_type
- > get_section_box_type;
- typedef detail::section::overlaps_section_box
- <
- typename IntersectionStrategy::disjoint_box_box_strategy_type
- > overlaps_section_box_type;
+ detail::sectionalize::enlarge_sections(monotonic_sections, m_strategy);
- detail::sectionalize::enlarge_sections(monotonic_sections,
- m_envelope_strategy);
geometry::partition
<
robust_box_type
>::apply(monotonic_sections, visitor,
- get_section_box_type(),
- overlaps_section_box_type());
+ detail::section::get_section_box(m_strategy),
+ detail::section::overlaps_section_box(m_strategy));
}
update_turn_administration();
@@ -614,21 +564,14 @@ struct buffered_piece_collection
turn_vector_type, piece_vector_type, DistanceStrategy
> visitor(m_turns, m_pieces, m_distance_strategy);
- typedef turn_overlaps_box
- <
- typename IntersectionStrategy::disjoint_point_box_strategy_type
- > turn_overlaps_box_type;
- typedef piece_overlaps_box
- <
- typename IntersectionStrategy::disjoint_box_box_strategy_type
- > piece_overlaps_box_type;
-
geometry::partition
<
box_type
>::apply(m_turns, m_pieces, visitor,
- turn_get_box(), turn_overlaps_box_type(),
- piece_get_box(), piece_overlaps_box_type());
+ turn_get_box(m_strategy),
+ turn_overlaps_box(m_strategy),
+ piece_get_box(m_strategy),
+ piece_overlaps_box(m_strategy));
}
}
@@ -771,7 +714,7 @@ struct buffered_piece_collection
original_rings.back()
= original_ring(clockwise_ring,
is_interior, has_interiors,
- m_envelope_strategy, m_expand_strategy);
+ m_strategy);
}
}
@@ -870,6 +813,7 @@ struct buffered_piece_collection
boost::begin(ring) + pc.first_seg_id.segment_index,
boost::begin(ring) + pc.beyond_last_segment_index,
m_robust_policy,
+ m_strategy,
ring_id, 10);
}
@@ -1042,7 +986,7 @@ struct buffered_piece_collection
enrich_intersection_points(m_turns,
m_clusters, offsetted_rings, offsetted_rings,
m_robust_policy,
- m_intersection_strategy);
+ m_strategy);
}
// Discards all rings which do have not-OK intersection points only.
@@ -1067,8 +1011,6 @@ struct buffered_piece_collection
inline bool point_coveredby_original(point_type const& point)
{
- typedef typename IntersectionStrategy::disjoint_point_box_strategy_type d_pb_strategy_type;
-
signed_size_type count_in_original = 0;
// Check of the robust point of this outputted ring is in
@@ -1085,16 +1027,13 @@ struct buffered_piece_collection
{
continue;
}
- if (detail::disjoint::disjoint_point_box(point,
- original.m_box,
- d_pb_strategy_type()))
+ if (detail::disjoint::disjoint_point_box(point, original.m_box,m_strategy))
{
continue;
}
int const geometry_code
- = detail::within::point_in_geometry(point,
- original.m_ring, m_point_in_geometry_strategy);
+ = detail::within::point_in_geometry(point, original.m_ring, m_strategy);
if (geometry_code == -1)
{
@@ -1133,7 +1072,7 @@ struct buffered_piece_collection
buffered_ring& ring = *it;
if (! ring.has_intersections()
&& boost::size(ring) > 0u
- && geometry::area(ring, m_area_strategy) < 0)
+ && geometry::area(ring, m_strategy) < 0)
{
if (! point_coveredby_original(geometry::range::front(ring)))
{
@@ -1173,7 +1112,7 @@ struct buffered_piece_collection
traversed_rings.clear();
buffer_overlay_visitor visitor;
traverser::apply(offsetted_rings, offsetted_rings,
- m_intersection_strategy, m_robust_policy,
+ m_strategy, m_robust_policy,
m_turns, traversed_rings,
turn_info_per_ring,
m_clusters, visitor);
@@ -1202,7 +1141,14 @@ struct buffered_piece_collection
template
inline OutputIterator assign(OutputIterator out) const
{
- typedef detail::overlay::ring_properties properties;
+ typedef typename geometry::area_result
+ <
+ buffered_ring, Strategy
+ >::type area_result_type;
+ typedef detail::overlay::ring_properties
+ <
+ point_type, area_result_type
+ > properties;
std::map selected;
@@ -1218,7 +1164,7 @@ struct buffered_piece_collection
if (! it->has_intersections()
&& ! it->is_untouched_outside_original)
{
- properties p = properties(*it, m_area_strategy);
+ properties p = properties(*it, m_strategy);
if (p.valid)
{
ring_identifier id(0, index, -1);
@@ -1234,7 +1180,7 @@ struct buffered_piece_collection
it != boost::end(traversed_rings);
++it, ++index)
{
- properties p = properties(*it, m_area_strategy);
+ properties p = properties(*it, m_strategy);
if (p.valid)
{
ring_identifier id(2, index, -1);
@@ -1243,9 +1189,9 @@ struct buffered_piece_collection
}
detail::overlay::assign_parents(offsetted_rings, traversed_rings,
- selected, m_intersection_strategy);
+ selected, m_strategy);
return detail::overlay::add_rings(selected, offsetted_rings, traversed_rings, out,
- m_area_strategy);
+ m_strategy);
}
};
diff --git a/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp b/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp
index 83920f389..09fef7518 100644
--- a/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp
+++ b/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp
@@ -117,7 +117,7 @@ template
typename Pieces,
typename Rings,
typename Turns,
- typename IntersectionStrategy,
+ typename Strategy,
typename RobustPolicy
>
class piece_turn_visitor
@@ -125,7 +125,7 @@ class piece_turn_visitor
Pieces const& m_pieces;
Rings const& m_rings;
Turns& m_turns;
- IntersectionStrategy const& m_intersection_strategy;
+ Strategy const& m_strategy;
RobustPolicy const& m_robust_policy;
template
@@ -271,7 +271,7 @@ class piece_turn_visitor
turn_policy::apply(unique_sub_range1, unique_sub_range2,
the_model,
- m_intersection_strategy,
+ m_strategy,
m_robust_policy,
std::back_inserter(m_turns));
}
@@ -283,12 +283,12 @@ public:
piece_turn_visitor(Pieces const& pieces,
Rings const& ring_collection,
Turns& turns,
- IntersectionStrategy const& intersection_strategy,
+ Strategy const& strategy,
RobustPolicy const& robust_policy)
: m_pieces(pieces)
, m_rings(ring_collection)
, m_turns(turns)
- , m_intersection_strategy(intersection_strategy)
+ , m_strategy(strategy)
, m_robust_policy(robust_policy)
{}
@@ -307,7 +307,7 @@ public:
|| is_on_same_convex_ring(piece1, piece2)
|| detail::disjoint::disjoint_box_box(section1.bounding_box,
section2.bounding_box,
- m_intersection_strategy.get_disjoint_box_box_strategy()) )
+ m_strategy) )
{
return true;
}
diff --git a/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp b/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp
index 026808edf..ecd03d9c8 100644
--- a/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp
+++ b/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp
@@ -167,9 +167,11 @@ struct piece_border
return result;
}
- void get_properties_of_border(bool is_point_buffer, Point const& center)
+ template
+ void get_properties_of_border(bool is_point_buffer, Point const& center,
+ Strategy const& strategy)
{
- m_has_envelope = calculate_envelope(m_envelope);
+ m_has_envelope = calculate_envelope(m_envelope, strategy);
if (m_has_envelope)
{
// Take roundings into account, enlarge box
@@ -182,8 +184,8 @@ struct piece_border
}
}
- template
- void get_properties_of_offsetted_ring_part(SideStrategy const& strategy)
+ template
+ void get_properties_of_offsetted_ring_part(Strategy const& strategy)
{
if (! ring_or_original_empty())
{
@@ -209,16 +211,16 @@ struct piece_border
m_originals[m_original_size++] = point;
}
- template
- bool calculate_envelope(Box& envelope) const
+ template
+ bool calculate_envelope(Box& envelope, Strategy const& strategy) const
{
geometry::assign_inverse(envelope);
if (ring_or_original_empty())
{
return false;
}
- expand_envelope(envelope, m_ring->begin() + m_begin, m_ring->begin() + m_end);
- expand_envelope(envelope, m_originals.begin(), m_originals.begin() + m_original_size);
+ expand_envelope(envelope, m_ring->begin() + m_begin, m_ring->begin() + m_end, strategy);
+ expand_envelope(envelope, m_originals.begin(), m_originals.begin() + m_original_size, strategy);
return true;
}
@@ -333,8 +335,8 @@ private :
return true;
}
- template
- bool step(TurnPoint const& point, Point const& p1, Point const& p2, Strategy const & strategy,
+ template
+ bool step(TurnPoint const& point, Point const& p1, Point const& p2, TiRStrategy const & strategy,
geometry::strategy::buffer::place_on_ring_type place_on_ring, State& state) const
{
// A step between original/offsetted ring is always convex
@@ -357,22 +359,17 @@ private :
return strategy.apply(point, p1, p2, dm, place_on_ring, state);
}
- template
- void expand_envelope(Box& envelope, It begin, It end) const
+ template
+ void expand_envelope(Box& envelope, It begin, It end, Strategy const& strategy) const
{
- typedef typename strategy::expand::services::default_strategy
- <
- point_tag, typename cs_tag::type
- >::type expand_strategy_type;
-
for (It it = begin; it != end; ++it)
{
- geometry::expand(envelope, *it, expand_strategy_type());
+ geometry::expand(envelope, *it, strategy);
}
}
- template
- bool is_convex(SideStrategy const& strategy) const
+ template
+ bool is_convex(Strategy const& strategy) const
{
if (ring_or_original_empty())
{
@@ -416,8 +413,8 @@ private :
return result;
}
- template
- bool is_convex(Point& previous, Point& current, It begin, It end, SideStrategy const& strategy) const
+ template
+ bool is_convex(Point& previous, Point& current, It begin, It end, Strategy const& strategy) const
{
for (It it = begin; it != end; ++it)
{
@@ -429,19 +426,16 @@ private :
return true;
}
- template
- bool is_convex(Point& previous, Point& current, Point const& next, SideStrategy const& strategy) const
+ template
+ bool is_convex(Point& previous, Point& current, Point const& next, Strategy const& strategy) const
{
- typename SideStrategy::equals_point_point_strategy_type const
- eq_pp_strategy = strategy.get_equals_point_point_strategy();
-
- int const side = strategy.apply(previous, current, next);
+ int const side = strategy.side().apply(previous, current, next);
if (side == 1)
{
// Next is on the left side of clockwise ring: piece is not convex
return false;
}
- if (! equals::equals_point_point(current, next, eq_pp_strategy))
+ if (! equals::equals_point_point(current, next, strategy))
{
previous = current;
current = next;
diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp
index d51220dac..b1930dc0c 100644
--- a/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp
+++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp
@@ -2,8 +2,8 @@
// Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands.
-// This file was modified by Oracle on 2016, 2018.
-// Modifications copyright (c) 2016-2018 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,
@@ -31,31 +31,40 @@ namespace boost { namespace geometry
namespace detail { namespace buffer
{
+
+template
struct original_get_box
{
+ explicit original_get_box(Strategy const& strategy)
+ : m_strategy(strategy)
+ {}
+
template
- static inline void apply(Box& total, Original const& original)
+ inline void apply(Box& total, Original const& original) const
{
assert_coordinate_type_equal(total, original.m_box);
- typedef typename strategy::expand::services::default_strategy
- <
- box_tag, typename cs_tag::type
- >::type expand_strategy_type;
-
- geometry::expand(total, original.m_box, expand_strategy_type());
+ geometry::expand(total, original.m_box, m_strategy);
}
+
+ Strategy const& m_strategy;
};
-template
+template
struct original_overlaps_box
{
+ explicit original_overlaps_box(Strategy const& strategy)
+ : m_strategy(strategy)
+ {}
+
template