aeqd.hpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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/util/math.hpp>
  39. #include <boost/math/special_functions/hypot.hpp>
  40. #include <boost/geometry/srs/projections/impl/base_static.hpp>
  41. #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
  42. #include <boost/geometry/srs/projections/impl/projects.hpp>
  43. #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
  44. #include <boost/geometry/srs/projections/impl/aasincos.hpp>
  45. #include <boost/geometry/srs/projections/impl/pj_mlfn.hpp>
  46. #include <boost/geometry/srs/projections/par4.hpp>
  47. #include <boost/type_traits/is_same.hpp>
  48. namespace boost { namespace geometry
  49. {
  50. namespace srs { namespace par4
  51. {
  52. struct aeqd {};
  53. //struct aeqd_guam {};
  54. }} //namespace srs::par4
  55. namespace projections
  56. {
  57. #ifndef DOXYGEN_NO_DETAIL
  58. namespace detail { namespace aeqd
  59. {
  60. static const double epsilon10 = 1.e-10;
  61. static const double tolerance = 1.e-14;
  62. enum mode_type {
  63. n_pole = 0,
  64. s_pole = 1,
  65. equit = 2,
  66. obliq = 3
  67. };
  68. template <typename T>
  69. struct par_aeqd
  70. {
  71. T sinph0;
  72. T cosph0;
  73. detail::en<T> en;
  74. T M1;
  75. T N1;
  76. T Mp;
  77. T He;
  78. T G;
  79. mode_type mode;
  80. srs::spheroid<T> spheroid;
  81. };
  82. template <typename T, typename Par, typename ProjParm>
  83. inline void e_forward(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y, Par const& par, ProjParm const& proj_parm)
  84. {
  85. T coslam, cosphi, sinphi, rho;
  86. //T azi1, s12;
  87. //T lam1, phi1, lam2, phi2;
  88. coslam = cos(lp_lon);
  89. cosphi = cos(lp_lat);
  90. sinphi = sin(lp_lat);
  91. switch (proj_parm.mode) {
  92. case n_pole:
  93. coslam = - coslam;
  94. BOOST_FALLTHROUGH;
  95. case s_pole:
  96. xy_x = (rho = fabs(proj_parm.Mp - pj_mlfn(lp_lat, sinphi, cosphi, proj_parm.en))) *
  97. sin(lp_lon);
  98. xy_y = rho * coslam;
  99. break;
  100. case equit:
  101. case obliq:
  102. if (fabs(lp_lon) < epsilon10 && fabs(lp_lat - par.phi0) < epsilon10) {
  103. xy_x = xy_y = 0.;
  104. break;
  105. }
  106. //phi1 = par.phi0; lam1 = par.lam0;
  107. //phi2 = lp_lat; lam2 = lp_lon + par.lam0;
  108. formula::result_inverse<T> const inv =
  109. formula::vincenty_inverse
  110. <
  111. T, true, true
  112. >::apply(par.lam0, par.phi0, lp_lon + par.lam0, lp_lat, proj_parm.spheroid);
  113. //azi1 = inv.azimuth; s12 = inv.distance;
  114. xy_x = inv.distance * sin(inv.azimuth) / par.a;
  115. xy_y = inv.distance * cos(inv.azimuth) / par.a;
  116. break;
  117. }
  118. }
  119. template <typename T, typename Par, typename ProjParm>
  120. inline void e_inverse(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat, Par const& par, ProjParm const& proj_parm)
  121. {
  122. T c;
  123. if ((c = boost::math::hypot(xy_x, xy_y)) < epsilon10) {
  124. lp_lat = par.phi0;
  125. lp_lon = 0.;
  126. return;
  127. }
  128. if (proj_parm.mode == obliq || proj_parm.mode == equit) {
  129. T const x2 = xy_x * par.a;
  130. T const y2 = xy_y * par.a;
  131. //T const lat1 = par.phi0;
  132. //T const lon1 = par.lam0;
  133. T const azi1 = atan2(x2, y2);
  134. T const s12 = sqrt(x2 * x2 + y2 * y2);
  135. formula::result_direct<T> const dir =
  136. formula::vincenty_direct
  137. <
  138. T, true
  139. >::apply(par.lam0, par.phi0, s12, azi1, proj_parm.spheroid);
  140. lp_lat = dir.lat2;
  141. lp_lon = dir.lon2;
  142. lp_lon -= par.lam0;
  143. } else { /* Polar */
  144. lp_lat = pj_inv_mlfn(proj_parm.mode == n_pole ? proj_parm.Mp - c : proj_parm.Mp + c,
  145. par.es, proj_parm.en);
  146. lp_lon = atan2(xy_x, proj_parm.mode == n_pole ? -xy_y : xy_y);
  147. }
  148. }
  149. template <typename T, typename Par, typename ProjParm>
  150. inline void e_guam_fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y, Par const& par, ProjParm const& proj_parm)
  151. {
  152. T cosphi, sinphi, t;
  153. cosphi = cos(lp_lat);
  154. sinphi = sin(lp_lat);
  155. t = 1. / sqrt(1. - par.es * sinphi * sinphi);
  156. xy_x = lp_lon * cosphi * t;
  157. xy_y = pj_mlfn(lp_lat, sinphi, cosphi, proj_parm.en) - proj_parm.M1 +
  158. .5 * lp_lon * lp_lon * cosphi * sinphi * t;
  159. }
  160. template <typename T, typename Par, typename ProjParm>
  161. inline void e_guam_inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat, Par const& par, ProjParm const& proj_parm)
  162. {
  163. T x2, t = 0.0;
  164. int i;
  165. x2 = 0.5 * xy_x * xy_x;
  166. lp_lat = par.phi0;
  167. for (i = 0; i < 3; ++i) {
  168. t = par.e * sin(lp_lat);
  169. lp_lat = pj_inv_mlfn(proj_parm.M1 + xy_y -
  170. x2 * tan(lp_lat) * (t = sqrt(1. - t * t)), par.es, proj_parm.en);
  171. }
  172. lp_lon = xy_x * t / cos(lp_lat);
  173. }
  174. template <typename T, typename Par, typename ProjParm>
  175. inline void s_forward(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y, Par const& /*par*/, ProjParm const& proj_parm)
  176. {
  177. static const T half_pi = detail::half_pi<T>();
  178. T coslam, cosphi, sinphi;
  179. sinphi = sin(lp_lat);
  180. cosphi = cos(lp_lat);
  181. coslam = cos(lp_lon);
  182. switch (proj_parm.mode) {
  183. case equit:
  184. xy_y = cosphi * coslam;
  185. goto oblcon;
  186. case obliq:
  187. xy_y = proj_parm.sinph0 * sinphi + proj_parm.cosph0 * cosphi * coslam;
  188. oblcon:
  189. if (fabs(fabs(xy_y) - 1.) < tolerance)
  190. if (xy_y < 0.)
  191. BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) );
  192. else
  193. xy_x = xy_y = 0.;
  194. else {
  195. xy_y = acos(xy_y);
  196. xy_y /= sin(xy_y);
  197. xy_x = xy_y * cosphi * sin(lp_lon);
  198. xy_y *= (proj_parm.mode == equit) ? sinphi :
  199. proj_parm.cosph0 * sinphi - proj_parm.sinph0 * cosphi * coslam;
  200. }
  201. break;
  202. case n_pole:
  203. lp_lat = -lp_lat;
  204. coslam = -coslam;
  205. BOOST_FALLTHROUGH;
  206. case s_pole:
  207. if (fabs(lp_lat - half_pi) < epsilon10)
  208. BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) );
  209. xy_x = (xy_y = (half_pi + lp_lat)) * sin(lp_lon);
  210. xy_y *= coslam;
  211. break;
  212. }
  213. }
  214. template <typename T, typename Par, typename ProjParm>
  215. inline void s_inverse(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat, Par const& par, ProjParm const& proj_parm)
  216. {
  217. static const T pi = detail::pi<T>();
  218. static const T half_pi = detail::half_pi<T>();
  219. T cosc, c_rh, sinc;
  220. if ((c_rh = boost::math::hypot(xy_x, xy_y)) > pi) {
  221. if (c_rh - epsilon10 > pi)
  222. BOOST_THROW_EXCEPTION( projection_exception(error_tolerance_condition) );
  223. c_rh = pi;
  224. } else if (c_rh < epsilon10) {
  225. lp_lat = par.phi0;
  226. lp_lon = 0.;
  227. return;
  228. }
  229. if (proj_parm.mode == obliq || proj_parm.mode == equit) {
  230. sinc = sin(c_rh);
  231. cosc = cos(c_rh);
  232. if (proj_parm.mode == equit) {
  233. lp_lat = aasin(xy_y * sinc / c_rh);
  234. xy_x *= sinc;
  235. xy_y = cosc * c_rh;
  236. } else {
  237. lp_lat = aasin(cosc * proj_parm.sinph0 + xy_y * sinc * proj_parm.cosph0 /
  238. c_rh);
  239. xy_y = (cosc - proj_parm.sinph0 * sin(lp_lat)) * c_rh;
  240. xy_x *= sinc * proj_parm.cosph0;
  241. }
  242. lp_lon = xy_y == 0. ? 0. : atan2(xy_x, xy_y);
  243. } else if (proj_parm.mode == n_pole) {
  244. lp_lat = half_pi - c_rh;
  245. lp_lon = atan2(xy_x, -xy_y);
  246. } else {
  247. lp_lat = c_rh - half_pi;
  248. lp_lon = atan2(xy_x, xy_y);
  249. }
  250. }
  251. // Azimuthal Equidistant
  252. template <typename Parameters, typename T>
  253. inline void setup_aeqd(Parameters& par, par_aeqd<T>& proj_parm, bool is_sphere, bool is_guam)
  254. {
  255. static const T half_pi = detail::half_pi<T>();
  256. par.phi0 = pj_get_param_r(par.params, "lat_0");
  257. if (fabs(fabs(par.phi0) - half_pi) < epsilon10) {
  258. proj_parm.mode = par.phi0 < 0. ? s_pole : n_pole;
  259. proj_parm.sinph0 = par.phi0 < 0. ? -1. : 1.;
  260. proj_parm.cosph0 = 0.;
  261. } else if (fabs(par.phi0) < epsilon10) {
  262. proj_parm.mode = equit;
  263. proj_parm.sinph0 = 0.;
  264. proj_parm.cosph0 = 1.;
  265. } else {
  266. proj_parm.mode = obliq;
  267. proj_parm.sinph0 = sin(par.phi0);
  268. proj_parm.cosph0 = cos(par.phi0);
  269. }
  270. if (is_sphere) {
  271. /* empty */
  272. } else {
  273. proj_parm.en = pj_enfn<T>(par.es);
  274. if (is_guam) {
  275. proj_parm.M1 = pj_mlfn(par.phi0, proj_parm.sinph0, proj_parm.cosph0, proj_parm.en);
  276. } else {
  277. switch (proj_parm.mode) {
  278. case n_pole:
  279. proj_parm.Mp = pj_mlfn<T>(half_pi, 1., 0., proj_parm.en);
  280. break;
  281. case s_pole:
  282. proj_parm.Mp = pj_mlfn<T>(-half_pi, -1., 0., proj_parm.en);
  283. break;
  284. case equit:
  285. case obliq:
  286. proj_parm.N1 = 1. / sqrt(1. - par.es * proj_parm.sinph0 * proj_parm.sinph0);
  287. proj_parm.G = proj_parm.sinph0 * (proj_parm.He = par.e / sqrt(par.one_es));
  288. proj_parm.He *= proj_parm.cosph0;
  289. break;
  290. }
  291. // Boost.Geometry specific, in proj4 geodesic is initialized at the beginning
  292. T const b = math::sqrt(math::sqr(par.a) * (1. - par.es));
  293. proj_parm.spheroid = srs::spheroid<T>(par.a, b);
  294. }
  295. }
  296. }
  297. // template class, using CRTP to implement forward/inverse
  298. template <typename T, typename Parameters>
  299. struct base_aeqd_e
  300. : public base_t_fi<base_aeqd_e<T, Parameters>, T, Parameters>
  301. {
  302. par_aeqd<T> m_proj_parm;
  303. inline base_aeqd_e(const Parameters& par)
  304. : base_t_fi<base_aeqd_e<T, Parameters>, T, Parameters>(*this, par)
  305. {}
  306. // FORWARD(e_forward) elliptical
  307. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  308. inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const
  309. {
  310. e_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm);
  311. }
  312. // INVERSE(e_inverse) elliptical
  313. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  314. inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const
  315. {
  316. e_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm);
  317. }
  318. static inline std::string get_name()
  319. {
  320. return "aeqd_e";
  321. }
  322. };
  323. // template class, using CRTP to implement forward/inverse
  324. template <typename T, typename Parameters>
  325. struct base_aeqd_e_guam
  326. : public base_t_fi<base_aeqd_e_guam<T, Parameters>, T, Parameters>
  327. {
  328. par_aeqd<T> m_proj_parm;
  329. inline base_aeqd_e_guam(const Parameters& par)
  330. : base_t_fi<base_aeqd_e_guam<T, Parameters>, T, Parameters>(*this, par)
  331. {}
  332. // FORWARD(e_guam_fwd) Guam elliptical
  333. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  334. inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const
  335. {
  336. e_guam_fwd(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm);
  337. }
  338. // INVERSE(e_guam_inv) Guam elliptical
  339. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  340. inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const
  341. {
  342. e_guam_inv(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm);
  343. }
  344. static inline std::string get_name()
  345. {
  346. return "aeqd_e_guam";
  347. }
  348. };
  349. // template class, using CRTP to implement forward/inverse
  350. template <typename BGParameters, typename T, typename Parameters>
  351. struct base_aeqd_e_static
  352. : public base_t_fi<base_aeqd_e_static<BGParameters, T, Parameters>, T, Parameters>
  353. {
  354. par_aeqd<T> m_proj_parm;
  355. static const bool is_guam = ! boost::is_same
  356. <
  357. typename srs::par4::detail::tuples_find_if
  358. <
  359. BGParameters,
  360. //srs::par4::detail::is_guam
  361. srs::par4::detail::is_param<srs::par4::guam>::pred
  362. >::type,
  363. void
  364. >::value;
  365. inline base_aeqd_e_static(const Parameters& par)
  366. : base_t_fi<base_aeqd_e_static<BGParameters, T, Parameters>, T, Parameters>(*this, par)
  367. {}
  368. // FORWARD(e_forward or e_guam_fwd) elliptical
  369. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  370. inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const
  371. {
  372. if (is_guam)
  373. e_guam_fwd(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm);
  374. else
  375. e_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm);
  376. }
  377. // INVERSE(e_inverse or e_guam_inv) elliptical
  378. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  379. inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const
  380. {
  381. if (is_guam)
  382. e_guam_inv(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm);
  383. else
  384. e_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm);
  385. }
  386. static inline std::string get_name()
  387. {
  388. return "aeqd_e_static";
  389. }
  390. };
  391. // template class, using CRTP to implement forward/inverse
  392. template <typename T, typename Parameters>
  393. struct base_aeqd_s
  394. : public base_t_fi<base_aeqd_s<T, Parameters>, T, Parameters>
  395. {
  396. par_aeqd<T> m_proj_parm;
  397. inline base_aeqd_s(const Parameters& par)
  398. : base_t_fi<base_aeqd_s<T, Parameters>, T, Parameters>(*this, par)
  399. {}
  400. // FORWARD(s_forward) spherical
  401. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  402. inline void fwd(T& lp_lon, T& lp_lat, T& xy_x, T& xy_y) const
  403. {
  404. s_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_par, this->m_proj_parm);
  405. }
  406. // INVERSE(s_inverse) spherical
  407. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  408. inline void inv(T& xy_x, T& xy_y, T& lp_lon, T& lp_lat) const
  409. {
  410. s_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_par, this->m_proj_parm);
  411. }
  412. static inline std::string get_name()
  413. {
  414. return "aeqd_s";
  415. }
  416. };
  417. }} // namespace detail::aeqd
  418. #endif // doxygen
  419. /*!
  420. \brief Azimuthal Equidistant projection
  421. \ingroup projections
  422. \tparam Geographic latlong point type
  423. \tparam Cartesian xy point type
  424. \tparam Parameters parameter type
  425. \par Projection characteristics
  426. - Azimuthal
  427. - Spheroid
  428. - Ellipsoid
  429. \par Projection parameters
  430. - lat_0: Latitude of origin (degrees)
  431. - guam (boolean)
  432. \par Example
  433. \image html ex_aeqd.gif
  434. */
  435. template <typename T, typename Parameters>
  436. struct aeqd_e : public detail::aeqd::base_aeqd_e<T, Parameters>
  437. {
  438. inline aeqd_e(const Parameters& par) : detail::aeqd::base_aeqd_e<T, Parameters>(par)
  439. {
  440. detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm, false, false);
  441. }
  442. };
  443. /*!
  444. \brief Azimuthal Equidistant projection
  445. \ingroup projections
  446. \tparam Geographic latlong point type
  447. \tparam Cartesian xy point type
  448. \tparam Parameters parameter type
  449. \par Projection characteristics
  450. - Azimuthal
  451. - Spheroid
  452. - Ellipsoid
  453. \par Projection parameters
  454. - lat_0: Latitude of origin (degrees)
  455. - guam (boolean)
  456. \par Example
  457. \image html ex_aeqd.gif
  458. */
  459. template <typename T, typename Parameters>
  460. struct aeqd_e_guam : public detail::aeqd::base_aeqd_e_guam<T, Parameters>
  461. {
  462. inline aeqd_e_guam(const Parameters& par) : detail::aeqd::base_aeqd_e_guam<T, Parameters>(par)
  463. {
  464. detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm, false, true);
  465. }
  466. };
  467. /*!
  468. \brief Azimuthal Equidistant projection
  469. \ingroup projections
  470. \tparam Geographic latlong point type
  471. \tparam Cartesian xy point type
  472. \tparam Parameters parameter type
  473. \par Projection characteristics
  474. - Azimuthal
  475. - Spheroid
  476. - Ellipsoid
  477. \par Projection parameters
  478. - lat_0: Latitude of origin (degrees)
  479. - guam (boolean)
  480. \par Example
  481. \image html ex_aeqd.gif
  482. */
  483. template <typename BGParameters, typename T, typename Parameters>
  484. struct aeqd_e_static : public detail::aeqd::base_aeqd_e_static<BGParameters, T, Parameters>
  485. {
  486. inline aeqd_e_static(const Parameters& par) : detail::aeqd::base_aeqd_e_static<BGParameters, T, Parameters>(par)
  487. {
  488. detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm,
  489. false,
  490. detail::aeqd::base_aeqd_e_static<BGParameters, 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. inline aeqd_s(const Parameters& par) : detail::aeqd::base_aeqd_s<T, Parameters>(par)
  513. {
  514. detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm, true, false);
  515. }
  516. };
  517. #ifndef DOXYGEN_NO_DETAIL
  518. namespace detail
  519. {
  520. // Static projection
  521. template <typename BGP, typename CT, typename P>
  522. struct static_projection_type<srs::par4::aeqd, srs_sphere_tag, BGP, CT, P>
  523. {
  524. typedef aeqd_s<CT, P> type;
  525. };
  526. template <typename BGP, typename CT, typename P>
  527. struct static_projection_type<srs::par4::aeqd, srs_spheroid_tag, BGP, CT, P>
  528. {
  529. typedef aeqd_e_static<BGP, CT, P> type;
  530. };
  531. //BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::aeqd, aeqd_s, aeqd_e_static)
  532. //BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::par4::aeqd_guam, aeqd_guam, aeqd_guam)
  533. // Factory entry(s)
  534. template <typename T, typename Parameters>
  535. class aeqd_entry : public detail::factory_entry<T, Parameters>
  536. {
  537. public :
  538. virtual base_v<T, Parameters>* create_new(const Parameters& par) const
  539. {
  540. bool const guam = pj_get_param_b(par.params, "guam");
  541. if (par.es && ! guam)
  542. return new base_v_fi<aeqd_e<T, Parameters>, T, Parameters>(par);
  543. else if (par.es && guam)
  544. return new base_v_fi<aeqd_e_guam<T, Parameters>, T, Parameters>(par);
  545. else
  546. return new base_v_fi<aeqd_s<T, Parameters>, T, Parameters>(par);
  547. }
  548. };
  549. template <typename T, typename Parameters>
  550. inline void aeqd_init(detail::base_factory<T, Parameters>& factory)
  551. {
  552. factory.add_to_factory("aeqd", new aeqd_entry<T, Parameters>);
  553. }
  554. } // namespace detail
  555. #endif // doxygen
  556. } // namespace projections
  557. }} // namespace boost::geometry
  558. #endif // BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP