123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- #ifndef BOOST_GEOMETRY_ALGORITHMS_AZIMUTH_HPP
- #define BOOST_GEOMETRY_ALGORITHMS_AZIMUTH_HPP
- #include <boost/geometry/algorithms/not_implemented.hpp>
- #include <boost/geometry/core/radian_access.hpp>
- #include <boost/geometry/core/tag.hpp>
- #include <boost/geometry/geometries/concepts/check.hpp>
- #include <boost/geometry/strategies/default_strategy.hpp>
- #include <boost/geometry/strategies/azimuth/cartesian.hpp>
- #include <boost/geometry/strategies/azimuth/geographic.hpp>
- #include <boost/geometry/strategies/azimuth/spherical.hpp>
- namespace boost { namespace geometry
- {
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail
- {
- }
- #endif
- #ifndef DOXYGEN_NO_DISPATCH
- namespace dispatch
- {
- template
- <
- typename Geometry1, typename Geometry2,
- typename Tag1 = typename tag<Geometry1>::type,
- typename Tag2 = typename tag<Geometry2>::type
- >
- struct azimuth : not_implemented<Tag1, Tag2>
- {};
- template <typename Point1, typename Point2>
- struct azimuth<Point1, Point2, point_tag, point_tag>
- {
- template <typename Strategy>
- static auto apply(Point1 const& p1, Point2 const& p2, Strategy const& strategy)
- {
- typedef typename decltype(strategy.azimuth())::template result_type
- <
- typename coordinate_type<Point1>::type,
- typename coordinate_type<Point2>::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);
-
-
-
-
- return result;
- }
- };
- }
- #endif
- namespace resolve_strategy
- {
- template
- <
- typename Strategy,
- bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
- >
- struct azimuth
- {
- template <typename P1, typename P2>
- static auto apply(P1 const& p1, P2 const& p2, Strategy const& strategy)
- {
- return dispatch::azimuth<P1, P2>::apply(p1, p2, strategy);
- }
- };
- template <typename Strategy>
- struct azimuth<Strategy, false>
- {
- template <typename P1, typename P2>
- 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<Strategy>::get(strategy));
- }
- };
- template <>
- struct azimuth<default_strategy, false>
- {
- template <typename P1, typename P2>
- 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<P1, P2>::apply(p1, p2, strategy_type());
- }
- };
- }
- namespace resolve_variant
- {
- }
- template <typename Point1, typename Point2>
- inline auto azimuth(Point1 const& point1, Point2 const& point2)
- {
- concepts::check<Point1 const>();
- concepts::check<Point2 const>();
- return resolve_strategy::azimuth
- <
- default_strategy
- >::apply(point1, point2, default_strategy());
- }
- template <typename Point1, typename Point2, typename Strategy>
- inline auto azimuth(Point1 const& point1, Point2 const& point2, Strategy const& strategy)
- {
- concepts::check<Point1 const>();
- concepts::check<Point2 const>();
- return resolve_strategy::azimuth<Strategy>::apply(point1, point2, strategy);
- }
- }}
- #endif
|