]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/projections/par4.hpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / par4.hpp
1 // Boost.Geometry
2
3 // Copyright (c) 2017-2018, Oracle and/or its affiliates.
4 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
5
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10 #ifndef BOOST_GEOMETRY_SRS_PROJECTIONS_PAR4_HPP
11 #define BOOST_GEOMETRY_SRS_PROJECTIONS_PAR4_HPP
12
13
14 #include <boost/geometry/core/tag.hpp>
15 #include <boost/geometry/core/tags.hpp>
16
17 #include <boost/geometry/srs/sphere.hpp>
18 #include <boost/geometry/srs/spheroid.hpp>
19
20 #include <boost/mpl/assert.hpp>
21 #include <boost/mpl/if.hpp>
22 #include <boost/tuple/tuple.hpp>
23 #include <boost/type_traits/integral_constant.hpp>
24 #include <boost/type_traits/is_same.hpp>
25 #include <boost/type_traits/is_void.hpp>
26
27
28 namespace boost { namespace geometry { namespace srs { namespace par4
29 {
30
31 // proj
32 // defined in projections' implementation files
33
34 // ellps
35 struct MERIT {};
36 struct SGS85 {};
37 struct GRS80 {};
38 struct IAU76 {};
39 struct airy {};
40 struct APL4_9 {};
41 struct NWL9D {};
42 struct mod_airy {};
43 struct andrae {};
44 struct aust_SA {};
45 struct GRS67 {};
46 struct bessel {};
47 struct bess_nam {};
48 struct clrk66 {};
49 struct clrk80 {};
50 struct clrk80ign {};
51 struct CPM {};
52 struct delmbr {};
53 struct engelis {};
54 struct evrst30 {};
55 struct evrst48 {};
56 struct evrst56 {};
57 struct evrst69 {};
58 struct evrstSS {};
59 struct fschr60 {};
60 struct fschr60m {};
61 struct fschr68 {};
62 struct helmert {};
63 struct hough {};
64 struct intl {};
65 struct krass {};
66 struct kaula {};
67 struct lerch {};
68 struct mprts {};
69 struct new_intl {};
70 struct plessis {};
71 struct SEasia {};
72 struct walbeck {};
73 struct WGS60 {};
74 struct WGS66 {};
75 struct WGS72 {};
76 struct WGS84 {};
77 struct sphere {};
78
79 // datum
80 //struct WGS84 {}; // already defined above
81 struct GGRS87 {};
82 struct NAD83 {};
83 struct NAD27 {};
84 struct potsdam {};
85 struct carthage {};
86 struct hermannskogel {};
87 struct ire65 {};
88 struct nzgd49 {};
89 struct OSGB36 {};
90
91 template <typename P>
92 struct proj
93 {
94 typedef P type;
95 };
96
97 #ifndef DOXYGEN_NO_DETAIL
98 namespace detail
99 {
100
101 template
102 <
103 typename E,
104 typename Tag = typename geometry::tag<E>::type
105 >
106 struct ellps_impl
107 : private E // empty base optimization
108 {
109 typedef E type;
110
111 ellps_impl() : E() {}
112 explicit ellps_impl(E const& e) : E(e) {}
113
114 E const& model() const { return *this; }
115 };
116
117 template <typename E>
118 struct ellps_impl<E, void>
119 {
120 typedef E type;
121 };
122
123 } // namespace detail
124 #endif // DOXYGEN_NO_DETAIL
125
126 template<typename E>
127 struct ellps
128 : par4::detail::ellps_impl<E>
129 {
130 ellps() {}
131 explicit ellps(E const& e)
132 : par4::detail::ellps_impl<E>(e)
133 {}
134 };
135
136 template <typename D>
137 struct datum
138 {
139 typedef D type;
140 };
141
142 template <typename P>
143 struct o_proj
144 {
145 typedef P type;
146 };
147
148 struct guam {};
149
150 #ifndef DOXYGEN_NO_DETAIL
151 namespace detail
152 {
153
154 inline double b_from_a_rf(double a, double rf)
155 {
156 return a * (1.0 - 1.0 / rf);
157 }
158
159 template
160 <
161 typename Ellps,
162 typename Tag = typename geometry::tag<typename Ellps::type>::type
163 >
164 struct ellps_traits
165 {
166 typedef typename Ellps::type model_type;
167 static model_type model(Ellps const& e) { return e.model(); }
168 };
169
170 #define BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_B(NAME, A, B) \
171 template <> \
172 struct ellps_traits<ellps<par4::NAME>, void> \
173 { \
174 typedef srs::spheroid<double> model_type; \
175 static model_type model(ellps<par4::NAME> const&) { return model_type(A, B); } \
176 };
177
178 #define BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(NAME, A, RF) \
179 template <> \
180 struct ellps_traits<ellps<par4::NAME>, void> \
181 { \
182 typedef srs::spheroid<double> model_type; \
183 static model_type model(ellps<par4::NAME> const&) { return model_type(A, b_from_a_rf(A, RF)); } \
184 };
185
186 #define BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_SPHERE(NAME, R) \
187 template <> \
188 struct ellps_traits<ellps<par4::NAME>, void> \
189 { \
190 typedef srs::sphere<double> model_type; \
191 static model_type model(ellps<par4::NAME> const&) { return model_type(R); } \
192 };
193
194 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(MERIT, 6378137.0, 298.257)
195 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(SGS85, 6378136.0, 298.257)
196 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(GRS80, 6378137.0, 298.257222101)
197 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(IAU76, 6378140.0, 298.257)
198 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_B (airy, 6377563.396, 6356256.910)
199 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(APL4_9, 6378137.0, 298.25)
200 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(NWL9D, 6378145.0, 298.25)
201 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_B (mod_airy, 6377340.189, 6356034.446)
202 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(andrae, 6377104.43, 300.0)
203 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(aust_SA, 6378160.0, 298.25)
204 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(GRS67, 6378160.0, 298.2471674270)
205 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(bessel, 6377397.155, 299.1528128)
206 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(bess_nam, 6377483.865, 299.1528128)
207 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_B (clrk66, 6378206.4, 6356583.8)
208 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(clrk80, 6378249.145, 293.4663)
209 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(clrk80ign, 6378249.2, 293.4660212936269)
210 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(CPM, 6375738.7, 334.29)
211 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(delmbr, 6376428.0, 311.5)
212 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(engelis, 6378136.05, 298.2566)
213 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(evrst30, 6377276.345, 300.8017)
214 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(evrst48, 6377304.063, 300.8017)
215 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(evrst56, 6377301.243, 300.8017)
216 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(evrst69, 6377295.664, 300.8017)
217 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(evrstSS, 6377298.556, 300.8017)
218 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(fschr60, 6378166.0, 298.3)
219 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(fschr60m, 6378155.0, 298.3)
220 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(fschr68, 6378150.0, 298.3)
221 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(helmert, 6378200.0, 298.3)
222 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(hough, 6378270.0, 297.0)
223 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(intl, 6378388.0, 297.0)
224 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(krass, 6378245.0, 298.3)
225 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(kaula, 6378163.0, 298.24)
226 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(lerch, 6378139.0, 298.257)
227 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(mprts, 6397300.0, 191.0)
228 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_B (new_intl, 6378157.5, 6356772.2)
229 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_B (plessis, 6376523.0, 6355863.0)
230 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_B (SEasia, 6378155.0, 6356773.3205)
231 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_B (walbeck, 6376896.0, 6355834.8467)
232 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(WGS60, 6378165.0, 298.3)
233 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(WGS66, 6378145.0, 298.25)
234 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(WGS72, 6378135.0, 298.26)
235 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_ELLPS_A_RF(WGS84, 6378137.0, 298.257223563)
236 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_SPHERE (sphere, 6370997.0)
237
238
239 template <typename D>
240 struct datum_traits
241 {
242 typedef void ellps_type;
243 static std::string id() { return ""; }
244 static std::string definition() { return ""; }
245 };
246
247 #define BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_DATUM(NAME, ID, ELLPS, DEF) \
248 template <> \
249 struct datum_traits< datum<par4::NAME> > \
250 { \
251 typedef par4::ellps<par4::ELLPS> ellps_type; \
252 static std::string id() { return ID; } \
253 static std::string definition() { return DEF; } \
254 };
255
256 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_DATUM(WGS84, "WGS84", WGS84, "towgs84=0,0,0")
257 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_DATUM(GGRS87, "GGRS87", GRS80, "towgs84=-199.87,74.79,246.62")
258 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_DATUM(NAD83, "NAD83", GRS80, "towgs84=0,0,0")
259 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_DATUM(NAD27, "NAD27", clrk66, "nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat")
260 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_DATUM(potsdam, "potsdam", bessel, "towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7")
261 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_DATUM(carthage, "carthage", clrk80ign, "towgs84=-263.0,6.0,431.0")
262 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_DATUM(hermannskogel, "hermannskogel", bessel, "towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232")
263 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_DATUM(ire65, "ire65", mod_airy, "towgs84=482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15")
264 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_DATUM(nzgd49, "nzgd49", intl, "towgs84=59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993")
265 BOOST_GEOMETRY_PROJECTIONS_DETAIL_REGISTER_DATUM(OSGB36, "OSGB36", airy, "towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894")
266
267
268 template
269 <
270 typename Tuple,
271 template <typename> class IsSamePred,
272 int I = 0,
273 int N = boost::tuples::length<Tuple>::value
274 >
275 struct tuples_find_index_if
276 : boost::mpl::if_c
277 <
278 IsSamePred<typename boost::tuples::element<I, Tuple>::type>::value,
279 boost::integral_constant<int, I>,
280 typename tuples_find_index_if<Tuple, IsSamePred, I+1, N>::type
281 >::type
282 {};
283
284 template
285 <
286 typename Tuple,
287 template <typename> class IsSamePred,
288 int N
289 >
290 struct tuples_find_index_if<Tuple, IsSamePred, N, N>
291 : boost::integral_constant<int, N>
292 {};
293
294 template
295 <
296 typename Tuple,
297 template <typename> class IsSamePred,
298 int I = tuples_find_index_if<Tuple, IsSamePred>::value,
299 int N = boost::tuples::length<Tuple>::value
300 >
301 struct tuples_find_if
302 : boost::tuples::element<I, Tuple>
303 {};
304
305 template
306 <
307 typename Tuple,
308 template <typename> class IsSamePred,
309 int N
310 >
311 struct tuples_find_if<Tuple, IsSamePred, N, N>
312 {
313 typedef void type;
314 };
315
316 /*template <typename Param>
317 struct is_param
318 {
319 template <typename T, int D = 0>
320 struct is_same_impl : boost::false_type {};
321 template <int D>
322 struct is_same_impl<Param, D> : boost::true_type {};
323
324 template <typename T>
325 struct is_same : is_same_impl<T> {};
326 };
327
328 template <template <typename> class Param>
329 struct is_param_t
330 {
331 template <typename T>
332 struct is_same : boost::false_type {};
333 template <typename T>
334 struct is_same<Param<T> > : boost::true_type {};
335 };*/
336
337 // NOTE: The following metafunctions are implemented one for each parameter
338 // because mingw-gcc-4.1.2 is unable to compile a solution based on template
339 // template parameter and member struct template partial specialization
340 // (see above).
341
342 /*template <typename T>
343 struct is_proj : boost::false_type {};
344 template <typename T>
345 struct is_proj<proj<T> > : boost::true_type {};
346
347 template <typename T>
348 struct is_ellps : boost::false_type {};
349 template <typename T>
350 struct is_ellps<ellps<T> > : boost::true_type {};
351
352 template <typename T>
353 struct is_datum : boost::false_type {};
354 template <typename T>
355 struct is_datum<datum<T> > : boost::true_type {};
356
357 template <typename T>
358 struct is_o_proj : boost::false_type {};
359 template <typename T>
360 struct is_o_proj<o_proj<T> > : boost::true_type {};
361
362 template <typename T>
363 struct is_guam : boost::false_type {};
364 template <>
365 struct is_guam<guam> : boost::true_type {};*/
366
367 // NOTE: The following implementation seems to work as well.
368
369 // TEST
370
371 template <typename T, template <typename> class Param>
372 struct is_same_t : boost::false_type {};
373 template <typename T, template <typename> class Param>
374 struct is_same_t<Param<T>, Param> : boost::true_type {};
375
376 template <typename Param>
377 struct is_param
378 {
379 template <typename T>
380 struct pred : boost::is_same<T, Param> {};
381 };
382
383 template <template <typename> class Param>
384 struct is_param_t
385 {
386 template <typename T>
387 struct pred : is_same_t<T, Param> {};
388 };
389
390 // pick proj static name
391
392 template <typename Tuple>
393 struct pick_proj_tag
394 {
395 typedef typename tuples_find_if
396 <
397 Tuple,
398 // is_proj
399 is_param_t<proj>::pred
400 >::type proj_type;
401
402 static const bool is_non_void = ! boost::is_void<proj_type>::value;
403
404 BOOST_MPL_ASSERT_MSG((is_non_void), PROJECTION_NOT_NAMED, (Tuple));
405
406 typedef typename proj_type::type type;
407 };
408
409
410 template <typename Ellps, typename Datum, int EllpsIndex>
411 struct pick_ellps_impl
412 {
413 typedef Ellps type;
414 typedef typename ellps_traits<Ellps>::model_type model_type;
415 template <typename Tuple>
416 static model_type model(Tuple const& tup)
417 {
418 return ellps_traits<Ellps>::model(boost::get<EllpsIndex>(tup));
419 }
420 };
421
422 template <typename Ellps, int EllpsIndex>
423 struct pick_ellps_impl<Ellps, void, EllpsIndex>
424 {
425 typedef Ellps type;
426 typedef typename ellps_traits<Ellps>::model_type model_type;
427 template <typename Tuple>
428 static model_type model(Tuple const& tup)
429 {
430 return ellps_traits<Ellps>::model(boost::get<EllpsIndex>(tup));
431 }
432 };
433
434 template <typename Datum, int EllpsIndex>
435 struct pick_ellps_impl<void, Datum, EllpsIndex>
436 {
437 typedef typename datum_traits<Datum>::ellps_type type;
438
439 static const bool is_datum_known = ! boost::is_void<type>::value;
440 BOOST_MPL_ASSERT_MSG((is_datum_known), UNKNOWN_DATUM, (types<Datum>));
441
442 typedef typename ellps_traits<type>::model_type model_type;
443 template <typename Tuple>
444 static model_type model(Tuple const& )
445 {
446 return ellps_traits<type>::model(type());
447 }
448 };
449
450 template <int EllpsIndex>
451 struct pick_ellps_impl<void, void, EllpsIndex>
452 {
453 // default ellipsoid
454 typedef ellps<WGS84> type;
455 typedef typename ellps_traits<type>::model_type model_type;
456 template <typename Tuple>
457 static model_type model(Tuple const& )
458 {
459 return ellps_traits<type>::model(type());
460 }
461 };
462
463 // Pick spheroid/sphere model from ellps or datum
464 // mimic pj_init() calling pj_datum_set() and pj_ell_set()
465 template <typename Tuple>
466 struct pick_ellps
467 : pick_ellps_impl
468 <
469 typename tuples_find_if<Tuple, /*is_ellps*/is_param_t<ellps>::pred>::type,
470 typename tuples_find_if<Tuple, /*is_datum*/is_param_t<datum>::pred>::type,
471 tuples_find_index_if<Tuple, /*is_ellps*/is_param_t<ellps>::pred>::value
472 >
473 {};
474
475
476 template <typename Tuple>
477 struct pick_o_proj_tag
478 {
479 typedef typename tuples_find_if
480 <
481 Tuple,
482 //is_o_proj
483 is_param_t<o_proj>::pred
484 >::type proj_type;
485
486 static const bool is_non_void = ! boost::is_void<proj_type>::value;
487
488 BOOST_MPL_ASSERT_MSG((is_non_void), PROJECTION_NOT_NAMED, (Tuple));
489
490 typedef typename proj_type::type type;
491 };
492
493
494 } // namespace detail
495 #endif // DOXYGEN_NO_DETAIL
496
497
498 }}}} // namespace boost::geometry::srs::par4
499
500
501 #endif // BOOST_GEOMETRY_SRS_PROJECTIONS_PAR4_HPP