ob_tran.hpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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, 2019.
  4. // Modifications copyright (c) 2017-2019, 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. // Permission is hereby granted, free of charge, to any person obtaining a
  16. // copy of this software and associated documentation files (the "Software"),
  17. // to deal in the Software without restriction, including without limitation
  18. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  19. // and/or sell copies of the Software, and to permit persons to whom the
  20. // Software is furnished to do so, subject to the following conditions:
  21. // The above copyright notice and this permission notice shall be included
  22. // in all copies or substantial portions of the Software.
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  24. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  26. // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  27. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  28. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  29. // DEALINGS IN THE SOFTWARE.
  30. #ifndef BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP
  31. #define BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP
  32. #include <boost/geometry/util/math.hpp>
  33. #include <boost/shared_ptr.hpp>
  34. #include <boost/geometry/srs/projections/impl/aasincos.hpp>
  35. #include <boost/geometry/srs/projections/impl/base_static.hpp>
  36. #include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
  37. #include <boost/geometry/srs/projections/impl/factory_entry.hpp>
  38. #include <boost/geometry/srs/projections/impl/pj_ell_set.hpp>
  39. #include <boost/geometry/srs/projections/impl/projects.hpp>
  40. namespace boost { namespace geometry
  41. {
  42. namespace projections
  43. {
  44. #ifndef DOXYGEN_NO_DETAIL
  45. namespace detail {
  46. // fwd declaration needed below
  47. template <typename T>
  48. inline detail::dynamic_wrapper_b<T, projections::parameters<T> >*
  49. create_new(srs::detail::proj4_parameters const& params,
  50. projections::parameters<T> const& parameters);
  51. template <typename T>
  52. inline detail::dynamic_wrapper_b<T, projections::parameters<T> >*
  53. create_new(srs::dpar::parameters<T> const& params,
  54. projections::parameters<T> const& parameters);
  55. } // namespace detail
  56. namespace detail { namespace ob_tran
  57. {
  58. static const double tolerance = 1e-10;
  59. template <typename Parameters>
  60. inline Parameters o_proj_parameters(srs::detail::proj4_parameters const& params,
  61. Parameters const& par)
  62. {
  63. /* copy existing header into new */
  64. Parameters pj = par;
  65. /* get name of projection to be translated */
  66. pj.id = pj_get_param_s(params, "o_proj");
  67. if (pj.id.is_unknown())
  68. BOOST_THROW_EXCEPTION( projection_exception(error_no_rotation_proj) );
  69. /* avoid endless recursion */
  70. if( pj.id.name == "ob_tran")
  71. BOOST_THROW_EXCEPTION( projection_exception(error_failed_to_find_proj) );
  72. // Commented out for consistency with Proj4 >= 5.0.0
  73. /* force spherical earth */
  74. //pj.one_es = pj.rone_es = 1.;
  75. //pj.es = pj.e = 0.;
  76. return pj;
  77. }
  78. template <typename T, typename Parameters>
  79. inline Parameters o_proj_parameters(srs::dpar::parameters<T> const& params,
  80. Parameters const& par)
  81. {
  82. /* copy existing header into new */
  83. Parameters pj = par;
  84. /* get name of projection to be translated */
  85. typename srs::dpar::parameters<T>::const_iterator
  86. it = pj_param_find(params, srs::dpar::o_proj);
  87. if (it != params.end())
  88. pj.id = static_cast<srs::dpar::value_proj>(it->template get_value<int>());
  89. else
  90. BOOST_THROW_EXCEPTION( projection_exception(error_no_rotation_proj) );
  91. /* avoid endless recursion */
  92. if( pj.id.id == srs::dpar::proj_ob_tran)
  93. BOOST_THROW_EXCEPTION( projection_exception(error_failed_to_find_proj) );
  94. // Commented out for consistency with Proj4 >= 5.0.0
  95. /* force spherical earth */
  96. //pj.one_es = pj.rone_es = 1.;
  97. //pj.es = pj.e = 0.;
  98. return pj;
  99. }
  100. template <BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX, typename Parameters>
  101. inline Parameters o_proj_parameters(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& /*params*/,
  102. Parameters const& par)
  103. {
  104. /* copy existing header into new */
  105. Parameters pj = par;
  106. /* get name of projection to be translated */
  107. typedef srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> params_type;
  108. typedef typename srs::spar::detail::tuples_find_if
  109. <
  110. params_type,
  111. srs::spar::detail::is_param_t<srs::spar::o_proj>::pred
  112. >::type o_proj_type;
  113. static const bool is_found = srs::spar::detail::tuples_is_found<o_proj_type>::value;
  114. BOOST_MPL_ASSERT_MSG((is_found), NO_ROTATION_PROJ, (params_type));
  115. typedef typename o_proj_type::type proj_type;
  116. static const bool is_specialized = srs::spar::detail::proj_traits<proj_type>::is_specialized;
  117. BOOST_MPL_ASSERT_MSG((is_specialized), NO_ROTATION_PROJ, (params_type));
  118. pj.id = srs::spar::detail::proj_traits<proj_type>::id;
  119. /* avoid endless recursion */
  120. static const bool is_non_resursive = ! boost::is_same<proj_type, srs::spar::proj_ob_tran>::value;
  121. BOOST_MPL_ASSERT_MSG((is_non_resursive), INVALID_O_PROJ_PARAMETER, (params_type));
  122. // Commented out for consistency with Proj4 >= 5.0.0
  123. /* force spherical earth */
  124. //pj.one_es = pj.rone_es = 1.;
  125. //pj.es = pj.e = 0.;
  126. return pj;
  127. }
  128. // TODO: It's possible that the original Parameters could be used
  129. // instead of a copy in link.
  130. // But it's not possible with the current implementation of
  131. // dynamic_wrapper_b always storing params
  132. template <typename T, typename Parameters>
  133. struct par_ob_tran
  134. {
  135. template <typename Params>
  136. par_ob_tran(Params const& params, Parameters const& par)
  137. : link(projections::detail::create_new(params, o_proj_parameters(params, par)))
  138. {
  139. if (! link.get())
  140. BOOST_THROW_EXCEPTION( projection_exception(error_unknown_projection_id) );
  141. }
  142. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  143. {
  144. link->fwd(link->params(), lp_lon, lp_lat, xy_x, xy_y);
  145. }
  146. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  147. {
  148. link->inv(link->params(), xy_x, xy_y, lp_lon, lp_lat);
  149. }
  150. boost::shared_ptr<dynamic_wrapper_b<T, Parameters> > link;
  151. T lamp;
  152. T cphip, sphip;
  153. };
  154. template <typename StaticParameters, typename T, typename Parameters>
  155. struct par_ob_tran_static
  156. {
  157. // this metafunction handles static error handling
  158. typedef typename srs::spar::detail::pick_o_proj_tag
  159. <
  160. StaticParameters
  161. >::type o_proj_tag;
  162. /* avoid endless recursion */
  163. static const bool is_o_proj_not_ob_tran = ! boost::is_same<o_proj_tag, srs::spar::proj_ob_tran>::value;
  164. BOOST_MPL_ASSERT_MSG((is_o_proj_not_ob_tran), INVALID_O_PROJ_PARAMETER, (StaticParameters));
  165. typedef typename projections::detail::static_projection_type
  166. <
  167. o_proj_tag,
  168. // Commented out for consistency with Proj4 >= 5.0.0
  169. //srs_sphere_tag, // force spherical
  170. typename projections::detail::static_srs_tag<StaticParameters>::type,
  171. StaticParameters,
  172. T,
  173. Parameters
  174. >::type projection_type;
  175. par_ob_tran_static(StaticParameters const& params, Parameters const& par)
  176. : link(params, o_proj_parameters(params, par))
  177. {}
  178. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  179. {
  180. link.fwd(link.params(), lp_lon, lp_lat, xy_x, xy_y);
  181. }
  182. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  183. {
  184. link.inv(link.params(), xy_x, xy_y, lp_lon, lp_lat);
  185. }
  186. projection_type link;
  187. T lamp;
  188. T cphip, sphip;
  189. };
  190. template <typename T, typename Par>
  191. inline void o_forward(T lp_lon, T lp_lat, T& xy_x, T& xy_y, Par const& proj_parm)
  192. {
  193. T coslam, sinphi, cosphi;
  194. coslam = cos(lp_lon);
  195. sinphi = sin(lp_lat);
  196. cosphi = cos(lp_lat);
  197. lp_lon = adjlon(aatan2(cosphi * sin(lp_lon), proj_parm.sphip * cosphi * coslam +
  198. proj_parm.cphip * sinphi) + proj_parm.lamp);
  199. lp_lat = aasin(proj_parm.sphip * sinphi - proj_parm.cphip * cosphi * coslam);
  200. proj_parm.fwd(lp_lon, lp_lat, xy_x, xy_y);
  201. }
  202. template <typename T, typename Par>
  203. inline void o_inverse(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat, Par const& proj_parm)
  204. {
  205. T coslam, sinphi, cosphi;
  206. proj_parm.inv(xy_x, xy_y, lp_lon, lp_lat);
  207. if (lp_lon != HUGE_VAL) {
  208. coslam = cos(lp_lon -= proj_parm.lamp);
  209. sinphi = sin(lp_lat);
  210. cosphi = cos(lp_lat);
  211. lp_lat = aasin(proj_parm.sphip * sinphi + proj_parm.cphip * cosphi * coslam);
  212. lp_lon = aatan2(cosphi * sin(lp_lon), proj_parm.sphip * cosphi * coslam -
  213. proj_parm.cphip * sinphi);
  214. }
  215. }
  216. template <typename T, typename Par>
  217. inline void t_forward(T lp_lon, T lp_lat, T& xy_x, T& xy_y, Par const& proj_parm)
  218. {
  219. T cosphi, coslam;
  220. cosphi = cos(lp_lat);
  221. coslam = cos(lp_lon);
  222. lp_lon = adjlon(aatan2(cosphi * sin(lp_lon), sin(lp_lat)) + proj_parm.lamp);
  223. lp_lat = aasin(- cosphi * coslam);
  224. proj_parm.fwd(lp_lon, lp_lat, xy_x, xy_y);
  225. }
  226. template <typename T, typename Par>
  227. inline void t_inverse(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat, Par const& proj_parm)
  228. {
  229. T cosphi, t;
  230. proj_parm.inv(xy_x, xy_y, lp_lon, lp_lat);
  231. if (lp_lon != HUGE_VAL) {
  232. cosphi = cos(lp_lat);
  233. t = lp_lon - proj_parm.lamp;
  234. lp_lon = aatan2(cosphi * sin(t), - sin(lp_lat));
  235. lp_lat = aasin(cosphi * cos(t));
  236. }
  237. }
  238. // General Oblique Transformation
  239. template <typename T, typename Params, typename Parameters, typename ProjParameters>
  240. inline T setup_ob_tran(Params const& params, Parameters & /*par*/, ProjParameters& proj_parm)
  241. {
  242. static const T half_pi = detail::half_pi<T>();
  243. T phip, alpha;
  244. // Commented out for consistency with Proj4 >= 5.0.0
  245. //par.es = 0.; /* force to spherical */
  246. // proj_parm.link should be created at this point
  247. if (pj_param_r<srs::spar::o_alpha>(params, "o_alpha", srs::dpar::o_alpha, alpha)) {
  248. T lamc, phic;
  249. lamc = pj_get_param_r<T, srs::spar::o_lon_c>(params, "o_lon_c", srs::dpar::o_lon_c);
  250. phic = pj_get_param_r<T, srs::spar::o_lon_c>(params, "o_lat_c", srs::dpar::o_lat_c);
  251. //alpha = pj_get_param_r(par.params, "o_alpha");
  252. if (fabs(fabs(phic) - half_pi) <= tolerance)
  253. BOOST_THROW_EXCEPTION( projection_exception(error_lat_0_or_alpha_eq_90) );
  254. proj_parm.lamp = lamc + aatan2(-cos(alpha), -sin(alpha) * sin(phic));
  255. phip = aasin(cos(phic) * sin(alpha));
  256. } else if (pj_param_r<srs::spar::o_lat_p>(params, "o_lat_p", srs::dpar::o_lat_p, phip)) { /* specified new pole */
  257. proj_parm.lamp = pj_get_param_r<T, srs::spar::o_lon_p>(params, "o_lon_p", srs::dpar::o_lon_p);
  258. //phip = pj_param_r(par.params, "o_lat_p");
  259. } else { /* specified new "equator" points */
  260. T lam1, lam2, phi1, phi2, con;
  261. lam1 = pj_get_param_r<T, srs::spar::o_lon_1>(params, "o_lon_1", srs::dpar::o_lon_1);
  262. phi1 = pj_get_param_r<T, srs::spar::o_lat_1>(params, "o_lat_1", srs::dpar::o_lat_1);
  263. lam2 = pj_get_param_r<T, srs::spar::o_lon_2>(params, "o_lon_2", srs::dpar::o_lon_2);
  264. phi2 = pj_get_param_r<T, srs::spar::o_lat_2>(params, "o_lat_2", srs::dpar::o_lat_2);
  265. if (fabs(phi1 - phi2) <= tolerance || (con = fabs(phi1)) <= tolerance ||
  266. fabs(con - half_pi) <= tolerance || fabs(fabs(phi2) - half_pi) <= tolerance)
  267. BOOST_THROW_EXCEPTION( projection_exception(error_lat_1_or_2_zero_or_90) );
  268. proj_parm.lamp = atan2(cos(phi1) * sin(phi2) * cos(lam1) -
  269. sin(phi1) * cos(phi2) * cos(lam2),
  270. sin(phi1) * cos(phi2) * sin(lam2) -
  271. cos(phi1) * sin(phi2) * sin(lam1));
  272. phip = atan(-cos(proj_parm.lamp - lam1) / tan(phi1));
  273. }
  274. if (fabs(phip) > tolerance) { /* oblique */
  275. proj_parm.cphip = cos(phip);
  276. proj_parm.sphip = sin(phip);
  277. } else { /* transverse */
  278. }
  279. // TODO:
  280. /* Support some rather speculative test cases, where the rotated projection */
  281. /* is actually latlong. We do not want scaling in that case... */
  282. //if (proj_parm.link...mutable_parameters().right==PJ_IO_UNITS_ANGULAR)
  283. // par.right = PJ_IO_UNITS_PROJECTED;
  284. // return phip to choose model
  285. return phip;
  286. }
  287. template <typename T, typename Parameters>
  288. struct base_ob_tran_oblique
  289. {
  290. par_ob_tran<T, Parameters> m_proj_parm;
  291. inline base_ob_tran_oblique(par_ob_tran<T, Parameters> const& proj_parm)
  292. : m_proj_parm(proj_parm)
  293. {}
  294. // FORWARD(o_forward) spheroid
  295. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  296. inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  297. {
  298. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  299. o_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  300. }
  301. // INVERSE(o_inverse) spheroid
  302. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  303. inline void inv(Parameters const& , T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  304. {
  305. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  306. o_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  307. }
  308. static inline std::string get_name()
  309. {
  310. return "ob_tran_oblique";
  311. }
  312. };
  313. template <typename T, typename Parameters>
  314. struct base_ob_tran_transverse
  315. {
  316. par_ob_tran<T, Parameters> m_proj_parm;
  317. inline base_ob_tran_transverse(par_ob_tran<T, Parameters> const& proj_parm)
  318. : m_proj_parm(proj_parm)
  319. {}
  320. // FORWARD(t_forward) spheroid
  321. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  322. inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  323. {
  324. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  325. t_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  326. }
  327. // INVERSE(t_inverse) spheroid
  328. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  329. inline void inv(Parameters const& , T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  330. {
  331. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  332. t_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  333. }
  334. static inline std::string get_name()
  335. {
  336. return "ob_tran_transverse";
  337. }
  338. };
  339. template <typename StaticParameters, typename T, typename Parameters>
  340. struct base_ob_tran_static
  341. {
  342. par_ob_tran_static<StaticParameters, T, Parameters> m_proj_parm;
  343. bool m_is_oblique;
  344. inline base_ob_tran_static(StaticParameters const& params, Parameters const& par)
  345. : m_proj_parm(params, par)
  346. {}
  347. // FORWARD(o_forward) spheroid
  348. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  349. inline void fwd(Parameters const& , T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  350. {
  351. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  352. if (m_is_oblique) {
  353. o_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  354. } else {
  355. t_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  356. }
  357. }
  358. // INVERSE(o_inverse) spheroid
  359. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  360. inline void inv(Parameters const& , T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  361. {
  362. // NOTE: Parameters ignored, m_proj_parm.link has a copy
  363. if (m_is_oblique) {
  364. o_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  365. } else {
  366. t_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  367. }
  368. }
  369. static inline std::string get_name()
  370. {
  371. return "ob_tran";
  372. }
  373. };
  374. }} // namespace detail::ob_tran
  375. #endif // doxygen
  376. /*!
  377. \brief General Oblique Transformation projection
  378. \ingroup projections
  379. \tparam Geographic latlong point type
  380. \tparam Cartesian xy point type
  381. \tparam Parameters parameter type
  382. \par Projection characteristics
  383. - Miscellaneous
  384. - Spheroid
  385. \par Projection parameters
  386. - o_proj (string)
  387. - Plus projection parameters
  388. - o_lat_p (degrees)
  389. - o_lon_p (degrees)
  390. - New pole
  391. - o_alpha: Alpha (degrees)
  392. - o_lon_c (degrees)
  393. - o_lat_c (degrees)
  394. - o_lon_1 (degrees)
  395. - o_lat_1: Latitude of first standard parallel (degrees)
  396. - o_lon_2 (degrees)
  397. - o_lat_2: Latitude of second standard parallel (degrees)
  398. \par Example
  399. \image html ex_ob_tran.gif
  400. */
  401. template <typename T, typename Parameters>
  402. struct ob_tran_oblique : public detail::ob_tran::base_ob_tran_oblique<T, Parameters>
  403. {
  404. template <typename Params>
  405. inline ob_tran_oblique(Params const& , Parameters const& ,
  406. detail::ob_tran::par_ob_tran<T, Parameters> const& proj_parm)
  407. : detail::ob_tran::base_ob_tran_oblique<T, Parameters>(proj_parm)
  408. {
  409. // already done
  410. //detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm);
  411. }
  412. };
  413. /*!
  414. \brief General Oblique Transformation projection
  415. \ingroup projections
  416. \tparam Geographic latlong point type
  417. \tparam Cartesian xy point type
  418. \tparam Parameters parameter type
  419. \par Projection characteristics
  420. - Miscellaneous
  421. - Spheroid
  422. \par Projection parameters
  423. - o_proj (string)
  424. - Plus projection parameters
  425. - o_lat_p (degrees)
  426. - o_lon_p (degrees)
  427. - New pole
  428. - o_alpha: Alpha (degrees)
  429. - o_lon_c (degrees)
  430. - o_lat_c (degrees)
  431. - o_lon_1 (degrees)
  432. - o_lat_1: Latitude of first standard parallel (degrees)
  433. - o_lon_2 (degrees)
  434. - o_lat_2: Latitude of second standard parallel (degrees)
  435. \par Example
  436. \image html ex_ob_tran.gif
  437. */
  438. template <typename T, typename Parameters>
  439. struct ob_tran_transverse : public detail::ob_tran::base_ob_tran_transverse<T, Parameters>
  440. {
  441. template <typename Params>
  442. inline ob_tran_transverse(Params const& , Parameters const& ,
  443. detail::ob_tran::par_ob_tran<T, Parameters> const& proj_parm)
  444. : detail::ob_tran::base_ob_tran_transverse<T, Parameters>(proj_parm)
  445. {
  446. // already done
  447. //detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm);
  448. }
  449. };
  450. /*!
  451. \brief General Oblique Transformation projection
  452. \ingroup projections
  453. \tparam Geographic latlong point type
  454. \tparam Cartesian xy point type
  455. \tparam Parameters parameter type
  456. \par Projection characteristics
  457. - Miscellaneous
  458. - Spheroid
  459. \par Projection parameters
  460. - o_proj (string)
  461. - Plus projection parameters
  462. - o_lat_p (degrees)
  463. - o_lon_p (degrees)
  464. - New pole
  465. - o_alpha: Alpha (degrees)
  466. - o_lon_c (degrees)
  467. - o_lat_c (degrees)
  468. - o_lon_1 (degrees)
  469. - o_lat_1: Latitude of first standard parallel (degrees)
  470. - o_lon_2 (degrees)
  471. - o_lat_2: Latitude of second standard parallel (degrees)
  472. \par Example
  473. \image html ex_ob_tran.gif
  474. */
  475. template <typename StaticParameters, typename T, typename Parameters>
  476. struct ob_tran_static : public detail::ob_tran::base_ob_tran_static<StaticParameters, T, Parameters>
  477. {
  478. inline ob_tran_static(StaticParameters const& params, Parameters const& par)
  479. : detail::ob_tran::base_ob_tran_static<StaticParameters, T, Parameters>(params, par)
  480. {
  481. T phip = detail::ob_tran::setup_ob_tran<T>(params, par, this->m_proj_parm);
  482. this->m_is_oblique = fabs(phip) > detail::ob_tran::tolerance;
  483. }
  484. };
  485. #ifndef DOXYGEN_NO_DETAIL
  486. namespace detail
  487. {
  488. // Static projection
  489. template <typename SP, typename CT, typename P>
  490. struct static_projection_type<srs::spar::proj_ob_tran, srs_sphere_tag, SP, CT, P>
  491. {
  492. typedef static_wrapper_fi<ob_tran_static<SP, CT, P>, P> type;
  493. };
  494. template <typename SP, typename CT, typename P>
  495. struct static_projection_type<srs::spar::proj_ob_tran, srs_spheroid_tag, SP, CT, P>
  496. {
  497. typedef static_wrapper_fi<ob_tran_static<SP, CT, P>, P> type;
  498. };
  499. // Factory entry(s)
  500. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_BEGIN(ob_tran_entry)
  501. {
  502. Parameters parameters_copy = parameters;
  503. detail::ob_tran::par_ob_tran<T, Parameters> proj_parm(params, parameters_copy);
  504. T phip = detail::ob_tran::setup_ob_tran<T>(params, parameters_copy, proj_parm);
  505. if (fabs(phip) > detail::ob_tran::tolerance)
  506. return new dynamic_wrapper_fi<ob_tran_oblique<T, Parameters>, T, Parameters>(params, parameters_copy, proj_parm);
  507. else
  508. return new dynamic_wrapper_fi<ob_tran_transverse<T, Parameters>, T, Parameters>(params, parameters_copy, proj_parm);
  509. }
  510. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_END
  511. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(ob_tran_init)
  512. {
  513. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(ob_tran, ob_tran_entry)
  514. }
  515. } // namespace detail
  516. #endif // doxygen
  517. } // namespace projections
  518. }} // namespace boost::geometry
  519. #endif // BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP