File indexing completed on 2025-01-18 09:36:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_SEGMENT_BOX_HPP
0012 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_SEGMENT_BOX_HPP
0013
0014 #include <boost/geometry/srs/spheroid.hpp>
0015
0016 #include <boost/geometry/core/coordinate_promotion.hpp>
0017
0018 #include <boost/geometry/algorithms/detail/distance/segment_to_box.hpp>
0019
0020 #include <boost/geometry/strategies/distance.hpp>
0021 #include <boost/geometry/strategies/geographic/azimuth.hpp>
0022 #include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
0023 #include <boost/geometry/strategies/geographic/distance_cross_track_point_box.hpp>
0024 #include <boost/geometry/strategies/geographic/parameters.hpp>
0025 #include <boost/geometry/strategies/geographic/side.hpp>
0026 #include <boost/geometry/strategies/normalize.hpp>
0027 #include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
0028 #include <boost/geometry/strategies/spherical/distance_segment_box.hpp>
0029 #include <boost/geometry/strategies/spherical/point_in_point.hpp>
0030
0031 #include <boost/geometry/util/select_calculation_type.hpp>
0032
0033 namespace boost { namespace geometry
0034 {
0035
0036
0037 namespace strategy { namespace distance
0038 {
0039
0040 template
0041 <
0042 typename FormulaPolicy = strategy::andoyer,
0043 typename Spheroid = srs::spheroid<double>,
0044 typename CalculationType = void
0045 >
0046 struct geographic_segment_box
0047 {
0048 template <typename PointOfSegment, typename PointOfBox>
0049 struct return_type
0050 : promote_floating_point
0051 <
0052 typename select_calculation_type
0053 <
0054 PointOfSegment,
0055 PointOfBox,
0056 CalculationType
0057 >::type
0058 >
0059 {};
0060
0061 typedef geographic_tag cs_tag;
0062
0063
0064
0065 explicit geographic_segment_box(Spheroid const& spheroid = Spheroid())
0066 : m_spheroid(spheroid)
0067 {}
0068
0069 Spheroid model() const
0070 {
0071 return m_spheroid;
0072 }
0073
0074
0075
0076 template
0077 <
0078 typename LessEqual, typename ReturnType,
0079 typename SegmentPoint, typename BoxPoint,
0080 typename Strategies
0081 >
0082 inline ReturnType segment_below_of_box(SegmentPoint const& p0,
0083 SegmentPoint const& p1,
0084 BoxPoint const& top_left,
0085 BoxPoint const& top_right,
0086 BoxPoint const& bottom_left,
0087 BoxPoint const& bottom_right,
0088 Strategies const& strategies) const
0089 {
0090 return generic_segment_box::segment_below_of_box
0091 <
0092 LessEqual,
0093 ReturnType
0094 >(p0,p1,top_left,top_right,bottom_left,bottom_right,
0095 strategies);
0096 }
0097
0098 template <typename SPoint, typename BPoint>
0099 static void mirror(SPoint& p0,
0100 SPoint& p1,
0101 BPoint& bottom_left,
0102 BPoint& bottom_right,
0103 BPoint& top_left,
0104 BPoint& top_right)
0105 {
0106
0107 generic_segment_box::mirror(p0, p1,
0108 bottom_left, bottom_right,
0109 top_left, top_right);
0110 }
0111
0112 private :
0113 Spheroid m_spheroid;
0114 };
0115
0116 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0117 namespace services
0118 {
0119
0120
0121
0122 template <typename FormulaPolicy>
0123 struct tag<geographic_segment_box<FormulaPolicy> >
0124 {
0125 typedef strategy_tag_distance_segment_box type;
0126 };
0127
0128 template
0129 <
0130 typename FormulaPolicy,
0131 typename Spheroid
0132 >
0133 struct tag<geographic_segment_box<FormulaPolicy, Spheroid> >
0134 {
0135 typedef strategy_tag_distance_segment_box type;
0136 };
0137
0138 template
0139 <
0140 typename FormulaPolicy,
0141 typename Spheroid,
0142 typename CalculationType
0143 >
0144 struct tag<geographic_segment_box<FormulaPolicy, Spheroid, CalculationType> >
0145 {
0146 typedef strategy_tag_distance_segment_box type;
0147 };
0148
0149
0150
0151 template <typename FormulaPolicy, typename PS, typename PB>
0152 struct return_type<geographic_segment_box<FormulaPolicy>, PS, PB>
0153 : geographic_segment_box<FormulaPolicy>::template return_type<PS, PB>
0154 {};
0155
0156 template
0157 <
0158 typename FormulaPolicy,
0159 typename Spheroid,
0160 typename PS,
0161 typename PB
0162 >
0163 struct return_type<geographic_segment_box<FormulaPolicy, Spheroid>, PS, PB>
0164 : geographic_segment_box<FormulaPolicy, Spheroid>::template return_type<PS, PB>
0165 {};
0166
0167 template
0168 <
0169 typename FormulaPolicy,
0170 typename Spheroid,
0171 typename CalculationType,
0172 typename PS,
0173 typename PB
0174 >
0175 struct return_type<geographic_segment_box<FormulaPolicy, Spheroid, CalculationType>, PS, PB>
0176 : geographic_segment_box<FormulaPolicy, Spheroid, CalculationType>::template return_type<PS, PB>
0177 {};
0178
0179
0180
0181 template
0182 <
0183 typename FormulaPolicy,
0184 typename Spheroid,
0185 typename CalculationType
0186 >
0187 struct comparable_type<geographic_segment_box<FormulaPolicy, Spheroid, CalculationType> >
0188 {
0189 typedef geographic_segment_box
0190 <
0191 FormulaPolicy, Spheroid, CalculationType
0192 > type;
0193 };
0194
0195 template
0196 <
0197 typename FormulaPolicy,
0198 typename Spheroid,
0199 typename CalculationType
0200 >
0201 struct get_comparable<geographic_segment_box<FormulaPolicy, Spheroid, CalculationType> >
0202 {
0203 typedef typename comparable_type
0204 <
0205 geographic_segment_box<FormulaPolicy, Spheroid, CalculationType>
0206 >::type comparable_type;
0207 public :
0208 static inline comparable_type
0209 apply(geographic_segment_box<FormulaPolicy, Spheroid, CalculationType> const& )
0210 {
0211 return comparable_type();
0212 }
0213 };
0214
0215
0216
0217 template
0218 <
0219 typename FormulaPolicy,
0220 typename PS,
0221 typename PB
0222 >
0223 struct result_from_distance<geographic_segment_box<FormulaPolicy>, PS, PB>
0224 {
0225 private :
0226 typedef typename geographic_segment_box
0227 <
0228 FormulaPolicy
0229 >::template return_type<PS, PB>::type return_type;
0230 public :
0231 template <typename T>
0232 static inline return_type
0233 apply(geographic_segment_box<FormulaPolicy> const& , T const& distance)
0234 {
0235 return distance;
0236 }
0237 };
0238
0239 template
0240 <
0241 typename FormulaPolicy,
0242 typename Spheroid,
0243 typename CalculationType,
0244 typename PS,
0245 typename PB
0246 >
0247 struct result_from_distance<geographic_segment_box<FormulaPolicy, Spheroid, CalculationType>, PS, PB>
0248 {
0249 private :
0250 typedef typename geographic_segment_box
0251 <
0252 FormulaPolicy, Spheroid, CalculationType
0253 >::template return_type<PS, PB>::type return_type;
0254 public :
0255 template <typename T>
0256 static inline return_type
0257 apply(geographic_segment_box<FormulaPolicy, Spheroid, CalculationType> const& , T const& distance)
0258 {
0259 return distance;
0260 }
0261 };
0262
0263
0264
0265
0266 template <typename Segment, typename Box>
0267 struct default_strategy
0268 <
0269 segment_tag, box_tag, Segment, Box,
0270 geographic_tag, geographic_tag
0271 >
0272 {
0273 typedef geographic_segment_box<> type;
0274 };
0275
0276 template <typename Box, typename Segment>
0277 struct default_strategy
0278 <
0279 box_tag, segment_tag, Box, Segment,
0280 geographic_tag, geographic_tag
0281 >
0282 {
0283 typedef typename default_strategy
0284 <
0285 segment_tag, box_tag, Segment, Box,
0286 geographic_tag, geographic_tag
0287 >::type type;
0288 };
0289
0290 }
0291 #endif
0292
0293 }}
0294
0295 }}
0296 #endif