ob_tran.hpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. // Boost.Geometry - gis-projections (based on PROJ4)
  2. // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
  4. // This file was modified by Oracle on 2017-2024.
  5. // Modifications copyright (c) 2017-2024, Oracle and/or its affiliates.
  6. // Contributed and/or modified by Visarion Fysikopoulos, on behalf of Oracle.
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
  8. // Use, modification and distribution is subject to the Boost Software License,
  9. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. // This file is converted from PROJ4, http://trac.osgeo.org/proj
  12. // PROJ4 is originally written by Gerald Evenden (then of the USGS)
  13. // PROJ4 is maintained by Frank Warmerdam
  14. // PROJ4 is converted to Boost.Geometry by Barend Gehrels
  15. // Last updated version of proj: 5.0.0
  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_OB_TRAN_HPP
  33. #define BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP
  34. #include <memory>
  35. #include <type_traits>
  36. #include <boost/geometry/core/static_assert.hpp>
  37. #include <boost/geometry/srs/projections/impl/aasincos.hpp>
  38. #include <boost/geometry/srs/projections/impl/base_static.hpp>
  39. #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
  40. #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
  41. #include <boost/geometry/srs/projections/impl/pj_ell_set.hpp>
  42. #include <boost/geometry/srs/projections/impl/projects.hpp>
  43. #include <boost/geometry/util/math.hpp>
  44. namespace boost { namespace geometry
  45. {
  46. namespace projections
  47. {
  48. #ifndef DOXYGEN_NO_DETAIL
  49. namespace detail {
  50. // fwd declaration needed below
  51. template <typename T>
  52. inline detail::dynamic_wrapper_b<T, projections::parameters<T> >*
  53. create_new(srs::detail::proj4_parameters const& params,
  54. projections::parameters<T> const& parameters);
  55. template <typename T>
  56. inline detail::dynamic_wrapper_b<T, projections::parameters<T> >*
  57. create_new(srs::dpar::parameters<T> const& params,
  58. projections::parameters<T> const& parameters);
  59. } // namespace detail
  60. namespace detail { namespace ob_tran
  61. {
  62. static const double tolerance = 1e-10;
  63. template <typename Parameters>
  64. inline Parameters o_proj_parameters(srs::detail::proj4_parameters const& params,
  65. Parameters const& par)
  66. {
  67. /* copy existing header into new */
  68. Parameters pj = par;
  69. /* get name of projection to be translated */
  70. pj.id = pj_get_param_s(params, "o_proj");
  71. if (pj.id.is_unknown())
  72. BOOST_THROW_EXCEPTION( projection_exception(error_no_rotation_proj) );
  73. /* avoid endless recursion */
  74. if( pj.id.name == "ob_tran")
  75. BOOST_THROW_EXCEPTION( projection_exception(error_failed_to_find_proj) );
  76. // Commented out for consistency with Proj4 >= 5.0.0
  77. /* force spherical earth */
  78. //pj.one_es = pj.rone_es = 1.;
  79. //pj.es = pj.e = 0.;
  80. return pj;
  81. }
  82. template <typename T, typename Parameters>
  83. inline Parameters o_proj_parameters(srs::dpar::parameters<T> const& params,
  84. Parameters const& par)
  85. {
  86. /* copy existing header into new */
  87. Parameters pj = par;
  88. /* get name of projection to be translated */
  89. typename srs::dpar::parameters<T>::const_iterator
  90. it = pj_param_find(params, srs::dpar::o_proj);
  91. if (it != params.end())
  92. pj.id = static_cast<srs::dpar::value_proj>(it->template get_value<int>());
  93. else
  94. BOOST_THROW_EXCEPTION( projection_exception(error_no_rotation_proj) );
  95. /* avoid endless recursion */
  96. if( pj.id.id == srs::dpar::proj_ob_tran)
  97. BOOST_THROW_EXCEPTION( projection_exception(error_failed_to_find_proj) );
  98. // Commented out for consistency with Proj4 >= 5.0.0
  99. /* force spherical earth */
  100. //pj.one_es = pj.rone_es = 1.;
  101. //pj.es = pj.e = 0.;
  102. return pj;
  103. }
  104. template <typename ...Ps, typename Parameters>
  105. inline Parameters o_proj_parameters(srs::spar::parameters<Ps...> const& /*params*/,
  106. Parameters const& par)
  107. {
  108. /* copy existing header into new */
  109. Parameters pj = par;
  110. /* get name of projection to be translated */
  111. typedef srs::spar::parameters<Ps...> params_type;
  112. typedef typename geometry::tuples::find_if
  113. <
  114. params_type,
  115. srs::spar::detail::is_param_t<srs::spar::o_proj>::pred
  116. >::type o_proj_type;
  117. static const bool is_found = geometry::tuples::is_found<o_proj_type>::value;
  118. BOOST_GEOMETRY_STATIC_ASSERT((is_found),
  119. "Rotation projection not specified.",
  120. params_type);
  121. typedef typename o_proj_type::type proj_type;
  122. static const bool is_specialized = srs::spar::detail::proj_traits<proj_type>::is_specialized;
  123. BOOST_GEOMETRY_STATIC_ASSERT((is_specialized),
  124. "Rotation projection not specified.",
  125. params_type);
  126. pj.id = srs::spar::detail::proj_traits<proj_type>::id;
  127. /* avoid endless recursion */
  128. static const bool is_non_resursive = ! std::is_same<proj_type, srs::spar::proj_ob_tran>::value;
  129. BOOST_GEOMETRY_STATIC_ASSERT((is_non_resursive),
  130. "o_proj parameter can not be set to ob_tran projection.",
  131. params_type);
  132. // Commented out for consistency with Proj4 >= 5.0.0
  133. /* force spherical earth */
  134. //pj.one_es = pj.rone_es = 1.;
  135. //pj.es = pj.e = 0.;
  136. return pj;
  137. }
  138. // TODO: It's possible that the original Parameters could be used
  139. // instead of a copy in link.
  140. // But it's not possible with the current implementation of
  141. // dynamic_wrapper_b always storing params
  142. template <typename T, typename Parameters>
  143. struct par_ob_tran
  144. {
  145. template <typename Params>
  146. par_ob_tran(Params const& params, Parameters const& par)
  147. : link(projections::detail::create_new(params, o_proj_parameters(params, par)))
  148. {
  149. if (! link.get())
  150. BOOST_THROW_EXCEPTION( projection_exception(error_unknown_projection_id) );
  151. }
  152. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  153. {
  154. link->fwd(link->params(), lp_lon, lp_lat, xy_x, xy_y);
  155. }
  156. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  157. {
  158. link->inv(link->params(), xy_x, xy_y, lp_lon, lp_lat);
  159. }
  160. std::shared_ptr<dynamic_wrapper_b<T, Parameters> > link;
  161. T lamp = 0;
  162. T cphip = 0;
  163. T sphip = 0;
  164. };
  165. template <typename StaticParameters, typename T, typename Parameters>
  166. struct par_ob_tran_static
  167. {
  168. // this metafunction handles static error handling
  169. typedef typename srs::spar::detail::pick_o_proj_tag
  170. <
  171. StaticParameters
  172. >::type o_proj_tag;
  173. /* avoid endless recursion */
  174. static const bool is_o_proj_not_ob_tran = ! std::is_same<o_proj_tag, srs::spar::proj_ob_tran>::value;
  175. BOOST_GEOMETRY_STATIC_ASSERT((is_o_proj_not_ob_tran),
  176. "o_proj parameter can not be set to ob_tran projection.",
  177. StaticParameters);
  178. typedef typename projections::detail::static_projection_type
  179. <
  180. o_proj_tag,
  181. // Commented out for consistency with Proj4 >= 5.0.0
  182. //srs_sphere_tag, // force spherical
  183. typename projections::detail::static_srs_tag<StaticParameters>::type,
  184. StaticParameters,
  185. T,
  186. Parameters
  187. >::type projection_type;
  188. par_ob_tran_static(StaticParameters const& params, Parameters const& par)
  189. : link(params, o_proj_parameters(params, par))
  190. {}
  191. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  192. {
  193. link.fwd(link.params(), lp_lon, lp_lat, xy_x, xy_y);
  194. }
  195. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  196. {
  197. link.inv(link.params(), xy_x, xy_y, lp_lon, lp_lat);
  198. }
  199. projection_type link;
  200. T lamp = 0;
  201. T cphip = 0;
  202. T sphip = 0;
  203. };
  204. template <typename T, typename Par>
  205. inline void o_forward(T lp_lon, T lp_lat, T& xy_x, T& xy_y, Par const& proj_parm)
  206. {
  207. T coslam, sinphi, cosphi;
  208. coslam = cos(lp_lon);
  209. sinphi = sin(lp_lat);
  210. cosphi = cos(lp_lat);
  211. lp_lon = adjlon(aatan2(cosphi * sin(lp_lon), proj_parm.sphip * cosphi * coslam +
  212. proj_parm.cphip * sinphi) + proj_parm.lamp);
  213. lp_lat = aasin(proj_parm.sphip * sinphi - proj_parm.cphip * cosphi * coslam);
  214. proj_parm.fwd(lp_lon, lp_lat, xy_x, xy_y);
  215. }
  216. template <typename T, typename Par>
  217. inline void o_inverse(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat, Par const& proj_parm)
  218. {
  219. T coslam, sinphi, cosphi;
  220. proj_parm.inv(xy_x, xy_y, lp_lon, lp_lat);
  221. if (lp_lon != HUGE_VAL) {
  222. coslam = cos(lp_lon -= proj_parm.lamp);
  223. sinphi = sin(lp_lat);
  224. cosphi = cos(lp_lat);
  225. lp_lat = aasin(proj_parm.sphip * sinphi + proj_parm.cphip * cosphi * coslam);
  226. lp_lon = aatan2(cosphi * sin(lp_lon), proj_parm.sphip * cosphi * coslam -
  227. proj_parm.cphip * sinphi);
  228. }
  229. }
  230. template <typename T, typename Par>
  231. inline void t_forward(T lp_lon, T lp_lat, T& xy_x, T& xy_y, Par const& proj_parm)
  232. {
  233. T cosphi, coslam;
  234. cosphi = cos(lp_lat);
  235. coslam = cos(lp_lon);
  236. lp_lon = adjlon(aatan2(cosphi * sin(lp_lon), sin(lp_lat)) + proj_parm.lamp);
  237. lp_lat = aasin(- cosphi * coslam);
  238. proj_parm.fwd(lp_lon, lp_lat, xy_x, xy_y);
  239. }
  240. template <typename T, typename Par>
  241. inline void t_inverse(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat, Par const& proj_parm)
  242. {
  243. T cosphi, t;
  244. proj_parm.inv(xy_x, xy_y, lp_lon, lp_lat);
  245. if (lp_lon != HUGE_VAL) {
  246. cosphi = cos(lp_lat);
  247. t = lp_lon - proj_parm.lamp;
  248. lp_lon = aatan2(cosphi * sin(t), - sin(lp_lat));
  249. lp_lat = aasin(cosphi * cos(t));
  250. }
  251. }
  252. // General Oblique Transformation
  253. template <typename T, typename Params, typename Parameters, typename ProjParameters>
  254. inline T setup_ob_tran(Params const& params, Parameters & /*par*/, ProjParameters& proj_parm)
  255. {
  256. static const T half_pi = detail::half_pi<T>();
  257. T phip, alpha;
  258. // Commented out for consistency with Proj4 >= 5.0.0
  259. //par.es = 0.; /* force to spherical */
  260. // proj_parm.link should be created at this point
  261. if (pj_param_r<srs::spar::o_alpha>(params, "o_alpha", srs::dpar::o_alpha, alpha)) {
  262. T lamc, phic;
  263. lamc = pj_get_param_r<T, srs::spar::o_lon_c>(params, "o_lon_c", srs::dpar::o_lon_c);
  264. phic = pj_get_param_r<T, srs::spar::o_lon_c>(params, "o_lat_c", srs::dpar::o_lat_c);
  265. //alpha = pj_get_param_r(par.params, "o_alpha");
  266. if (fabs(fabs(phic) - half_pi) <= tolerance)
  267. BOOST_THROW_EXCEPTION( projection_exception(error_lat_0_or_alpha_eq_90) );
  268. proj_parm.lamp = lamc + aatan2(-cos(alpha), -sin(alpha) * sin(phic));
  269. phip = aasin(cos(phic) * sin(alpha));
  270. } else if (pj_param_r<srs::spar::o_lat_p>(params, "o_lat_p", srs::dpar::o_lat_p, phip)) { /* specified new pole */
  271. proj_parm.lamp = pj_get_param_r<T, srs::spar::o_lon_p>(params, "o_lon_p", srs::dpar::o_lon_p);
  272. //phip = pj_param_r(par.params, "o_lat_p");
  273. } else { /* specified new "equator" points */
  274. T lam1, lam2, phi1, phi2, con;
  275. lam1 = pj_get_param_r<T, srs::spar::o_lon_1>(params, "o_lon_1", srs::dpar::o_lon_1);
  276. phi1 = pj_get_param_r<T, srs::spar::o_lat_1>(params, "o_lat_1", srs::dpar::o_lat_1);
  277. lam2 = pj_get_param_r<T, srs::spar::o_lon_2>(params, "o_lon_2", srs::dpar::o_lon_2);
  278. phi2 = pj_get_param_r<T, srs::spar::o_lat_2>(params, "o_lat_2", srs::dpar::o_lat_2);
  279. if (fabs(phi1 - phi2) <= tolerance || (con = fabs(phi1)) <= tolerance ||
  280. fabs(con - half_pi) <= tolerance || fabs(fabs(phi2) - half_pi) <= tolerance)
  281. BOOST_THROW_EXCEPTION( projection_exception(error_lat_1_or_2_zero_or_90) );
  282. proj_parm.lamp = atan2(cos(phi1) * sin(phi2) * cos(lam1) -
  283. sin(phi1) * cos(phi2) * cos(lam2),
  284. sin(phi1) * cos(phi2) * sin(lam2) -
  285. cos(phi1) * sin(phi2) * sin(lam1));
  286. phip = atan(-cos(proj_parm.lamp - lam1) / tan(phi1));
  287. }
  288. if (fabs(phip) > tolerance) { /* oblique */
  289. proj_parm.cphip = cos(phip);
  290. proj_parm.sphip = sin(phip);
  291. } else { /* transverse */
  292. }
  293. // TODO:
  294. /* Support some rather speculative test cases, where the rotated projection */
  295. /* is actually latlong. We do not want scaling in that case... */
  296. //if (proj_parm.link...mutable_parameters().right==PJ_IO_UNITS_ANGULAR)
  297. // par.right = PJ_IO_UNITS_PROJECTED;
  298. // return phip to choose model
  299. return phip;
  300. }
  301. template <typename T, typename Parameters>
  302. struct base_ob_tran_oblique
  303. {
  304. par_ob_tran<T, Parameters> m_proj_parm;
  305. inline base_ob_tran_oblique(par_ob_tran<T, Parameters> const& proj_parm)
  306. : m_proj_parm(proj_parm)
  307. {}
  308. // FORWARD(o_forward) spheroid
  309. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  310. inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  311. {
  312. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  313. o_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  314. }
  315. // INVERSE(o_inverse) spheroid
  316. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  317. inline void inv(Parameters const& , T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  318. {
  319. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  320. o_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  321. }
  322. static inline std::string get_name()
  323. {
  324. return "ob_tran_oblique";
  325. }
  326. };
  327. template <typename T, typename Parameters>
  328. struct base_ob_tran_transverse
  329. {
  330. par_ob_tran<T, Parameters> m_proj_parm;
  331. inline base_ob_tran_transverse(par_ob_tran<T, Parameters> const& proj_parm)
  332. : m_proj_parm(proj_parm)
  333. {}
  334. // FORWARD(t_forward) spheroid
  335. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  336. inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  337. {
  338. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  339. t_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  340. }
  341. // INVERSE(t_inverse) spheroid
  342. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  343. inline void inv(Parameters const& , T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  344. {
  345. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  346. t_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  347. }
  348. static inline std::string get_name()
  349. {
  350. return "ob_tran_transverse";
  351. }
  352. };
  353. template <typename StaticParameters, typename T, typename Parameters>
  354. struct base_ob_tran_static
  355. {
  356. par_ob_tran_static<StaticParameters, T, Parameters> m_proj_parm;
  357. bool m_is_oblique;
  358. inline base_ob_tran_static(StaticParameters const& params, Parameters const& par)
  359. : m_proj_parm(params, par)
  360. {}
  361. // FORWARD(o_forward) spheroid
  362. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  363. inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  364. {
  365. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  366. if (m_is_oblique) {
  367. o_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  368. } else {
  369. t_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  370. }
  371. }
  372. // INVERSE(o_inverse) spheroid
  373. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  374. inline void inv(Parameters const& , T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  375. {
  376. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  377. if (m_is_oblique) {
  378. o_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  379. } else {
  380. t_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  381. }
  382. }
  383. static inline std::string get_name()
  384. {
  385. return "ob_tran";
  386. }
  387. };
  388. }} // namespace detail::ob_tran
  389. #endif // doxygen
  390. /*!
  391. \brief General Oblique Transformation projection
  392. \ingroup projections
  393. \tparam Geographic latlong point type
  394. \tparam Cartesian xy point type
  395. \tparam Parameters parameter type
  396. \par Projection characteristics
  397. - Miscellaneous
  398. - Spheroid
  399. \par Projection parameters
  400. - o_proj (string)
  401. - Plus projection parameters
  402. - o_lat_p (degrees)
  403. - o_lon_p (degrees)
  404. - New pole
  405. - o_alpha: Alpha (degrees)
  406. - o_lon_c (degrees)
  407. - o_lat_c (degrees)
  408. - o_lon_1 (degrees)
  409. - o_lat_1: Latitude of first standard parallel (degrees)
  410. - o_lon_2 (degrees)
  411. - o_lat_2: Latitude of second standard parallel (degrees)
  412. \par Example
  413. \image html ex_ob_tran.gif
  414. */
  415. template <typename T, typename Parameters>
  416. struct ob_tran_oblique : public detail::ob_tran::base_ob_tran_oblique<T, Parameters>
  417. {
  418. template <typename Params>
  419. inline ob_tran_oblique(Params const& , Parameters const& ,
  420. detail::ob_tran::par_ob_tran<T, Parameters> const& proj_parm)
  421. : detail::ob_tran::base_ob_tran_oblique<T, Parameters>(proj_parm)
  422. {
  423. // already done
  424. //detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm);
  425. }
  426. };
  427. /*!
  428. \brief General Oblique Transformation projection
  429. \ingroup projections
  430. \tparam Geographic latlong point type
  431. \tparam Cartesian xy point type
  432. \tparam Parameters parameter type
  433. \par Projection characteristics
  434. - Miscellaneous
  435. - Spheroid
  436. \par Projection parameters
  437. - o_proj (string)
  438. - Plus projection parameters
  439. - o_lat_p (degrees)
  440. - o_lon_p (degrees)
  441. - New pole
  442. - o_alpha: Alpha (degrees)
  443. - o_lon_c (degrees)
  444. - o_lat_c (degrees)
  445. - o_lon_1 (degrees)
  446. - o_lat_1: Latitude of first standard parallel (degrees)
  447. - o_lon_2 (degrees)
  448. - o_lat_2: Latitude of second standard parallel (degrees)
  449. \par Example
  450. \image html ex_ob_tran.gif
  451. */
  452. template <typename T, typename Parameters>
  453. struct ob_tran_transverse : public detail::ob_tran::base_ob_tran_transverse<T, Parameters>
  454. {
  455. template <typename Params>
  456. inline ob_tran_transverse(Params const& , Parameters const& ,
  457. detail::ob_tran::par_ob_tran<T, Parameters> const& proj_parm)
  458. : detail::ob_tran::base_ob_tran_transverse<T, Parameters>(proj_parm)
  459. {
  460. // already done
  461. //detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm);
  462. }
  463. };
  464. /*!
  465. \brief General Oblique Transformation projection
  466. \ingroup projections
  467. \tparam Geographic latlong point type
  468. \tparam Cartesian xy point type
  469. \tparam Parameters parameter type
  470. \par Projection characteristics
  471. - Miscellaneous
  472. - Spheroid
  473. \par Projection parameters
  474. - o_proj (string)
  475. - Plus projection parameters
  476. - o_lat_p (degrees)
  477. - o_lon_p (degrees)
  478. - New pole
  479. - o_alpha: Alpha (degrees)
  480. - o_lon_c (degrees)
  481. - o_lat_c (degrees)
  482. - o_lon_1 (degrees)
  483. - o_lat_1: Latitude of first standard parallel (degrees)
  484. - o_lon_2 (degrees)
  485. - o_lat_2: Latitude of second standard parallel (degrees)
  486. \par Example
  487. \image html ex_ob_tran.gif
  488. */
  489. template <typename StaticParameters, typename T, typename Parameters>
  490. struct ob_tran_static : public detail::ob_tran::base_ob_tran_static<StaticParameters, T, Parameters>
  491. {
  492. inline ob_tran_static(StaticParameters const& params, Parameters const& par)
  493. : detail::ob_tran::base_ob_tran_static<StaticParameters, T, Parameters>(params, par)
  494. {
  495. T phip = detail::ob_tran::setup_ob_tran<T>(params, par, this->m_proj_parm);
  496. this->m_is_oblique = fabs(phip) > detail::ob_tran::tolerance;
  497. }
  498. };
  499. #ifndef DOXYGEN_NO_DETAIL
  500. namespace detail
  501. {
  502. // Static projection
  503. template <typename SP, typename CT, typename P>
  504. struct static_projection_type<srs::spar::proj_ob_tran, srs_sphere_tag, SP, CT, P>
  505. {
  506. typedef static_wrapper_fi<ob_tran_static<SP, CT, P>, P> type;
  507. };
  508. template <typename SP, typename CT, typename P>
  509. struct static_projection_type<srs::spar::proj_ob_tran, srs_spheroid_tag, SP, CT, P>
  510. {
  511. typedef static_wrapper_fi<ob_tran_static<SP, CT, P>, P> type;
  512. };
  513. // Factory entry(s)
  514. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_BEGIN(ob_tran_entry)
  515. {
  516. Parameters parameters_copy = parameters;
  517. detail::ob_tran::par_ob_tran<T, Parameters> proj_parm(params, parameters_copy);
  518. T phip = detail::ob_tran::setup_ob_tran<T>(params, parameters_copy, proj_parm);
  519. if (fabs(phip) > detail::ob_tran::tolerance)
  520. return new dynamic_wrapper_fi<ob_tran_oblique<T, Parameters>, T, Parameters>(params, parameters_copy, proj_parm);
  521. else
  522. return new dynamic_wrapper_fi<ob_tran_transverse<T, Parameters>, T, Parameters>(params, parameters_copy, proj_parm);
  523. }
  524. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_END
  525. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(ob_tran_init)
  526. {
  527. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(ob_tran, ob_tran_entry)
  528. }
  529. } // namespace detail
  530. #endif // doxygen
  531. } // namespace projections
  532. }} // namespace boost::geometry
  533. #endif // BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP