3 // Copyright (c) 2019, Oracle and/or its affiliates.
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_POINT_ORDER_HPP
11 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_POINT_ORDER_HPP
14 #include <boost/geometry/core/tags.hpp>
16 #include <boost/geometry/srs/spheroid.hpp>
18 #include <boost/geometry/strategies/geographic/parameters.hpp>
19 #include <boost/geometry/strategies/point_order.hpp>
20 #include <boost/geometry/strategies/spherical/point_in_point.hpp>
22 #include <boost/geometry/util/math.hpp>
23 #include <boost/geometry/util/select_calculation_type.hpp>
26 namespace boost { namespace geometry
29 namespace strategy { namespace point_order
34 typename FormulaPolicy = strategy::andoyer,
35 typename Spheroid = srs::spheroid<double>,
36 typename CalculationType = void
40 typedef azimuth_tag version_tag;
42 template <typename Geometry>
45 typedef typename geometry::select_calculation_type_alt
47 CalculationType, Geometry
54 explicit geographic(Spheroid const& spheroid)
55 : m_spheroid(spheroid)
58 template <typename Point>
59 inline bool apply(Point const& p1, Point const& p2,
60 typename result_type<Point>::type & azi,
61 typename result_type<Point>::type & razi) const
63 typedef typename result_type<Point>::type calc_t;
65 if (equals_point_point(p1, p2))
70 formula::result_inverse<calc_t> res = FormulaPolicy::template inverse
72 calc_t, false, true, true, false, false
73 >::apply(geometry::get_as_radian<0>(p1),
74 geometry::get_as_radian<1>(p1),
75 geometry::get_as_radian<0>(p2),
76 geometry::get_as_radian<1>(p2),
80 razi = res.reverse_azimuth;
85 template <typename Point>
86 inline typename result_type<Point>::type
87 apply(Point const& /*p0*/, Point const& /*p1*/, Point const& /*p2*/,
88 typename result_type<Point>::type const& azi1,
89 typename result_type<Point>::type const& azi2) const
91 // TODO: support poles
92 return math::longitude_distance_signed<radian>(azi1, azi2);
96 template <typename Point>
97 static bool equals_point_point(Point const& p0, Point const& p1)
99 return strategy::within::spherical_point_point::apply(p0, p1);
109 struct default_strategy<geographic_tag>
111 typedef geographic<> type;
114 } // namespace services
116 }} // namespace strategy::point_order
118 }} // namespace boost::geometry
120 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_POINT_ORDER_HPP