fix: add closest_ponts and centroid getters to higher level umbrella strategies

This commit is contained in:
Adam Wulkiewicz 2025-01-10 23:59:40 +01:00
parent 225c4f2346
commit 3bedb43f1d
9 changed files with 101 additions and 31 deletions

View File

@ -1,5 +1,7 @@
// Boost.Geometry
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2020-2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@ -14,6 +16,8 @@
#include <boost/geometry/strategies/area/cartesian.hpp>
#include <boost/geometry/strategies/azimuth/cartesian.hpp>
#include <boost/geometry/strategies/buffer/cartesian.hpp>
#include <boost/geometry/strategies/centroid/cartesian.hpp>
#include <boost/geometry/strategies/closest_points/cartesian.hpp>
#include <boost/geometry/strategies/convex_hull/cartesian.hpp>
#include <boost/geometry/strategies/distance/cartesian.hpp>
#include <boost/geometry/strategies/envelope/cartesian.hpp>
@ -36,7 +40,8 @@ namespace strategies
template <typename CalculationType = void>
class cartesian
// derived from the umbrella strategy defining the most strategies
: public strategies::index::cartesian<CalculationType>
: public strategies::closest_points::cartesian<CalculationType>
, public strategies::centroid::detail::cartesian<CalculationType>
{
public:

View File

@ -1,5 +1,7 @@
// Boost.Geometry
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@ -27,9 +29,12 @@ namespace boost { namespace geometry
namespace strategies { namespace centroid
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
template <typename CalculationType = void>
struct cartesian
: public strategies::detail::cartesian_base
{
template <typename Geometry>
static auto centroid(Geometry const&,
@ -77,6 +82,17 @@ struct cartesian
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
template <typename CalculationType = void>
struct cartesian
: public strategies::detail::cartesian_base
, public strategies::centroid::detail::cartesian<CalculationType>
{};
namespace services
{

View File

@ -1,5 +1,7 @@
// Boost.Geometry
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@ -22,24 +24,13 @@ namespace boost { namespace geometry
namespace strategies { namespace centroid
{
template
<
typename FormulaPolicy = strategy::andoyer,
typename Spheroid = srs::spheroid<double>,
typename CalculationType = void
>
class geographic
: public strategies::detail::geographic_base<Spheroid>
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
using base_t = strategies::detail::geographic_base<Spheroid>;
class geographic
{
public:
geographic() = default;
explicit geographic(Spheroid const& spheroid)
: base_t(spheroid)
{}
// TODO: Box and Segment should have proper strategies.
template <typename Geometry, typename Point>
static auto centroid(Geometry const&, Point const&,
@ -53,6 +44,32 @@ public:
}
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
template
<
typename FormulaPolicy = strategy::andoyer,
typename Spheroid = srs::spheroid<double>,
typename CalculationType = void
>
class geographic
: public strategies::detail::geographic_base<Spheroid>
, public strategies::centroid::detail::geographic
{
using base_t = strategies::detail::geographic_base<Spheroid>;
public:
geographic() = default;
explicit geographic(Spheroid const& spheroid)
: base_t(spheroid)
{}
};
namespace services
{

View File

@ -1,5 +1,7 @@
// Boost.Geometry
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@ -22,18 +24,13 @@ namespace boost { namespace geometry
namespace strategies { namespace centroid
{
template
<
typename CalculationType = void
>
class spherical
: public strategies::detail::spherical_base<void>
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
using base_t = strategies::detail::spherical_base<void>;
class spherical
{
public:
spherical() = default;
// TODO: Box and Segment should have proper strategies.
template <typename Geometry, typename Point>
static auto centroid(Geometry const&, Point const&,
@ -48,6 +45,20 @@ public:
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
template <typename CalculationType = void>
class spherical
: public strategies::detail::spherical_base<void>
, public strategies::centroid::detail::spherical
{
public:
spherical() = default;
};
namespace services
{

View File

@ -1,5 +1,7 @@
// Boost.Geometry
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2020-2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@ -14,6 +16,8 @@
#include <boost/geometry/strategies/area/geographic.hpp>
#include <boost/geometry/strategies/azimuth/geographic.hpp>
#include <boost/geometry/strategies/buffer/geographic.hpp>
#include <boost/geometry/strategies/centroid/geographic.hpp>
#include <boost/geometry/strategies/closest_points/geographic.hpp>
#include <boost/geometry/strategies/convex_hull/geographic.hpp>
#include <boost/geometry/strategies/distance/geographic.hpp>
#include <boost/geometry/strategies/envelope/geographic.hpp>
@ -41,9 +45,10 @@ template
>
class geographic
// derived from the umbrella strategy defining the most strategies
: public index::geographic<FormulaPolicy, Spheroid, CalculationType>
: public strategies::closest_points::geographic<FormulaPolicy, Spheroid, CalculationType>
, public strategies::centroid::detail::geographic
{
using base_t = index::geographic<FormulaPolicy, Spheroid, CalculationType>;
using base_t = strategies::closest_points::geographic<FormulaPolicy, Spheroid, CalculationType>;
public:
geographic() = default;

View File

@ -1,5 +1,7 @@
// Boost.Geometry
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2020-2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@ -11,17 +13,18 @@
#define BOOST_GEOMETRY_STRATEGIES_INDEX_CARTESIAN_HPP
#include <boost/geometry/strategies/centroid/cartesian.hpp>
#include <boost/geometry/strategies/distance/cartesian.hpp>
#include <boost/geometry/strategies/index/services.hpp>
namespace boost { namespace geometry { namespace strategies { namespace index
{
template <typename CalculationType = void>
class cartesian
: public distance::cartesian<CalculationType>
, public strategies::centroid::detail::cartesian<CalculationType>
{};

View File

@ -1,5 +1,7 @@
// Boost.Geometry
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2020-2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@ -11,6 +13,7 @@
#define BOOST_GEOMETRY_STRATEGIES_INDEX_GEOGRAPHIC_HPP
#include <boost/geometry/strategies/centroid/geographic.hpp>
#include <boost/geometry/strategies/distance/geographic.hpp>
#include <boost/geometry/strategies/index/services.hpp>
@ -26,6 +29,7 @@ template
>
class geographic
: public distance::geographic<FormulaPolicy, Spheroid, CalculationType>
, public strategies::centroid::detail::geographic
{
typedef distance::geographic<FormulaPolicy, Spheroid, CalculationType> base_t;

View File

@ -1,5 +1,7 @@
// Boost.Geometry
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2020-2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@ -11,6 +13,7 @@
#define BOOST_GEOMETRY_STRATEGIES_INDEX_SPHERICAL_HPP
#include <boost/geometry/strategies/centroid/spherical.hpp>
#include <boost/geometry/strategies/distance/spherical.hpp>
#include <boost/geometry/strategies/index/services.hpp>
@ -28,6 +31,7 @@ namespace detail
template <typename RadiusTypeOrSphere, typename CalculationType>
class spherical
: public strategies::distance::detail::spherical<RadiusTypeOrSphere, CalculationType>
, public strategies::centroid::detail::spherical
{
using base_t = strategies::distance::detail::spherical<RadiusTypeOrSphere, CalculationType>;

View File

@ -1,5 +1,7 @@
// Boost.Geometry
// Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2020-2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@ -14,6 +16,8 @@
#include <boost/geometry/strategies/area/spherical.hpp>
#include <boost/geometry/strategies/azimuth/spherical.hpp>
#include <boost/geometry/strategies/buffer/spherical.hpp>
#include <boost/geometry/strategies/centroid/spherical.hpp>
#include <boost/geometry/strategies/closest_points/spherical.hpp>
#include <boost/geometry/strategies/convex_hull/spherical.hpp>
#include <boost/geometry/strategies/distance/spherical.hpp>
#include <boost/geometry/strategies/envelope/spherical.hpp>
@ -40,9 +44,10 @@ template
>
class spherical
// derived from the umbrella strategy defining the most strategies
: public strategies::index::detail::spherical<RadiusTypeOrSphere, CalculationType>
: public strategies::closest_points::spherical<RadiusTypeOrSphere, CalculationType>
, public strategies::centroid::detail::spherical
{
using base_t = strategies::index::detail::spherical<RadiusTypeOrSphere, CalculationType>;
using base_t = strategies::closest_points::spherical<RadiusTypeOrSphere, CalculationType>;
public:
spherical() = default;