Added thirdparty: boost library

This commit is contained in:
Viacheslav Demydiuk
2024-01-06 19:55:56 +02:00
parent bf49f439e1
commit bccd1e7051
15683 changed files with 3239840 additions and 0 deletions
@@ -0,0 +1,238 @@
// Boost.Geometry
// Copyright (c) 2021, 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_DISTANCE_BACKWARD_COMPATIBILITY_HPP
#define BOOST_GEOMETRY_STRATEGIES_DISTANCE_BACKWARD_COMPATIBILITY_HPP
#include <boost/geometry/strategies/distance/cartesian.hpp>
#include <boost/geometry/strategies/distance/comparable.hpp>
#include <boost/geometry/strategies/distance/detail.hpp>
#include <boost/geometry/strategies/distance/geographic.hpp>
#include <boost/geometry/strategies/distance/spherical.hpp>
namespace boost { namespace geometry
{
namespace strategies { namespace distance
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
template
<
typename Strategy,
typename CSTag,
typename StrategyTag = typename strategy::distance::services::tag<Strategy>::type
>
struct custom_strategy
{
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
"Not implemented for this Strategy.",
Strategy);
};
// NOTES:
// - There is no guarantee that any of the custom strategies are compatible with other
// strategies.
// - In many cases it is not possible to pass the custom strategy into other strategies.
// - The old backward compatibility code creating default Pt/Seg strategy from custom
// Pt/Pt strategy worked the same way. The custom strategy is default-created.
// - There are two versions of algorithm for Polyseg/Box, one for Seg/Box strategy the
// other one for Pt/Seg strategy. However there is only one version of algorithm for
// Seg/Box taking Seg/Box strategy.
// - Geographic strategies are default-created which means WGS84 spheroid is used.
// - Currently only Pt/Pt custom strategies are supported because this is what the old
// backward compatibility code was addressing.
template <typename Strategy>
struct custom_strategy<Strategy, cartesian_tag, strategy_tag_distance_point_point>
: cartesian<>
{
custom_strategy(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
{
return m_strategy;
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_ps_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::projected_point<void, Strategy>();
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_pb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::pythagoras_point_box<>();
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_sb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::cartesian_segment_box<void, Strategy>();
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_bb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::pythagoras_box_box<>();
}
private:
Strategy const& m_strategy;
};
template <typename Strategy>
struct custom_strategy<Strategy, spherical_tag, strategy_tag_distance_point_point>
: detail::spherical<void, void>
{
custom_strategy(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
{
return m_strategy;
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_ps_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::cross_track<void, Strategy>(m_strategy);
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_pb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::cross_track_point_box<void, Strategy>(m_strategy);
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_sb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::spherical_segment_box<void, Strategy>(m_strategy);
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_bb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::cross_track_box_box<void, Strategy>(m_strategy);
}
private:
Strategy const& m_strategy;
};
template <typename Strategy>
struct custom_strategy<Strategy, geographic_tag, strategy_tag_distance_point_point>
: geographic<>
{
custom_strategy(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
{
return m_strategy;
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_ps_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::geographic_cross_track<>();
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_pb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::geographic_cross_track_point_box<>();
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_sb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::geographic_segment_box<>();
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
enable_if_bb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::geographic_cross_track_box_box<>();
}
private:
Strategy const& m_strategy;
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
namespace services
{
template <typename Geometry1, typename Geometry2, typename Strategy>
struct custom_strategy_converter<Geometry1, Geometry2, Strategy, cartesian_tag, cartesian_tag>
{
static auto get(Strategy const& strategy)
{
return detail::custom_strategy<Strategy, cartesian_tag>(strategy);
}
};
template <typename Geometry1, typename Geometry2, typename Strategy>
struct custom_strategy_converter<Geometry1, Geometry2, Strategy, spherical_equatorial_tag, spherical_equatorial_tag>
{
static auto get(Strategy const& strategy)
{
return detail::custom_strategy<Strategy, spherical_tag>(strategy);
}
};
template <typename Geometry1, typename Geometry2, typename Strategy>
struct custom_strategy_converter<Geometry1, Geometry2, Strategy, geographic_tag, geographic_tag>
{
static auto get(Strategy const& strategy)
{
return detail::custom_strategy<Strategy, geographic_tag>(strategy);
}
};
} // namespace services
}} // namespace strategies::distance
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_BACKWARD_COMPATIBILITY_HPP
+175
View File
@@ -0,0 +1,175 @@
// Boost.Geometry
// Copyright (c) 2021, 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_DISTANCE_CARTESIAN_HPP
#define BOOST_GEOMETRY_STRATEGIES_DISTANCE_CARTESIAN_HPP
//#include <boost/geometry/strategies/cartesian/azimuth.hpp>
#include <boost/geometry/strategies/cartesian/distance_projected_point.hpp>
#include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
#include <boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp>
#include <boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp>
#include <boost/geometry/strategies/cartesian/distance_segment_box.hpp>
#include <boost/geometry/strategies/detail.hpp>
#include <boost/geometry/strategies/distance/comparable.hpp>
#include <boost/geometry/strategies/distance/detail.hpp>
#include <boost/geometry/strategies/distance/services.hpp>
//#include <boost/geometry/strategies/normalize.hpp>
#include <boost/geometry/strategies/relate/cartesian.hpp>
#include <boost/geometry/util/type_traits.hpp>
namespace boost { namespace geometry
{
namespace strategies { namespace distance
{
template <typename CalculationType = void>
struct cartesian
: public strategies::relate::cartesian<CalculationType>
{
template <typename Geometry1, typename Geometry2>
static auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr)
{
return strategy::distance::pythagoras<CalculationType>();
}
template <typename Geometry1, typename Geometry2>
static auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_ps_t<Geometry1, Geometry2> * = nullptr)
{
return strategy::distance::projected_point
<
CalculationType,
strategy::distance::pythagoras<CalculationType>
>();
}
template <typename Geometry1, typename Geometry2>
static auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_pb_t<Geometry1, Geometry2> * = nullptr)
{
return strategy::distance::pythagoras_point_box<CalculationType>();
}
template <typename Geometry1, typename Geometry2>
static auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_sb_t<Geometry1, Geometry2> * = nullptr)
{
return strategy::distance::cartesian_segment_box
<
CalculationType,
strategy::distance::pythagoras<CalculationType>
>();
}
template <typename Geometry1, typename Geometry2>
static auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_bb_t<Geometry1, Geometry2> * = nullptr)
{
return strategy::distance::pythagoras_box_box<CalculationType>();
}
};
namespace services
{
template <typename Geometry1, typename Geometry2>
struct default_strategy<Geometry1, Geometry2, cartesian_tag, cartesian_tag>
{
using type = strategies::distance::cartesian<>;
};
template <typename CT>
struct strategy_converter<strategy::distance::pythagoras<CT> >
{
template <typename S>
static auto get(S const&)
{
return strategies::distance::cartesian<CT>();
}
};
template <typename CT, typename PPS>
struct strategy_converter<strategy::distance::projected_point<CT, PPS> >
: strategy_converter<PPS>
{};
template <typename CT>
struct strategy_converter<strategy::distance::pythagoras_point_box<CT> >
{
static auto get(strategy::distance::pythagoras_point_box<CT> const&)
{
return strategies::distance::cartesian<CT>();
}
};
template <typename CT, typename PPS>
struct strategy_converter<strategy::distance::cartesian_segment_box<CT, PPS> >
: strategy_converter<PPS>
{};
template <typename CT>
struct strategy_converter<strategy::distance::pythagoras_box_box<CT> >
{
static auto get(strategy::distance::pythagoras_box_box<CT> const&)
{
return strategies::distance::cartesian<CT>();
}
};
template <typename CT>
struct strategy_converter<strategy::distance::comparable::pythagoras<CT> >
{
template <typename S>
static auto get(S const&)
{
return strategies::distance::detail::make_comparable(
strategies::distance::cartesian<CT>());
}
};
template <typename CT>
struct strategy_converter<strategy::distance::comparable::pythagoras_point_box<CT> >
{
static auto get(strategy::distance::comparable::pythagoras_point_box<CT> const&)
{
return strategies::distance::detail::make_comparable(
strategies::distance::cartesian<CT>());
}
};
template <typename CT>
struct strategy_converter<strategy::distance::comparable::pythagoras_box_box<CT> >
{
static auto get(strategy::distance::comparable::pythagoras_box_box<CT> const&)
{
return strategies::distance::detail::make_comparable(
strategies::distance::cartesian<CT>());
}
};
} // namespace services
}} // namespace strategies::distance
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_CARTESIAN_HPP
+63
View File
@@ -0,0 +1,63 @@
// Boost.Geometry
// Copyright (c) 2021, 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_DISTANCE_COMPARABLE_HPP
#define BOOST_GEOMETRY_STRATEGIES_DISTANCE_COMPARABLE_HPP
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/core/static_assert.hpp>
#include <boost/geometry/strategies/distance.hpp>
namespace boost { namespace geometry
{
namespace strategies { namespace distance
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
template <typename Strategies>
struct comparable
: public Strategies
{
comparable() = default;
explicit comparable(Strategies const& strategies)
: Strategies(strategies)
{}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const& g1, Geometry2 const& g2) const
{
return strategy::distance::services::get_comparable
<
decltype(Strategies::distance(g1, g2))
>::apply(Strategies::distance(g1, g2));
}
};
template <typename Strategies>
inline comparable<Strategies> make_comparable(Strategies const& strategies)
{
return comparable<Strategies>(strategies);
}
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
}} // namespace strategies::distance
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_COMPARABLE_HPP
+66
View File
@@ -0,0 +1,66 @@
// Boost.Geometry
// Copyright (c) 2021, 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_DISTANCE_DETAIL_HPP
#define BOOST_GEOMETRY_STRATEGIES_DISTANCE_DETAIL_HPP
#include <boost/geometry/util/type_traits.hpp>
namespace boost { namespace geometry
{
namespace strategies { namespace distance
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
template <typename Geometry1, typename Geometry2>
using enable_if_pp_t = std::enable_if_t
<
util::is_pointlike<Geometry1>::value && util::is_pointlike<Geometry2>::value
>;
template <typename Geometry1, typename Geometry2>
using enable_if_ps_t = std::enable_if_t
<
(util::is_pointlike<Geometry1>::value && util::is_segmental<Geometry2>::value)
|| (util::is_segmental<Geometry1>::value && util::is_pointlike<Geometry2>::value)
|| (util::is_segmental<Geometry1>::value && util::is_segmental<Geometry2>::value)
>;
template <typename Geometry1, typename Geometry2>
using enable_if_pb_t = std::enable_if_t
<
util::is_pointlike<Geometry1>::value && util::is_box<Geometry2>::value
>;
template <typename Geometry1, typename Geometry2>
using enable_if_sb_t = std::enable_if_t
<
util::is_segmental<Geometry1>::value && util::is_box<Geometry2>::value
>;
template <typename Geometry1, typename Geometry2>
using enable_if_bb_t = std::enable_if_t
<
util::is_box<Geometry1>::value && util::is_box<Geometry2>::value
>;
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
}} // namespace strategies::distance
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_DETAIL_HPP
+260
View File
@@ -0,0 +1,260 @@
// Boost.Geometry
// Copyright (c) 2021, 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_DISTANCE_GEOGRAPHIC_HPP
#define BOOST_GEOMETRY_STRATEGIES_DISTANCE_GEOGRAPHIC_HPP
#include <boost/geometry/strategies/distance/comparable.hpp>
#include <boost/geometry/strategies/distance/detail.hpp>
#include <boost/geometry/strategies/distance/services.hpp>
#include <boost/geometry/strategies/detail.hpp>
#include <boost/geometry/strategies/geographic/azimuth.hpp>
#include <boost/geometry/strategies/geographic/distance.hpp>
#include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
#include <boost/geometry/strategies/geographic/distance_cross_track_box_box.hpp>
#include <boost/geometry/strategies/geographic/distance_cross_track_point_box.hpp>
#include <boost/geometry/strategies/geographic/distance_segment_box.hpp>
// TODO - for backwards compatibility, remove?
#include <boost/geometry/strategies/geographic/distance_andoyer.hpp>
#include <boost/geometry/strategies/geographic/distance_thomas.hpp>
#include <boost/geometry/strategies/geographic/distance_vincenty.hpp>
#include <boost/geometry/strategies/normalize.hpp>
#include <boost/geometry/strategies/relate/geographic.hpp>
namespace boost { namespace geometry
{
namespace strategies { namespace distance
{
// TODO: azimuth and normalize getters would not be needed if distance_segment_box was implemented differently
// right now it calls disjoint algorithm details.
template
<
typename FormulaPolicy = strategy::andoyer,
typename Spheroid = srs::spheroid<double>,
typename CalculationType = void
>
class geographic
: public strategies::relate::geographic<FormulaPolicy, Spheroid, CalculationType>
{
using base_t = strategies::relate::geographic<FormulaPolicy, Spheroid, CalculationType>;
public:
geographic() = default;
explicit geographic(Spheroid const& spheroid)
: base_t(spheroid)
{}
// azimuth
auto azimuth() const
{
return strategy::azimuth::geographic
<
FormulaPolicy, Spheroid, CalculationType
>(base_t::m_spheroid);
}
// distance
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::geographic
<
FormulaPolicy, Spheroid, CalculationType
>(base_t::m_spheroid);
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_ps_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::geographic_cross_track
<
FormulaPolicy, Spheroid, CalculationType
>(base_t::m_spheroid);
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_pb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::geographic_cross_track_point_box
<
FormulaPolicy, Spheroid, CalculationType
>(base_t::m_spheroid);
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_sb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::geographic_segment_box
<
FormulaPolicy, Spheroid, CalculationType
>(base_t::m_spheroid);
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_bb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::geographic_cross_track_box_box
<
FormulaPolicy, Spheroid, CalculationType
>(base_t::m_spheroid);
}
// normalize
template <typename Geometry>
static auto normalize(Geometry const&,
std::enable_if_t
<
util::is_point<Geometry>::value
> * = nullptr)
{
return strategy::normalize::spherical_point();
}
};
namespace services
{
template <typename Geometry1, typename Geometry2>
struct default_strategy<Geometry1, Geometry2, geographic_tag, geographic_tag>
{
using type = strategies::distance::geographic<>;
};
template <typename FP, typename S, typename CT>
struct strategy_converter<strategy::distance::geographic<FP, S, CT> >
{
static auto get(strategy::distance::geographic<FP, S, CT> const& s)
{
return strategies::distance::geographic<FP, S, CT>(s.model());
}
};
// TODO - for backwards compatibility, remove?
template <typename S, typename CT>
struct strategy_converter<strategy::distance::andoyer<S, CT> >
{
static auto get(strategy::distance::andoyer<S, CT> const& s)
{
return strategies::distance::geographic<strategy::andoyer, S, CT>(s.model());
}
};
// TODO - for backwards compatibility, remove?
template <typename S, typename CT>
struct strategy_converter<strategy::distance::thomas<S, CT> >
{
static auto get(strategy::distance::thomas<S, CT> const& s)
{
return strategies::distance::geographic<strategy::thomas, S, CT>(s.model());
}
};
// TODO - for backwards compatibility, remove?
template <typename S, typename CT>
struct strategy_converter<strategy::distance::vincenty<S, CT> >
{
static auto get(strategy::distance::vincenty<S, CT> const& s)
{
return strategies::distance::geographic<strategy::vincenty, S, CT>(s.model());
}
};
template <typename FP, typename S, typename CT>
struct strategy_converter<strategy::distance::geographic_cross_track<FP, S, CT> >
{
static auto get(strategy::distance::geographic_cross_track<FP, S, CT> const& s)
{
return strategies::distance::geographic<FP, S, CT>(s.model());
}
};
template <typename FP, typename S, typename CT>
struct strategy_converter<strategy::distance::geographic_cross_track_point_box<FP, S, CT> >
{
static auto get(strategy::distance::geographic_cross_track_point_box<FP, S, CT> const& s)
{
return strategies::distance::geographic<FP, S, CT>(s.model());
}
};
template <typename FP, typename S, typename CT>
struct strategy_converter<strategy::distance::geographic_segment_box<FP, S, CT> >
{
static auto get(strategy::distance::geographic_segment_box<FP, S, CT> const& s)
{
return strategies::distance::geographic<FP, S, CT>(s.model());
}
};
template <typename FP, typename S, typename CT>
struct strategy_converter<strategy::distance::geographic_cross_track_box_box<FP, S, CT> >
{
static auto get(strategy::distance::geographic_cross_track_box_box<FP, S, CT> const& s)
{
return strategies::distance::geographic<FP, S, CT>(s.model());
}
};
// details
// TODO: This specialization wouldn't be needed if strategy::distance::geographic_cross_track was implemented as an alias
template <typename FP, typename S, typename CT, bool B, bool ECP>
struct strategy_converter<strategy::distance::detail::geographic_cross_track<FP, S, CT, B, ECP> >
{
struct altered_strategy
: strategies::distance::geographic<FP, S, CT>
{
typedef strategies::distance::geographic<FP, S, CT> base_t;
explicit altered_strategy(S const& s) : base_t(s) {}
using base_t::distance;
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_ps_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::detail::geographic_cross_track
<
FP, S, CT, B, ECP
>(base_t::m_spheroid);
}
};
static auto get(strategy::distance::detail::geographic_cross_track<FP, S, CT, B, ECP> const& s)
{
return altered_strategy(s.model());
}
};
} // namespace services
}} // namespace strategies::distance
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_GEOGRAPHIC_HPP
+74
View File
@@ -0,0 +1,74 @@
// Boost.Geometry
// Copyright (c) 2021, 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_DISTANCE_SERVICES_HPP
#define BOOST_GEOMETRY_STRATEGIES_DISTANCE_SERVICES_HPP
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/core/static_assert.hpp>
#include <boost/geometry/strategies/detail.hpp>
namespace boost { namespace geometry
{
namespace strategies { namespace distance
{
namespace services
{
template
<
typename Geometry1,
typename Geometry2,
typename CSTag1 = typename geometry::cs_tag<Geometry1>::type,
typename CSTag2 = typename geometry::cs_tag<Geometry2>::type
>
struct default_strategy
{
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
"Not implemented for these Geometries' coordinate systems.",
Geometry1, Geometry2, CSTag1, CSTag2);
};
template <typename Strategy>
struct strategy_converter
{
static auto get(Strategy const&)
{
return strategies::detail::not_implemented();
}
};
template
<
typename Geometry1,
typename Geometry2,
typename Strategy,
typename CSTag1 = typename geometry::cs_tag<Geometry1>::type,
typename CSTag2 = typename geometry::cs_tag<Geometry2>::type
>
struct custom_strategy_converter
{
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
"Not implemented for this Strategy.",
Strategy);
};
} // namespace services
}} // namespace strategies::distance
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_SERVICES_HPP
+227
View File
@@ -0,0 +1,227 @@
// Boost.Geometry
// Copyright (c) 2021, 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_DISTANCE_SPHERICAL_HPP
#define BOOST_GEOMETRY_STRATEGIES_DISTANCE_SPHERICAL_HPP
#include <boost/geometry/strategies/distance/comparable.hpp>
#include <boost/geometry/strategies/distance/detail.hpp>
#include <boost/geometry/strategies/distance/services.hpp>
#include <boost/geometry/strategies/detail.hpp>
#include <boost/geometry/strategies/normalize.hpp>
#include <boost/geometry/strategies/relate/spherical.hpp>
#include <boost/geometry/strategies/spherical/azimuth.hpp>
#include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
#include <boost/geometry/strategies/spherical/distance_cross_track_box_box.hpp>
#include <boost/geometry/strategies/spherical/distance_cross_track_point_box.hpp>
#include <boost/geometry/strategies/spherical/distance_haversine.hpp>
#include <boost/geometry/strategies/spherical/distance_segment_box.hpp>
namespace boost { namespace geometry
{
namespace strategies { namespace distance
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
// TODO: azimuth and normalize getters would not be needed if distance_segment_box was implemented differently
// right now it calls disjoint algorithm details.
template <typename RadiusTypeOrSphere, typename CalculationType>
class spherical
: public strategies::relate::detail::spherical<RadiusTypeOrSphere, CalculationType>
{
using base_t = strategies::relate::detail::spherical<RadiusTypeOrSphere, CalculationType>;
public:
spherical() = default;
template <typename RadiusOrSphere>
explicit spherical(RadiusOrSphere const& radius_or_sphere)
: base_t(radius_or_sphere)
{}
// azimuth
static auto azimuth()
{
return strategy::azimuth::spherical<CalculationType>();
}
// distance
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::haversine
<
typename base_t::radius_type, CalculationType
>(base_t::radius());
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_ps_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::cross_track
<
CalculationType,
strategy::distance::haversine<typename base_t::radius_type, CalculationType>
>(base_t::radius());
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_pb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::cross_track_point_box
<
CalculationType,
strategy::distance::haversine<typename base_t::radius_type, CalculationType>
>(base_t::radius());
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_sb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::spherical_segment_box
<
CalculationType,
strategy::distance::haversine<typename base_t::radius_type, CalculationType>
>(base_t::radius());
}
template <typename Geometry1, typename Geometry2>
auto distance(Geometry1 const&, Geometry2 const&,
detail::enable_if_bb_t<Geometry1, Geometry2> * = nullptr) const
{
return strategy::distance::cross_track_box_box
<
CalculationType,
strategy::distance::haversine<typename base_t::radius_type, CalculationType>
>(base_t::radius());
}
// normalize
template <typename Geometry>
static auto normalize(Geometry const&,
std::enable_if_t
<
util::is_point<Geometry>::value
> * = nullptr)
{
return strategy::normalize::spherical_point();
}
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
template
<
typename RadiusTypeOrSphere = double,
typename CalculationType = void
>
class spherical
: public strategies::distance::detail::spherical<RadiusTypeOrSphere, CalculationType>
{
using base_t = strategies::distance::detail::spherical<RadiusTypeOrSphere, CalculationType>;
public:
spherical() = default;
template <typename RadiusOrSphere>
explicit spherical(RadiusOrSphere const& radius_or_sphere)
: base_t(radius_or_sphere)
{}
};
namespace services
{
template <typename Geometry1, typename Geometry2>
struct default_strategy
<
Geometry1, Geometry2,
spherical_equatorial_tag, spherical_equatorial_tag
>
{
using type = strategies::distance::spherical<>;
};
template <typename R, typename CT>
struct strategy_converter<strategy::distance::haversine<R, CT> >
{
template <typename S>
static auto get(S const& s)
{
return strategies::distance::spherical<R, CT>(s.radius());
}
};
template <typename CT, typename PPS>
struct strategy_converter<strategy::distance::cross_track<CT, PPS> >
: strategy_converter<PPS>
{};
template <typename CT, typename PPS>
struct strategy_converter<strategy::distance::cross_track_point_box<CT, PPS> >
: strategy_converter<PPS>
{};
template <typename CT, typename PPS>
struct strategy_converter<strategy::distance::spherical_segment_box<CT, PPS> >
: strategy_converter<PPS>
{};
template <typename CT, typename PPS>
struct strategy_converter<strategy::distance::cross_track_box_box<CT, PPS> >
: strategy_converter<PPS>
{};
template <typename R, typename CT>
struct strategy_converter<strategy::distance::comparable::haversine<R, CT> >
{
template <typename S>
static auto get(S const& s)
{
return strategies::distance::detail::make_comparable(
strategies::distance::spherical<R, CT>(s.radius()));
}
};
template <typename CT, typename PPS>
struct strategy_converter<strategy::distance::comparable::cross_track<CT, PPS> >
: strategy_converter<PPS>
{};
} // namespace services
}} // namespace strategies::distance
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_SPHERICAL_HPP