1 // Boost.Geometry Index
5 // Copyright (c) 2019, Oracle and/or its affiliates.
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
12 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INDEX_HPP
13 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INDEX_HPP
16 #include <boost/geometry/strategies/geographic/distance.hpp>
17 #include <boost/geometry/strategies/geographic/distance_andoyer.hpp> // backward compatibility
18 #include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
19 #include <boost/geometry/strategies/geographic/distance_cross_track_point_box.hpp>
20 #include <boost/geometry/strategies/geographic/distance_segment_box.hpp>
21 #include <boost/geometry/strategies/geographic/distance_thomas.hpp> // backward compatibility
22 #include <boost/geometry/strategies/geographic/distance_vincenty.hpp> // backward compatibility
23 #include <boost/geometry/strategies/geographic/envelope_segment.hpp>
24 #include <boost/geometry/strategies/geographic/expand_segment.hpp>
25 #include <boost/geometry/strategies/geographic/intersection.hpp>
26 #include <boost/geometry/strategies/geographic/point_in_poly_winding.hpp>
28 #include <boost/geometry/strategies/spherical/index.hpp>
31 namespace boost { namespace geometry { namespace strategy { namespace index
36 typename FormulaPolicy = strategy::andoyer,
37 typename Spheroid = geometry::srs::spheroid<double>,
38 typename CalculationType = void
41 : spherical<CalculationType>
43 typedef geographic_tag cs_tag;
45 typedef geometry::strategy::envelope::geographic_segment
47 FormulaPolicy, Spheroid, CalculationType
48 > envelope_segment_strategy_type;
50 inline envelope_segment_strategy_type get_envelope_segment_strategy() const
52 return envelope_segment_strategy_type(m_spheroid);
55 typedef geometry::strategy::expand::geographic_segment
57 FormulaPolicy, Spheroid, CalculationType
58 > expand_segment_strategy_type;
60 inline expand_segment_strategy_type get_expand_segment_strategy() const
62 return expand_segment_strategy_type(m_spheroid);
65 // used in equals(Seg, Seg) but only to get_point_in_point_strategy()
66 typedef geometry::strategy::intersection::geographic_segments
69 // If index::geographic formula is derived from intersection::geographic_segments
70 // formula with different Order this may cause an inconsistency
71 strategy::default_order<FormulaPolicy>::value,
74 > relate_segment_segment_strategy_type;
76 inline relate_segment_segment_strategy_type get_relate_segment_segment_strategy() const
78 return relate_segment_segment_strategy_type(m_spheroid);
81 typedef geometry::strategy::distance::geographic
83 FormulaPolicy, Spheroid, CalculationType
84 > comparable_distance_point_point_strategy_type;
86 inline comparable_distance_point_point_strategy_type get_comparable_distance_point_point_strategy() const
88 return comparable_distance_point_point_strategy_type(m_spheroid);
91 typedef geometry::strategy::distance::geographic_cross_track_point_box
93 FormulaPolicy, Spheroid, CalculationType
94 > comparable_distance_point_box_strategy_type;
96 inline comparable_distance_point_box_strategy_type get_comparable_distance_point_box_strategy() const
98 return comparable_distance_point_box_strategy_type(m_spheroid);
101 typedef geometry::strategy::distance::geographic_cross_track
103 FormulaPolicy, Spheroid, CalculationType
104 > comparable_distance_point_segment_strategy_type;
106 inline comparable_distance_point_segment_strategy_type get_comparable_distance_point_segment_strategy() const
108 return comparable_distance_point_segment_strategy_type(m_spheroid);
111 typedef geometry::strategy::distance::geographic_segment_box
113 FormulaPolicy, Spheroid, CalculationType
114 > comparable_distance_segment_box_strategy_type;
116 inline comparable_distance_segment_box_strategy_type get_comparable_distance_segment_box_strategy() const
118 return comparable_distance_segment_box_strategy_type(m_spheroid);
125 explicit geographic(Spheroid const& spheroid)
126 : m_spheroid(spheroid)
137 template <typename Geometry>
138 struct default_strategy<Geometry, geographic_tag>
140 typedef geographic<> type;
144 // within and relate (MPt, Mls/MPoly)
145 template <typename Point1, typename Point2, typename Formula, typename Spheroid, typename CalculationType>
146 struct from_strategy<within::geographic_winding<Point1, Point2, Formula, Spheroid, CalculationType> >
148 typedef strategy::index::geographic<Formula, Spheroid, CalculationType> type;
150 static inline type get(within::geographic_winding<Point1, Point2, Formula, Spheroid, CalculationType> const& strategy)
152 return type(strategy.model());
156 // distance (MPt, MPt)
157 template <typename Formula, typename Spheroid, typename CalculationType>
158 struct from_strategy<distance::geographic<Formula, Spheroid, CalculationType> >
160 typedef strategy::index::geographic<Formula, Spheroid, CalculationType> type;
162 static inline type get(distance::geographic<Formula, Spheroid, CalculationType> const& strategy)
164 return type(strategy.model());
167 template <typename Spheroid, typename CalculationType>
168 struct from_strategy<distance::andoyer<Spheroid, CalculationType> >
170 typedef strategy::index::geographic<strategy::andoyer, Spheroid, CalculationType> type;
172 static inline type get(distance::andoyer<Spheroid, CalculationType> const& strategy)
174 return type(strategy.model());
177 template <typename Spheroid, typename CalculationType>
178 struct from_strategy<distance::thomas<Spheroid, CalculationType> >
180 typedef strategy::index::geographic<strategy::thomas, Spheroid, CalculationType> type;
182 static inline type get(distance::thomas<Spheroid, CalculationType> const& strategy)
184 return type(strategy.model());
187 template <typename Spheroid, typename CalculationType>
188 struct from_strategy<distance::vincenty<Spheroid, CalculationType> >
190 typedef strategy::index::geographic<strategy::vincenty, Spheroid, CalculationType> type;
192 static inline type get(distance::vincenty<Spheroid, CalculationType> const& strategy)
194 return type(strategy.model());
198 // distance (MPt, Linear/Areal)
199 template <typename Formula, typename Spheroid, typename CalculationType>
200 struct from_strategy<distance::geographic_cross_track<Formula, Spheroid, CalculationType> >
202 typedef strategy::index::geographic<Formula, Spheroid, CalculationType> type;
204 static inline type get(distance::geographic_cross_track<Formula, Spheroid, CalculationType> const& strategy)
206 return type(strategy.model());
211 } // namespace services
214 }}}} // namespace boost::geometry::strategy::index
216 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_INDEX_HPP