aeqd.hpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. // Boost.Geometry - gis-projections (based on PROJ4)
  2. // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // This file was modified by Oracle on 2017, 2018.
  4. // Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
  5. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
  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. // This file is converted from PROJ4, http://trac.osgeo.org/proj
  10. // PROJ4 is originally written by Gerald Evenden (then of the USGS)
  11. // PROJ4 is maintained by Frank Warmerdam
  12. // PROJ4 is converted to Boost.Geometry by Barend Gehrels
  13. // Last updated version of proj: 5.0.0
  14. // Original copyright notice:
  15. // Purpose: Implementation of the aeqd (Azimuthal Equidistant) projection.
  16. // Author: Gerald Evenden
  17. // Copyright (c) 1995, Gerald Evenden
  18. // Permission is hereby granted, free of charge, to any person obtaining a
  19. // copy of this software and associated documentation files (the "Software"),
  20. // to deal in the Software without restriction, including without limitation
  21. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  22. // and/or sell copies of the Software, and to permit persons to whom the
  23. // Software is furnished to do so, subject to the following conditions:
  24. // The above copyright notice and this permission notice shall be included
  25. // in all copies or substantial portions of the Software.
  26. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  27. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  28. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  29. // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  30. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  31. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  32. // DEALINGS IN THE SOFTWARE.
  33. #ifndef BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP
  34. #define BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP
  35. #include <boost/config.hpp>
  36. #include <boost/geometry/formulas/vincenty_direct.hpp>
  37. #include <boost/geometry/formulas/vincenty_inverse.hpp>
  38. #include <boost/geometry/srs/projections/impl/aasincos.hpp>
  39. #include <boost/geometry/srs/projections/impl/base_static.hpp>
  40. #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
  41. #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
  42. #include <boost/geometry/srs/projections/impl/pj_mlfn.hpp>
  43. #include <boost/geometry/srs/projections/impl/pj_param.hpp>
  44. #include <boost/geometry/srs/projections/impl/projects.hpp>
  45. #include <boost/geometry/util/math.hpp>
  46. #include <boost/math/special_functions/hypot.hpp>
  47. #include <boost/type_traits/is_same.hpp>
  48. namespace boost { namespace geometry
  49. {
  50. namespace projections
  51. {
  52. #ifndef DOXYGEN_NO_DETAIL
  53. namespace detail { namespace aeqd
  54. {
  55. static const double epsilon10 = 1.e-10;
  56. static const double tolerance = 1.e-14;
  57. enum mode_type {
  58. n_pole = 0,
  59. s_pole = 1,
  60. equit = 2,
  61. obliq = 3
  62. };
  63. template <typename T>
  64. struct par_aeqd
  65. {
  66. T sinph0;
  67. T cosph0;
  68. detail::en<T> en;
  69. T M1;
  70. T N1;
  71. T Mp;
  72. T He;
  73. T G;
  74. mode_type mode;
  75. srs::spheroid<T> spheroid;
  76. };
  77. template <typename T, typename Par, typename ProjParm>
  78. inline void e_forward(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y, Par const& par, ProjParm const& proj_parm)
  79. {
  80. T coslam, cosphi, sinphi, rho;
  81. //T azi1, s12;
  82. //T lam1, phi1, lam2, phi2;
  83. coslam = cos(lp_lon);
  84. cosphi = cos(lp_lat);
  85. sinphi = sin(lp_lat);
  86. switch (proj_parm.mode) {
  87. case n_pole:
  88. coslam = - coslam;
  89. BOOST_FALLTHROUGH;
  90. case s_pole:
  91. xy_x = (rho = fabs(proj_parm.Mp - pj_mlfn(lp_lat, sinphi, cosphi, proj_parm.en))) *
  92. sin(lp_lon);
  93. xy_y = rho * coslam;
  94. break;
  95. case equit:
  96. case obliq:
  97. if (fabs(lp_lon) < epsilon10 && fabs(lp_lat - par.phi0) < epsilon10) {
  98. xy_x = xy_y = 0.;
  99. break;
  100. }
  101. //phi1 = par.phi0; lam1 = par.lam0;
  102. //phi2 = lp_lat; lam2 = lp_lon + par.lam0;
  103. formula::result_inverse<T> const inv =
  104. formula::vincenty_inverse
  105. <
  106. T, true, true
  107. >::apply(par.lam0, par.phi0, lp_lon + par.lam0, lp_lat, proj_parm.spheroid);
  108. //azi1 = inv.azimuth; s12 = inv.distance;
  109. xy_x = inv.distance * sin(inv.azimuth) / par.a;
  110. xy_y = inv.distance * cos(inv.azimuth) / par.a;
  111. break;
  112. }
  113. }
  114. template <typename T, typename Par, typename ProjParm>
  115. inline void e_inverse(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat, Par const& par, ProjParm const& proj_parm)
  116. {
  117. T c;
  118. if ((c = boost::math::hypot(xy_x, xy_y)) < epsilon10) {
  119. lp_lat = par.phi0;
  120. lp_lon = 0.;
  121. return;
  122. }
  123. if (proj_parm.mode == obliq || proj_parm.mode == equit) {
  124. T const x2 = xy_x * par.a;
  125. T const y2 = xy_y * par.a;
  126. //T const lat1 = par.phi0;
  127. //T const lon1 = par.lam0;
  128. T const azi1 = atan2(x2, y2);
  129. T const s12 = sqrt(x2 * x2 + y2 * y2);
  130. formula::result_direct<T> const dir =
  131. formula::vincenty_direct
  132. <
  133. T, true
  134. >::apply(par.lam0, par.phi0, s12, azi1, proj_parm.spheroid);
  135. lp_lat = dir.lat2;
  136. lp_lon = dir.lon2;
  137. lp_lon -= par.lam0;
  138. } else { /* Polar */
  139. lp_lat = pj_inv_mlfn(proj_parm.mode == n_pole ? proj_parm.Mp - c : proj_parm.Mp + c,
  140. par.es, proj_parm.en);
  141. lp_lon = atan2(xy_x, proj_parm.mode == n_pole ? -xy_y : xy_y);
  142. }
  143. }
  144. template <typename T, typename Par, typename ProjParm>
  145. inline void e_guam_fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y, Par const& par, ProjParm const& proj_parm)
  146. {
  147. T cosphi, sinphi, t;
  148. cosphi = cos(lp_lat);
  149. sinphi = sin(lp_lat);
  150. t = 1. / sqrt(1. - par.es * sinphi * sinphi);
  151. xy_x = lp_lon * cosphi * t;
  152. xy_y = pj_mlfn(lp_lat, sinphi, cosphi, proj_parm.en) - proj_parm.M1 +
  153. .5 * lp_lon * lp_lon * cosphi * sinphi * t;
  154. }
  155. template <typename T, typename Par, typename ProjParm>
  156. inline void e_guam_inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat, Par const& par, ProjParm const& proj_parm)
  157. {
  158. T x2, t = 0.0;
  159. int i;
  160. x2 = 0.5 * xy_x * xy_x;
  161. lp_lat = par.phi0;
  162. for (i = 0; i < 3; ++i) {
  163. t = par.e * sin(lp_lat);
  164. lp_lat = pj_inv_mlfn(proj_parm.M1 + xy_y -
  165. x2 * tan(lp_lat) * (t = sqrt(1. - t * t)), par.es, proj_parm.en);
  166. }
  167. lp_lon = xy_x * t / cos(lp_lat);
  168. }
  169. template <typename T, typename Par, typename ProjParm>
  170. inline void s_forward(T const& lp_lon, T lp_lat, T& xy_x, T& xy_y, Par const& /*par*/, ProjParm const& proj_parm)
  171. {
  172. static const T half_pi = detail::half_pi<T>();
  173. T coslam, cosphi, sinphi;
  174. sinphi = sin(lp_lat);
  175. cosphi = cos(lp_lat);
  176. coslam = cos(lp_lon);
  177. switch (proj_parm.mode) {
  178. case equit:
  179. xy_y = cosphi * coslam;
  180. goto oblcon;
  181. case obliq:
  182. xy_y = proj_parm.sinph0 * sinphi + proj_parm.cosph0 * cosphi * coslam;
  183. oblcon:
  184. if (fabs(fabs(xy_y) - 1.) < tolerance)
  185. if (xy_y < 0.)
  186. BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) );
  187. else
  188. xy_x = xy_y = 0.;
  189. else {
  190. xy_y = acos(xy_y);
  191. xy_y /= sin(xy_y);
  192. xy_x = xy_y * cosphi * sin(lp_lon);
  193. xy_y *= (proj_parm.mode == equit) ? sinphi :
  194. proj_parm.cosph0 * sinphi - proj_parm.sinph0 * cosphi * coslam;
  195. }
  196. break;
  197. case n_pole:
  198. lp_lat = -lp_lat;
  199. coslam = -coslam;
  200. BOOST_FALLTHROUGH;
  201. case s_pole:
  202. if (fabs(lp_lat - half_pi) < epsilon10)
  203. BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) );
  204. xy_x = (xy_y = (half_pi + lp_lat)) * sin(lp_lon);
  205. xy_y *= coslam;
  206. break;
  207. }
  208. }
  209. template <typename T, typename Par, typename ProjParm>
  210. inline void s_inverse(T xy_x, T xy_y, T& lp_lon, T& lp_lat, Par const& par, ProjParm const& proj_parm)
  211. {
  212. static const T pi = detail::pi<T>();
  213. static const T half_pi = detail::half_pi<T>();
  214. T cosc, c_rh, sinc;
  215. if ((c_rh = boost::math::hypot(xy_x, xy_y)) > pi) {
  216. if (c_rh - epsilon10 > pi)
  217. BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) );
  218. c_rh = pi;
  219. } else if (c_rh < epsilon10) {
  220. lp_lat = par.phi0;
  221. lp_lon = 0.;
  222. return;
  223. }
  224. if (proj_parm.mode == obliq || proj_parm.mode == equit) {
  225. sinc = sin(c_rh);
  226. cosc = cos(c_rh);
  227. if (proj_parm.mode == equit) {
  228. lp_lat = aasin(xy_y * sinc / c_rh);
  229. xy_x *= sinc;
  230. xy_y = cosc * c_rh;
  231. } else {
  232. lp_lat = aasin(cosc * proj_parm.sinph0 + xy_y * sinc * proj_parm.cosph0 /
  233. c_rh);
  234. xy_y = (cosc - proj_parm.sinph0 * sin(lp_lat)) * c_rh;
  235. xy_x *= sinc * proj_parm.cosph0;
  236. }
  237. lp_lon = xy_y == 0. ? 0. : atan2(xy_x, xy_y);
  238. } else if (proj_parm.mode == n_pole) {
  239. lp_lat = half_pi - c_rh;
  240. lp_lon = atan2(xy_x, -xy_y);
  241. } else {
  242. lp_lat = c_rh - half_pi;
  243. lp_lon = atan2(xy_x, xy_y);
  244. }
  245. }
  246. // Azimuthal Equidistant
  247. template <typename Params, typename Parameters, typename T>
  248. inline void setup_aeqd(Params const& params, Parameters& par, par_aeqd<T>& proj_parm, bool is_sphere, bool is_guam)
  249. {
  250. static const T half_pi = detail::half_pi<T>();
  251. par.phi0 = pj_get_param_r<T, srs::spar::lat_0>(params, "lat_0", srs::dpar::lat_0);
  252. if (fabs(fabs(par.phi0) - half_pi) < epsilon10) {
  253. proj_parm.mode = par.phi0 < 0. ? s_pole : n_pole;
  254. proj_parm.sinph0 = par.phi0 < 0. ? -1. : 1.;
  255. proj_parm.cosph0 = 0.;
  256. } else if (fabs(par.phi0) < epsilon10) {
  257. proj_parm.mode = equit;
  258. proj_parm.sinph0 = 0.;
  259. proj_parm.cosph0 = 1.;
  260. } else {
  261. proj_parm.mode = obliq;
  262. proj_parm.sinph0 = sin(par.phi0);
  263. proj_parm.cosph0 = cos(par.phi0);
  264. }
  265. if (is_sphere) {
  266. /* empty */
  267. } else {
  268. proj_parm.en = pj_enfn<T>(par.es);
  269. if (is_guam) {
  270. proj_parm.M1 = pj_mlfn(par.phi0, proj_parm.sinph0, proj_parm.cosph0, proj_parm.en);
  271. } else {
  272. switch (proj_parm.mode) {
  273. case n_pole:
  274. proj_parm.Mp = pj_mlfn<T>(half_pi, 1., 0., proj_parm.en);
  275. break;
  276. case s_pole:
  277. proj_parm.Mp = pj_mlfn<T>(-half_pi, -1., 0., proj_parm.en);
  278. break;
  279. case equit:
  280. case obliq:
  281. proj_parm.N1 = 1. / sqrt(1. - par.es * proj_parm.sinph0 * proj_parm.sinph0);
  282. proj_parm.G = proj_parm.sinph0 * (proj_parm.He = par.e / sqrt(par.one_es));
  283. proj_parm.He *= proj_parm.cosph0;
  284. break;
  285. }
  286. // Boost.Geometry specific, in proj4 geodesic is initialized at the beginning
  287. T const b = math::sqrt(math::sqr(par.a) * (1. - par.es));
  288. proj_parm.spheroid = srs::spheroid<T>(par.a, b);
  289. }
  290. }
  291. }
  292. // template class, using CRTP to implement forward/inverse
  293. template <typename T, typename Parameters>
  294. struct base_aeqd_e
  295. : public base_t_fi<base_aeqd_e<T, Parameters>, T, Parameters>
  296. {
  297. par_aeqd<T> m_proj_parm;
  298. inline base_aeqd_e(const Parameters& par)
  299. : base_t_fi<base_aeqd_e<T, Parameters>, T, Parameters>(*this, par)
  300. {}
  301. // FORWARD(e_forward) elliptical
  302. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  303. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  304. {
  305. e_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm);
  306. }
  307. // INVERSE(e_inverse) elliptical
  308. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  309. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  310. {
  311. e_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm);
  312. }
  313. static inline std::string get_name()
  314. {
  315. return "aeqd_e";
  316. }
  317. };
  318. // template class, using CRTP to implement forward/inverse
  319. template <typename T, typename Parameters>
  320. struct base_aeqd_e_guam
  321. : public base_t_fi<base_aeqd_e_guam<T, Parameters>, T, Parameters>
  322. {
  323. par_aeqd<T> m_proj_parm;
  324. inline base_aeqd_e_guam(const Parameters& par)
  325. : base_t_fi<base_aeqd_e_guam<T, Parameters>, T, Parameters>(*this, par)
  326. {}
  327. // FORWARD(e_guam_fwd) Guam elliptical
  328. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  329. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  330. {
  331. e_guam_fwd(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm);
  332. }
  333. // INVERSE(e_guam_inv) Guam elliptical
  334. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  335. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  336. {
  337. e_guam_inv(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm);
  338. }
  339. static inline std::string get_name()
  340. {
  341. return "aeqd_e_guam";
  342. }
  343. };
  344. // template class, using CRTP to implement forward/inverse
  345. template <typename BGParameters, typename T, typename Parameters>
  346. struct base_aeqd_e_static
  347. : public base_t_fi<base_aeqd_e_static<BGParameters, T, Parameters>, T, Parameters>
  348. {
  349. par_aeqd<T> m_proj_parm;
  350. static const bool is_guam = ! boost::is_same
  351. <
  352. typename srs::spar::detail::tuples_find_if
  353. <
  354. BGParameters,
  355. //srs::par4::detail::is_guam
  356. srs::spar::detail::is_param<srs::spar::guam>::pred
  357. >::type,
  358. void
  359. >::value;
  360. inline base_aeqd_e_static(const Parameters& par)
  361. : base_t_fi<base_aeqd_e_static<BGParameters, T, Parameters>, T, Parameters>(*this, par)
  362. {}
  363. // FORWARD(e_forward or e_guam_fwd) elliptical
  364. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  365. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  366. {
  367. if (is_guam)
  368. e_guam_fwd(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm);
  369. else
  370. e_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm);
  371. }
  372. // INVERSE(e_inverse or e_guam_inv) elliptical
  373. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  374. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  375. {
  376. if (is_guam)
  377. e_guam_inv(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm);
  378. else
  379. e_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm);
  380. }
  381. static inline std::string get_name()
  382. {
  383. return "aeqd_e_static";
  384. }
  385. };
  386. // template class, using CRTP to implement forward/inverse
  387. template <typename T, typename Parameters>
  388. struct base_aeqd_s
  389. : public base_t_fi<base_aeqd_s<T, Parameters>, T, Parameters>
  390. {
  391. par_aeqd<T> m_proj_parm;
  392. inline base_aeqd_s(const Parameters& par)
  393. : base_t_fi<base_aeqd_s<T, Parameters>, T, Parameters>(*this, par)
  394. {}
  395. // FORWARD(s_forward) spherical
  396. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  397. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  398. {
  399. s_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm);
  400. }
  401. // INVERSE(s_inverse) spherical
  402. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  403. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  404. {
  405. s_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm);
  406. }
  407. static inline std::string get_name()
  408. {
  409. return "aeqd_s";
  410. }
  411. };
  412. }} // namespace detail::aeqd
  413. #endif // doxygen
  414. /*!
  415. \brief Azimuthal Equidistant projection
  416. \ingroup projections
  417. \tparam Geographic latlong point type
  418. \tparam Cartesian xy point type
  419. \tparam Parameters parameter type
  420. \par Projection characteristics
  421. - Azimuthal
  422. - Spheroid
  423. - Ellipsoid
  424. \par Projection parameters
  425. - lat_0: Latitude of origin (degrees)
  426. - guam (boolean)
  427. \par Example
  428. \image html ex_aeqd.gif
  429. */
  430. template <typename T, typename Parameters>
  431. struct aeqd_e : public detail::aeqd::base_aeqd_e<T, Parameters>
  432. {
  433. template <typename Params>
  434. inline aeqd_e(Params const& params, Parameters const& par)
  435. : detail::aeqd::base_aeqd_e<T, Parameters>(par)
  436. {
  437. detail::aeqd::setup_aeqd(params, this->m_par, this->m_proj_parm, false, false);
  438. }
  439. };
  440. /*!
  441. \brief Azimuthal Equidistant projection
  442. \ingroup projections
  443. \tparam Geographic latlong point type
  444. \tparam Cartesian xy point type
  445. \tparam Parameters parameter type
  446. \par Projection characteristics
  447. - Azimuthal
  448. - Spheroid
  449. - Ellipsoid
  450. \par Projection parameters
  451. - lat_0: Latitude of origin (degrees)
  452. - guam (boolean)
  453. \par Example
  454. \image html ex_aeqd.gif
  455. */
  456. template <typename T, typename Parameters>
  457. struct aeqd_e_guam : public detail::aeqd::base_aeqd_e_guam<T, Parameters>
  458. {
  459. template <typename Params>
  460. inline aeqd_e_guam(Params const& params, Parameters const& par)
  461. : detail::aeqd::base_aeqd_e_guam<T, Parameters>(par)
  462. {
  463. detail::aeqd::setup_aeqd(params, this->m_par, this->m_proj_parm, false, true);
  464. }
  465. };
  466. /*!
  467. \brief Azimuthal Equidistant projection
  468. \ingroup projections
  469. \tparam Geographic latlong point type
  470. \tparam Cartesian xy point type
  471. \tparam Parameters parameter type
  472. \par Projection characteristics
  473. - Azimuthal
  474. - Spheroid
  475. - Ellipsoid
  476. \par Projection parameters
  477. - lat_0: Latitude of origin (degrees)
  478. - guam (boolean)
  479. \par Example
  480. \image html ex_aeqd.gif
  481. */
  482. template <typename SParams, typename T, typename Parameters>
  483. struct aeqd_e_static : public detail::aeqd::base_aeqd_e_static<SParams, T, Parameters>
  484. {
  485. inline aeqd_e_static(SParams const& params, Parameters const& par)
  486. : detail::aeqd::base_aeqd_e_static<SParams, T, Parameters>(par)
  487. {
  488. detail::aeqd::setup_aeqd(params, this->m_par, this->m_proj_parm,
  489. false,
  490. detail::aeqd::base_aeqd_e_static<SParams, T, Parameters>::is_guam);
  491. }
  492. };
  493. /*!
  494. \brief Azimuthal Equidistant projection
  495. \ingroup projections
  496. \tparam Geographic latlong point type
  497. \tparam Cartesian xy point type
  498. \tparam Parameters parameter type
  499. \par Projection characteristics
  500. - Azimuthal
  501. - Spheroid
  502. - Ellipsoid
  503. \par Projection parameters
  504. - lat_0: Latitude of origin (degrees)
  505. - guam (boolean)
  506. \par Example
  507. \image html ex_aeqd.gif
  508. */
  509. template <typename T, typename Parameters>
  510. struct aeqd_s : public detail::aeqd::base_aeqd_s<T, Parameters>
  511. {
  512. template <typename Params>
  513. inline aeqd_s(Params const& params, Parameters const& par)
  514. : detail::aeqd::base_aeqd_s<T, Parameters>(par)
  515. {
  516. detail::aeqd::setup_aeqd(params, this->m_par, this->m_proj_parm, true, false);
  517. }
  518. };
  519. #ifndef DOXYGEN_NO_DETAIL
  520. namespace detail
  521. {
  522. // Static projection
  523. template <typename BGP, typename CT, typename P>
  524. struct static_projection_type<srs::spar::proj_aeqd, srs_sphere_tag, BGP, CT, P>
  525. {
  526. typedef aeqd_s<CT, P> type;
  527. };
  528. template <typename BGP, typename CT, typename P>
  529. struct static_projection_type<srs::spar::proj_aeqd, srs_spheroid_tag, BGP, CT, P>
  530. {
  531. typedef aeqd_e_static<BGP, CT, P> type;
  532. };
  533. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_BEGIN(aeqd_entry)
  534. {
  535. bool const guam = pj_get_param_b<srs::spar::guam>(params, "guam", srs::dpar::guam);
  536. if (parameters.es && ! guam)
  537. return new base_v_fi<aeqd_e<T, Parameters>, T, Parameters>(params, parameters);
  538. else if (parameters.es && guam)
  539. return new base_v_fi<aeqd_e_guam<T, Parameters>, T, Parameters>(params, parameters);
  540. else
  541. return new base_v_fi<aeqd_s<T, Parameters>, T, Parameters>(params, parameters);
  542. }
  543. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_END
  544. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(aeqd_init)
  545. {
  546. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(aeqd, aeqd_entry)
  547. }
  548. } // namespace detail
  549. #endif // doxygen
  550. } // namespace projections
  551. }} // namespace boost::geometry
  552. #endif // BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP