File indexing completed on 2025-01-18 09:36:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_POINT_ORDER_HPP
0011 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_POINT_ORDER_HPP
0012
0013
0014 #include <boost/geometry/core/tags.hpp>
0015
0016 #include <boost/geometry/srs/spheroid.hpp>
0017
0018 #include <boost/geometry/strategies/geographic/parameters.hpp>
0019 #include <boost/geometry/strategies/point_order.hpp>
0020 #include <boost/geometry/strategies/spherical/point_in_point.hpp>
0021
0022 #include <boost/geometry/util/math.hpp>
0023 #include <boost/geometry/util/select_calculation_type.hpp>
0024
0025
0026 namespace boost { namespace geometry
0027 {
0028
0029 namespace strategy { namespace point_order
0030 {
0031
0032 template
0033 <
0034 typename FormulaPolicy = strategy::andoyer,
0035 typename Spheroid = srs::spheroid<double>,
0036 typename CalculationType = void
0037 >
0038 struct geographic
0039 {
0040 typedef azimuth_tag version_tag;
0041
0042 template <typename Geometry>
0043 struct result_type
0044 {
0045 typedef typename geometry::select_calculation_type_alt
0046 <
0047 CalculationType, Geometry
0048 >::type type;
0049 };
0050
0051 geographic()
0052 {}
0053
0054 explicit geographic(Spheroid const& spheroid)
0055 : m_spheroid(spheroid)
0056 {}
0057
0058 template <typename Point>
0059 inline bool apply(Point const& p1, Point const& p2,
0060 typename result_type<Point>::type & azi,
0061 typename result_type<Point>::type & razi) const
0062 {
0063 typedef typename result_type<Point>::type calc_t;
0064
0065 if (equals_point_point(p1, p2))
0066 {
0067 return false;
0068 }
0069
0070 formula::result_inverse<calc_t> res = FormulaPolicy::template inverse
0071 <
0072 calc_t, false, true, true, false, false
0073 >::apply(geometry::get_as_radian<0>(p1),
0074 geometry::get_as_radian<1>(p1),
0075 geometry::get_as_radian<0>(p2),
0076 geometry::get_as_radian<1>(p2),
0077 m_spheroid);
0078
0079 azi = res.azimuth;
0080 razi = res.reverse_azimuth;
0081
0082 return true;
0083 }
0084
0085 template <typename Point>
0086 inline typename result_type<Point>::type
0087 apply(Point const& , Point const& , Point const& ,
0088 typename result_type<Point>::type const& azi1,
0089 typename result_type<Point>::type const& azi2) const
0090 {
0091
0092 return math::longitude_distance_signed<radian>(azi1, azi2);
0093 }
0094
0095 private:
0096 template <typename Point>
0097 static bool equals_point_point(Point const& p0, Point const& p1)
0098 {
0099 return strategy::within::spherical_point_point::apply(p0, p1);
0100 }
0101
0102 Spheroid m_spheroid;
0103 };
0104
0105 namespace services
0106 {
0107
0108 template <>
0109 struct default_strategy<geographic_tag>
0110 {
0111 typedef geographic<> type;
0112 };
0113
0114 }
0115
0116 }}
0117
0118 }}
0119
0120 #endif