pj_ell_set.hpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // This file is manually converted from PROJ4
  3. // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // This file was modified by Oracle on 2017, 2018.
  5. // Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
  6. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. // This file is converted from PROJ4, http://trac.osgeo.org/proj
  11. // PROJ4 is originally written by Gerald Evenden (then of the USGS)
  12. // PROJ4 is maintained by Frank Warmerdam
  13. // PROJ4 is converted to Geometry Library by
  14. // Barend Gehrels (Geodan, Amsterdam)
  15. // Adam Wulkiewicz
  16. // Original copyright notice:
  17. // Permission is hereby granted, free of charge, to any person obtaining a
  18. // copy of this software and associated documentation files (the "Software"),
  19. // to deal in the Software without restriction, including without limitation
  20. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  21. // and/or sell copies of the Software, and to permit persons to whom the
  22. // Software is furnished to do so, subject to the following conditions:
  23. // The above copyright notice and this permission notice shall be included
  24. // in all copies or substantial portions of the Software.
  25. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  26. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  27. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  28. // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  29. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  30. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  31. // DEALINGS IN THE SOFTWARE.
  32. #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELL_SET_HPP
  33. #define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELL_SET_HPP
  34. #include <string>
  35. #include <vector>
  36. #include <boost/geometry/formulas/eccentricity_sqr.hpp>
  37. #include <boost/geometry/util/math.hpp>
  38. #include <boost/geometry/srs/projections/dpar.hpp>
  39. #include <boost/geometry/srs/projections/impl/pj_datum_set.hpp>
  40. #include <boost/geometry/srs/projections/impl/pj_ellps.hpp>
  41. #include <boost/geometry/srs/projections/impl/pj_param.hpp>
  42. #include <boost/geometry/srs/projections/proj4.hpp>
  43. #include <boost/geometry/srs/projections/spar.hpp>
  44. namespace boost { namespace geometry { namespace projections {
  45. namespace detail {
  46. /* set ellipsoid parameters a and es */
  47. template <typename T>
  48. inline T SIXTH() { return .1666666666666666667; } /* 1/6 */
  49. template <typename T>
  50. inline T RA4() { return .04722222222222222222; } /* 17/360 */
  51. template <typename T>
  52. inline T RA6() { return .02215608465608465608; } /* 67/3024 */
  53. template <typename T>
  54. inline T RV4() { return .06944444444444444444; } /* 5/72 */
  55. template <typename T>
  56. inline T RV6() { return .04243827160493827160; } /* 55/1296 */
  57. template <typename T>
  58. inline T pj_ell_b_to_es(T const& a, T const& b)
  59. {
  60. return 1. - (b * b) / (a * a);
  61. }
  62. /************************************************************************/
  63. /* pj_ell_init_ellps() */
  64. /************************************************************************/
  65. // Originally a part of pj_ell_set()
  66. template <typename T>
  67. inline bool pj_ell_init_ellps(srs::detail::proj4_parameters const& params, T &a, T &b)
  68. {
  69. /* check if ellps present and temporarily append its values to pl */
  70. std::string name = pj_get_param_s(params, "ellps");
  71. if (! name.empty())
  72. {
  73. const pj_ellps_type<T>* pj_ellps = pj_get_ellps<T>().first;
  74. const int n = pj_get_ellps<T>().second;
  75. int index = -1;
  76. for (int i = 0; i < n && index == -1; i++)
  77. {
  78. if(pj_ellps[i].id == name)
  79. {
  80. index = i;
  81. }
  82. }
  83. if (index == -1) {
  84. BOOST_THROW_EXCEPTION( projection_exception(error_unknown_ellp_param) );
  85. }
  86. pj_ellps_type<T> const& pj_ellp = pj_ellps[index];
  87. a = pj_ellp.a;
  88. b = pj_ellp.b;
  89. return true;
  90. }
  91. return false;
  92. }
  93. template <typename T>
  94. inline bool pj_ell_init_ellps(srs::dpar::parameters<T> const& params, T &a, T &b)
  95. {
  96. /* check if ellps present and temporarily append its values to pl */
  97. typename srs::dpar::parameters<T>::const_iterator
  98. it = pj_param_find(params, srs::dpar::ellps);
  99. if (it != params.end())
  100. {
  101. if (it->template is_value_set<int>())
  102. {
  103. const pj_ellps_type<T>* pj_ellps = pj_get_ellps<T>().first;
  104. const int n = pj_get_ellps<T>().second;
  105. int i = it->template get_value<int>();
  106. if (i < 0 || i >= n) {
  107. BOOST_THROW_EXCEPTION( projection_exception(error_unknown_ellp_param) );
  108. }
  109. pj_ellps_type<T> const& pj_ellp = pj_ellps[i];
  110. a = pj_ellp.a;
  111. b = pj_ellp.b;
  112. }
  113. else if (it->template is_value_set<T>())
  114. {
  115. a = it->template get_value<T>();
  116. b = a;
  117. }
  118. else if (it->template is_value_set<srs::spheroid<T> >())
  119. {
  120. srs::spheroid<T> const& s = it->template get_value<srs::spheroid<T> >();
  121. a = geometry::get_radius<0>(s);
  122. b = geometry::get_radius<2>(s);
  123. }
  124. else
  125. {
  126. BOOST_THROW_EXCEPTION( projection_exception(error_unknown_ellp_param) );
  127. }
  128. return true;
  129. }
  130. return false;
  131. }
  132. template
  133. <
  134. typename Params,
  135. int I = srs::spar::detail::tuples_find_index_if
  136. <
  137. Params,
  138. srs::spar::detail::is_param_tr<srs::spar::detail::ellps_traits>::pred
  139. >::value,
  140. int N = boost::tuples::length<Params>::value
  141. >
  142. struct pj_ell_init_ellps_static
  143. {
  144. template <typename T>
  145. static bool apply(Params const& params, T &a, T &b)
  146. {
  147. typedef typename boost::tuples::element<I, Params>::type param_type;
  148. typedef srs::spar::detail::ellps_traits<param_type> traits_type;
  149. typedef typename traits_type::template model_type<T>::type model_type;
  150. param_type const& param = boost::tuples::get<I>(params);
  151. model_type const& model = traits_type::template model<T>(param);
  152. a = geometry::get_radius<0>(model);
  153. b = geometry::get_radius<2>(model);
  154. return true;
  155. }
  156. };
  157. template <typename Params, int N>
  158. struct pj_ell_init_ellps_static<Params, N, N>
  159. {
  160. template <typename T>
  161. static bool apply(Params const& , T & , T & )
  162. {
  163. return false;
  164. }
  165. };
  166. template <typename T, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
  167. inline bool pj_ell_init_ellps(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& params,
  168. T &a, T &b)
  169. {
  170. return pj_ell_init_ellps_static
  171. <
  172. srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>
  173. >::apply(params, a, b);
  174. }
  175. /************************************************************************/
  176. /* pj_ell_init() */
  177. /************************************************************************/
  178. /* initialize geographic shape parameters */
  179. // This function works differently than the original pj_ell_set().
  180. // It doesn't push parameters defined in ellps into params list.
  181. // Instead it tries to use size (a, R) and shape (es, e, rf, f, b) parameters
  182. // and then if needed falls back to ellps, then to datum and then to the default WGS84
  183. template <typename Params, typename T>
  184. inline void pj_ell_init(Params const& params, T &a, T &es)
  185. {
  186. /* check for varying forms of ellipsoid input */
  187. a = es = 0.;
  188. /* R takes precedence */
  189. if (pj_param_f<srs::spar::r>(params, "R", srs::dpar::r, a)) {
  190. /* empty */
  191. } else { /* probable elliptical figure */
  192. // Set ellipsoid's size parameter
  193. a = pj_get_param_f<T, srs::spar::a>(params, "a", srs::dpar::a);
  194. bool is_a_set = a != 0.0;
  195. // Set ellipsoid's shape parameter
  196. T b = 0.0;
  197. bool is_ell_set = false;
  198. if (pj_param_f<srs::spar::es>(params, "es", srs::dpar::es, es)) {/* eccentricity squared */
  199. /* empty */
  200. is_ell_set = true;
  201. } else if (pj_param_f<srs::spar::e>(params, "e", srs::dpar::e, es)) { /* eccentricity */
  202. es = es * es;
  203. is_ell_set = true;
  204. } else if (pj_param_f<srs::spar::rf>(params, "rf", srs::dpar::rf, es)) { /* recip flattening */
  205. if (es == 0.0) {
  206. BOOST_THROW_EXCEPTION( projection_exception(error_rev_flattening_is_zero) );
  207. }
  208. es = 1./ es;
  209. es = es * (2. - es);
  210. is_ell_set = true;
  211. } else if (pj_param_f<srs::spar::f>(params, "f", srs::dpar::f, es)) { /* flattening */
  212. es = es * (2. - es);
  213. is_ell_set = true;
  214. } else if (pj_param_f<srs::spar::b>(params, "b", srs::dpar::b, b)) { /* minor axis */
  215. es = pj_ell_b_to_es(a, b);
  216. is_ell_set = true;
  217. } /* else es == 0. and sphere of radius a */
  218. // NOTE: Below when ellps is used to initialize a and es
  219. // b is not set because it only has sense together with a
  220. // but a could have been set separately before, e.g. consider passing:
  221. // a=1 ellps=airy (a=6377563.396 b=6356256.910)
  222. // after setting size parameter a and shape parameter from ellps
  223. // b has to be recalculated
  224. // If ellipsoid's parameters are not set directly
  225. // use ellps parameter
  226. if (! is_a_set || ! is_ell_set) {
  227. T ellps_a = 0, ellps_b = 0;
  228. if (pj_ell_init_ellps(params, ellps_a, ellps_b)) {
  229. if (! is_a_set) {
  230. a = ellps_a;
  231. is_a_set = true;
  232. }
  233. if (! is_ell_set) {
  234. es = pj_ell_b_to_es(ellps_a, ellps_b);
  235. is_ell_set = true;
  236. }
  237. }
  238. }
  239. // If ellipsoid's parameters are not set
  240. // use ellps defined by datum parameter
  241. if (! is_a_set || ! is_ell_set)
  242. {
  243. const pj_datums_type<T>* datum = pj_datum_find_datum<T>(params);
  244. if (datum != NULL)
  245. {
  246. pj_ellps_type<T> const& pj_ellp = pj_get_ellps<T>().first[datum->ellps];
  247. if (! is_a_set) {
  248. a = pj_ellp.a;
  249. is_a_set = true;
  250. }
  251. if (! is_ell_set) {
  252. es = pj_ell_b_to_es(pj_ellp.a, pj_ellp.b);
  253. is_ell_set = true;
  254. }
  255. }
  256. }
  257. // If ellipsoid's parameters are still not set
  258. // use default WGS84
  259. if ((! is_a_set || ! is_ell_set)
  260. && ! pj_get_param_b<srs::spar::no_defs>(params, "no_defs", srs::dpar::no_defs))
  261. {
  262. pj_ellps_type<T> const& pj_ellp = pj_get_ellps<T>().first[srs::dpar::ellps_wgs84];
  263. if (! is_a_set) {
  264. a = pj_ellp.a;
  265. is_a_set = true;
  266. }
  267. if (! is_ell_set) {
  268. es = pj_ell_b_to_es(pj_ellp.a, pj_ellp.b);
  269. is_ell_set = true;
  270. }
  271. }
  272. if (b == 0.0)
  273. b = a * sqrt(1. - es);
  274. /* following options turn ellipsoid into equivalent sphere */
  275. if (pj_get_param_b<srs::spar::r_au>(params, "R_A", srs::dpar::r_au)) { /* sphere--area of ellipsoid */
  276. a *= 1. - es * (SIXTH<T>() + es * (RA4<T>() + es * RA6<T>()));
  277. es = 0.;
  278. } else if (pj_get_param_b<srs::spar::r_v>(params, "R_V", srs::dpar::r_v)) { /* sphere--vol. of ellipsoid */
  279. a *= 1. - es * (SIXTH<T>() + es * (RV4<T>() + es * RV6<T>()));
  280. es = 0.;
  281. } else if (pj_get_param_b<srs::spar::r_a>(params, "R_a", srs::dpar::r_a)) { /* sphere--arithmetic mean */
  282. a = .5 * (a + b);
  283. es = 0.;
  284. } else if (pj_get_param_b<srs::spar::r_g>(params, "R_g", srs::dpar::r_g)) { /* sphere--geometric mean */
  285. a = sqrt(a * b);
  286. es = 0.;
  287. } else if (pj_get_param_b<srs::spar::r_h>(params, "R_h", srs::dpar::r_h)) { /* sphere--harmonic mean */
  288. a = 2. * a * b / (a + b);
  289. es = 0.;
  290. } else {
  291. T tmp;
  292. bool i = pj_param_r<srs::spar::r_lat_a>(params, "R_lat_a", srs::dpar::r_lat_a, tmp);
  293. if (i || /* sphere--arith. */
  294. pj_param_r<srs::spar::r_lat_g>(params, "R_lat_g", srs::dpar::r_lat_g, tmp)) { /* or geom. mean at latitude */
  295. tmp = sin(tmp);
  296. if (geometry::math::abs(tmp) > geometry::math::half_pi<T>()) {
  297. BOOST_THROW_EXCEPTION( projection_exception(error_ref_rad_larger_than_90) );
  298. }
  299. tmp = 1. - es * tmp * tmp;
  300. a *= i ? .5 * (1. - es + tmp) / ( tmp * sqrt(tmp)) :
  301. sqrt(1. - es) / tmp;
  302. es = 0.;
  303. }
  304. }
  305. }
  306. /* some remaining checks */
  307. if (es < 0.) {
  308. BOOST_THROW_EXCEPTION( projection_exception(error_es_less_than_zero) );
  309. }
  310. if (a <= 0.) {
  311. BOOST_THROW_EXCEPTION( projection_exception(error_major_axis_not_given) );
  312. }
  313. }
  314. template <typename Params>
  315. struct static_srs_tag_check_nonexpanded
  316. {
  317. typedef typename boost::mpl::if_c
  318. <
  319. srs::spar::detail::tuples_exists_if
  320. <
  321. Params, srs::spar::detail::is_param_t<srs::spar::r>::pred
  322. >::value
  323. || srs::spar::detail::tuples_exists_if
  324. <
  325. Params, srs::spar::detail::is_param<srs::spar::r_au>::pred
  326. >::value
  327. || srs::spar::detail::tuples_exists_if
  328. <
  329. Params, srs::spar::detail::is_param<srs::spar::r_v>::pred
  330. >::value
  331. || srs::spar::detail::tuples_exists_if
  332. <
  333. Params, srs::spar::detail::is_param<srs::spar::r_a>::pred
  334. >::value
  335. || srs::spar::detail::tuples_exists_if
  336. <
  337. Params, srs::spar::detail::is_param<srs::spar::r_g>::pred
  338. >::value
  339. || srs::spar::detail::tuples_exists_if
  340. <
  341. Params, srs::spar::detail::is_param<srs::spar::r_h>::pred
  342. >::value
  343. || srs::spar::detail::tuples_exists_if
  344. <
  345. Params, srs::spar::detail::is_param_t<srs::spar::r_lat_a>::pred
  346. >::value
  347. || srs::spar::detail::tuples_exists_if
  348. <
  349. Params, srs::spar::detail::is_param_t<srs::spar::r_lat_g>::pred
  350. >::value,
  351. srs_sphere_tag,
  352. // NOTE: The assumption here is that if the user defines either one of:
  353. // b, es, e, f, rf parameters then he wants to define spheroid, not sphere
  354. typename boost::mpl::if_c
  355. <
  356. srs::spar::detail::tuples_exists_if
  357. <
  358. Params, srs::spar::detail::is_param_t<srs::spar::b>::pred
  359. >::value
  360. || srs::spar::detail::tuples_exists_if
  361. <
  362. Params, srs::spar::detail::is_param_t<srs::spar::es>::pred
  363. >::value
  364. || srs::spar::detail::tuples_exists_if
  365. <
  366. Params, srs::spar::detail::is_param_t<srs::spar::e>::pred
  367. >::value
  368. || srs::spar::detail::tuples_exists_if
  369. <
  370. Params, srs::spar::detail::is_param_t<srs::spar::rf>::pred
  371. >::value
  372. || srs::spar::detail::tuples_exists_if
  373. <
  374. Params, srs::spar::detail::is_param_t<srs::spar::f>::pred
  375. >::value,
  376. srs_spheroid_tag,
  377. void
  378. >::type
  379. >::type type;
  380. };
  381. template <typename Params>
  382. struct static_srs_tag_check_ellps
  383. {
  384. typedef typename geometry::tag
  385. <
  386. typename srs::spar::detail::ellps_traits
  387. <
  388. typename srs::spar::detail::tuples_find_if
  389. <
  390. Params,
  391. srs::spar::detail::is_param_tr<srs::spar::detail::ellps_traits>::pred
  392. >::type
  393. >::template model_type<double>::type // dummy type
  394. >::type type;
  395. };
  396. template <typename Params>
  397. struct static_srs_tag_check_datum
  398. {
  399. typedef typename geometry::tag
  400. <
  401. typename srs::spar::detail::ellps_traits
  402. <
  403. typename srs::spar::detail::datum_traits
  404. <
  405. typename srs::spar::detail::tuples_find_if
  406. <
  407. Params,
  408. srs::spar::detail::is_param_tr<srs::spar::detail::datum_traits>::pred
  409. >::type
  410. >::ellps_type
  411. >::template model_type<double>::type // dummy type
  412. >::type type;
  413. };
  414. template
  415. <
  416. typename Params,
  417. typename NonExpandedTag = typename static_srs_tag_check_nonexpanded
  418. <
  419. Params
  420. >::type,
  421. typename EllpsTag = typename static_srs_tag_check_ellps
  422. <
  423. Params
  424. >::type,
  425. typename DatumTag = typename static_srs_tag_check_datum
  426. <
  427. Params
  428. >::type
  429. >
  430. struct static_srs_tag
  431. {
  432. // User passed one of the non-ellps, non-datum parameters
  433. typedef NonExpandedTag type;
  434. };
  435. template <typename Params, typename EllpsTag, typename DatumTag>
  436. struct static_srs_tag<Params, void, EllpsTag, DatumTag>
  437. {
  438. // User didn't pass neither one of the non-ellps, non-datum parameters
  439. // but passed ellps
  440. typedef EllpsTag type;
  441. };
  442. template <typename Params, typename DatumTag>
  443. struct static_srs_tag<Params, void, void, DatumTag>
  444. {
  445. // User didn't pass neither one of the non-ellps, non-datum parameters
  446. // nor ellps parameter but passed datum parameter
  447. typedef DatumTag type;
  448. };
  449. template <typename Params>
  450. struct static_srs_tag<Params, void, void, void>
  451. {
  452. // User didn't pass any parameter defining model
  453. // so use default or generate error
  454. typedef typename boost::mpl::if_c
  455. <
  456. srs::spar::detail::tuples_exists_if
  457. <
  458. Params, srs::spar::detail::is_param<srs::spar::no_defs>::pred
  459. >::value,
  460. void,
  461. srs_spheroid_tag // WGS84
  462. >::type type;
  463. static const bool is_found = ! boost::is_same<type, void>::value;
  464. BOOST_MPL_ASSERT_MSG((is_found), UNKNOWN_ELLP_PARAM, (Params));
  465. };
  466. template <typename T>
  467. inline void pj_calc_ellipsoid_params(parameters<T> & p, T const& a, T const& es) {
  468. /****************************************************************************************
  469. Calculate a large number of ancillary ellipsoidal parameters, in addition to
  470. the two traditional PROJ defining parameters: Semimajor axis, a, and the
  471. eccentricity squared, es.
  472. Most of these parameters are fairly cheap to compute in comparison to the overall
  473. effort involved in initializing a PJ object. They may, however, take a substantial
  474. part of the time taken in computing an individual point transformation.
  475. So by providing them up front, we can amortize the (already modest) cost over all
  476. transformations carried out over the entire lifetime of a PJ object, rather than
  477. incur that cost for every single transformation.
  478. Most of the parameter calculations here are based on the "angular eccentricity",
  479. i.e. the angle, measured from the semiminor axis, of a line going from the north
  480. pole to one of the foci of the ellipsoid - or in other words: The arc sine of the
  481. eccentricity.
  482. The formulae used are mostly taken from:
  483. Richard H. Rapp: Geometric Geodesy, Part I, (178 pp, 1991).
  484. Columbus, Ohio: Dept. of Geodetic Science
  485. and Surveying, Ohio State University.
  486. ****************************************************************************************/
  487. p.a = a;
  488. p.es = es;
  489. /* Compute some ancillary ellipsoidal parameters */
  490. if (p.e==0)
  491. p.e = sqrt(p.es); /* eccentricity */
  492. //p.alpha = asin (p.e); /* angular eccentricity */
  493. /* second eccentricity */
  494. //p.e2 = tan (p.alpha);
  495. //p.e2s = p.e2 * p.e2;
  496. /* third eccentricity */
  497. //p.e3 = (0!=p.alpha)? sin (p.alpha) / sqrt(2 - sin (p.alpha)*sin (p.alpha)): 0;
  498. //p.e3s = p.e3 * p.e3;
  499. /* flattening */
  500. //if (0==p.f)
  501. // p.f = 1 - cos (p.alpha); /* = 1 - sqrt (1 - PIN->es); */
  502. //p.rf = p.f != 0.0 ? 1.0/p.f: HUGE_VAL;
  503. /* second flattening */
  504. //p.f2 = (cos(p.alpha)!=0)? 1/cos (p.alpha) - 1: 0;
  505. //p.rf2 = p.f2 != 0.0 ? 1/p.f2: HUGE_VAL;
  506. /* third flattening */
  507. //p.n = pow (tan (p.alpha/2), 2);
  508. //p.rn = p.n != 0.0 ? 1/p.n: HUGE_VAL;
  509. /* ...and a few more */
  510. //if (0==p.b)
  511. // p.b = (1 - p.f)*p.a;
  512. //p.rb = 1. / p.b;
  513. p.ra = 1. / p.a;
  514. p.one_es = 1. - p.es;
  515. if (p.one_es == 0.) {
  516. BOOST_THROW_EXCEPTION( projection_exception(error_eccentricity_is_one) );
  517. }
  518. p.rone_es = 1./p.one_es;
  519. }
  520. } // namespace detail
  521. }}} // namespace boost::geometry::projections
  522. #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELL_SET_HPP