File indexing completed on 2025-01-18 09:36:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_GEOMETRY_STRATEGIES_CENTROID_CARTESIAN_HPP
0011 #define BOOST_GEOMETRY_STRATEGIES_CENTROID_CARTESIAN_HPP
0012
0013
0014 #include <boost/geometry/strategies/cartesian/centroid_average.hpp>
0015 #include <boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp>
0016 #include <boost/geometry/strategies/cartesian/centroid_weighted_length.hpp>
0017
0018 #include <boost/geometry/strategies/detail.hpp>
0019 #include <boost/geometry/strategies/centroid/services.hpp>
0020
0021 #include <boost/geometry/util/type_traits.hpp>
0022
0023
0024 namespace boost { namespace geometry
0025 {
0026
0027 namespace strategies { namespace centroid
0028 {
0029
0030 template <typename CalculationType = void>
0031 struct cartesian
0032 : public strategies::detail::cartesian_base
0033 {
0034 template <typename Geometry>
0035 static auto centroid(Geometry const&,
0036 std::enable_if_t
0037 <
0038 util::is_pointlike<Geometry>::value
0039 > * = nullptr)
0040 {
0041 return strategy::centroid::average<>();
0042 }
0043
0044 template <typename Geometry>
0045 static auto centroid(Geometry const&,
0046 std::enable_if_t
0047 <
0048 util::is_polylinear<Geometry>::value
0049 > * = nullptr)
0050 {
0051 return strategy::centroid::weighted_length<void, void, CalculationType>();
0052 }
0053
0054 template <typename Geometry>
0055 static auto centroid(Geometry const&,
0056 std::enable_if_t
0057 <
0058 util::is_polygonal<Geometry>::value
0059
0060
0061 > * = nullptr)
0062 {
0063 return strategy::centroid::bashein_detmer<void, void, CalculationType>();
0064 }
0065
0066
0067 template <typename Geometry, typename Point>
0068 static auto centroid(Geometry const&, Point const&,
0069 std::enable_if_t
0070 <
0071 util::is_segment<Geometry>::value
0072 || util::is_box<Geometry>::value
0073 > * = nullptr)
0074 {
0075 return strategy::centroid::not_applicable_strategy();
0076 }
0077 };
0078
0079
0080 namespace services
0081 {
0082
0083 template <typename Geometry>
0084 struct default_strategy<Geometry, cartesian_tag>
0085 {
0086 using type = strategies::centroid::cartesian<>;
0087 };
0088
0089
0090 template <typename PC, typename PG>
0091 struct strategy_converter<strategy::centroid::average<PC, PG> >
0092 {
0093 static auto get(strategy::centroid::average<PC, PG> const&)
0094 {
0095 return strategies::centroid::cartesian<>();
0096 }
0097 };
0098
0099 template <typename PC, typename PG>
0100 struct strategy_converter<strategy::centroid::weighted_length<PC, PG> >
0101 {
0102 static auto get(strategy::centroid::weighted_length<PC, PG> const&)
0103 {
0104 return strategies::centroid::cartesian<>();
0105 }
0106 };
0107
0108 template <typename PC, typename PG, typename CT>
0109 struct strategy_converter<strategy::centroid::bashein_detmer<PC, PG, CT> >
0110 {
0111 static auto get(strategy::centroid::bashein_detmer<PC, PG, CT> const&)
0112 {
0113 return strategies::centroid::cartesian<CT>();
0114 }
0115 };
0116
0117 }
0118
0119 }}
0120
0121 }}
0122
0123 #endif