ob_tran.hpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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::base_v<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::base_v<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. template <typename T, typename Parameters>
  129. struct par_ob_tran
  130. {
  131. template <typename Params>
  132. par_ob_tran(Params const& params, Parameters const& par)
  133. : link(projections::detail::create_new(params, o_proj_parameters(params, par)))
  134. {
  135. if (! link.get())
  136. BOOST_THROW_EXCEPTION( projection_exception(error_unknown_projection_id) );
  137. }
  138. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  139. {
  140. link->fwd(lp_lon, lp_lat, xy_x, xy_y);
  141. }
  142. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  143. {
  144. link->inv(xy_x, xy_y, lp_lon, lp_lat);
  145. }
  146. boost::shared_ptr<base_v<T, Parameters> > link;
  147. T lamp;
  148. T cphip, sphip;
  149. };
  150. template <typename StaticParameters, typename T, typename Parameters>
  151. struct par_ob_tran_static
  152. {
  153. // this metafunction handles static error handling
  154. typedef typename srs::spar::detail::pick_o_proj_tag
  155. <
  156. StaticParameters
  157. >::type o_proj_tag;
  158. /* avoid endless recursion */
  159. static const bool is_o_proj_not_ob_tran = ! boost::is_same<o_proj_tag, srs::spar::proj_ob_tran>::value;
  160. BOOST_MPL_ASSERT_MSG((is_o_proj_not_ob_tran), INVALID_O_PROJ_PARAMETER, (StaticParameters));
  161. typedef typename projections::detail::static_projection_type
  162. <
  163. o_proj_tag,
  164. // Commented out for consistency with Proj4 >= 5.0.0
  165. //srs_sphere_tag, // force spherical
  166. typename projections::detail::static_srs_tag<StaticParameters>::type,
  167. StaticParameters,
  168. T,
  169. Parameters
  170. >::type projection_type;
  171. par_ob_tran_static(StaticParameters const& params, Parameters const& par)
  172. : link(params, o_proj_parameters(params, par))
  173. {}
  174. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  175. {
  176. link.fwd(lp_lon, lp_lat, xy_x, xy_y);
  177. }
  178. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  179. {
  180. link.inv(xy_x, xy_y, lp_lon, lp_lat);
  181. }
  182. projection_type link;
  183. T lamp;
  184. T cphip, sphip;
  185. };
  186. template <typename T, typename Par>
  187. inline void o_forward(T lp_lon, T lp_lat, T& xy_x, T& xy_y, Par const& proj_parm)
  188. {
  189. T coslam, sinphi, cosphi;
  190. coslam = cos(lp_lon);
  191. sinphi = sin(lp_lat);
  192. cosphi = cos(lp_lat);
  193. lp_lon = adjlon(aatan2(cosphi * sin(lp_lon), proj_parm.sphip * cosphi * coslam +
  194. proj_parm.cphip * sinphi) + proj_parm.lamp);
  195. lp_lat = aasin(proj_parm.sphip * sinphi - proj_parm.cphip * cosphi * coslam);
  196. proj_parm.fwd(lp_lon, lp_lat, xy_x, xy_y);
  197. }
  198. template <typename T, typename Par>
  199. inline void o_inverse(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat, Par const& proj_parm)
  200. {
  201. T coslam, sinphi, cosphi;
  202. proj_parm.inv(xy_x, xy_y, lp_lon, lp_lat);
  203. if (lp_lon != HUGE_VAL) {
  204. coslam = cos(lp_lon -= proj_parm.lamp);
  205. sinphi = sin(lp_lat);
  206. cosphi = cos(lp_lat);
  207. lp_lat = aasin(proj_parm.sphip * sinphi + proj_parm.cphip * cosphi * coslam);
  208. lp_lon = aatan2(cosphi * sin(lp_lon), proj_parm.sphip * cosphi * coslam -
  209. proj_parm.cphip * sinphi);
  210. }
  211. }
  212. template <typename T, typename Par>
  213. inline void t_forward(T lp_lon, T lp_lat, T& xy_x, T& xy_y, Par const& proj_parm)
  214. {
  215. T cosphi, coslam;
  216. cosphi = cos(lp_lat);
  217. coslam = cos(lp_lon);
  218. lp_lon = adjlon(aatan2(cosphi * sin(lp_lon), sin(lp_lat)) + proj_parm.lamp);
  219. lp_lat = aasin(- cosphi * coslam);
  220. proj_parm.fwd(lp_lon, lp_lat, xy_x, xy_y);
  221. }
  222. template <typename T, typename Par>
  223. inline void t_inverse(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat, Par const& proj_parm)
  224. {
  225. T cosphi, t;
  226. proj_parm.inv(xy_x, xy_y, lp_lon, lp_lat);
  227. if (lp_lon != HUGE_VAL) {
  228. cosphi = cos(lp_lat);
  229. t = lp_lon - proj_parm.lamp;
  230. lp_lon = aatan2(cosphi * sin(t), - sin(lp_lat));
  231. lp_lat = aasin(cosphi * cos(t));
  232. }
  233. }
  234. // General Oblique Transformation
  235. template <typename T, typename Params, typename Parameters, typename ProjParameters>
  236. inline T setup_ob_tran(Params const& params, Parameters & /*par*/, ProjParameters& proj_parm)
  237. {
  238. static const T half_pi = detail::half_pi<T>();
  239. T phip, alpha;
  240. // Commented out for consistency with Proj4 >= 5.0.0
  241. //par.es = 0.; /* force to spherical */
  242. // proj_parm.link should be created at this point
  243. if (pj_param_r<srs::spar::o_alpha>(params, "o_alpha", srs::dpar::o_alpha, alpha)) {
  244. T lamc, phic;
  245. lamc = pj_get_param_r<T, srs::spar::o_lon_c>(params, "o_lon_c", srs::dpar::o_lon_c);
  246. phic = pj_get_param_r<T, srs::spar::o_lon_c>(params, "o_lat_c", srs::dpar::o_lat_c);
  247. //alpha = pj_get_param_r(par.params, "o_alpha");
  248. if (fabs(fabs(phic) - half_pi) <= tolerance)
  249. BOOST_THROW_EXCEPTION( projection_exception(error_lat_0_or_alpha_eq_90) );
  250. proj_parm.lamp = lamc + aatan2(-cos(alpha), -sin(alpha) * sin(phic));
  251. phip = aasin(cos(phic) * sin(alpha));
  252. } else if (pj_param_r<srs::spar::o_lat_p>(params, "o_lat_p", srs::dpar::o_lat_p, phip)) { /* specified new pole */
  253. proj_parm.lamp = pj_get_param_r<T, srs::spar::o_lon_p>(params, "o_lon_p", srs::dpar::o_lon_p);
  254. //phip = pj_param_r(par.params, "o_lat_p");
  255. } else { /* specified new "equator" points */
  256. T lam1, lam2, phi1, phi2, con;
  257. lam1 = pj_get_param_r<T, srs::spar::o_lon_1>(params, "o_lon_1", srs::dpar::o_lon_1);
  258. phi1 = pj_get_param_r<T, srs::spar::o_lat_1>(params, "o_lat_1", srs::dpar::o_lat_1);
  259. lam2 = pj_get_param_r<T, srs::spar::o_lon_2>(params, "o_lon_2", srs::dpar::o_lon_2);
  260. phi2 = pj_get_param_r<T, srs::spar::o_lat_2>(params, "o_lat_2", srs::dpar::o_lat_2);
  261. if (fabs(phi1 - phi2) <= tolerance || (con = fabs(phi1)) <= tolerance ||
  262. fabs(con - half_pi) <= tolerance || fabs(fabs(phi2) - half_pi) <= tolerance)
  263. BOOST_THROW_EXCEPTION( projection_exception(error_lat_1_or_2_zero_or_90) );
  264. proj_parm.lamp = atan2(cos(phi1) * sin(phi2) * cos(lam1) -
  265. sin(phi1) * cos(phi2) * cos(lam2),
  266. sin(phi1) * cos(phi2) * sin(lam2) -
  267. cos(phi1) * sin(phi2) * sin(lam1));
  268. phip = atan(-cos(proj_parm.lamp - lam1) / tan(phi1));
  269. }
  270. if (fabs(phip) > tolerance) { /* oblique */
  271. proj_parm.cphip = cos(phip);
  272. proj_parm.sphip = sin(phip);
  273. } else { /* transverse */
  274. }
  275. // TODO:
  276. /* Support some rather speculative test cases, where the rotated projection */
  277. /* is actually latlong. We do not want scaling in that case... */
  278. //if (proj_parm.link...mutable_parameters().right==PJ_IO_UNITS_ANGULAR)
  279. // par.right = PJ_IO_UNITS_PROJECTED;
  280. // return phip to choose model
  281. return phip;
  282. }
  283. // template class, using CRTP to implement forward/inverse
  284. template <typename T, typename Parameters>
  285. struct base_ob_tran_oblique
  286. : public base_t_fi<base_ob_tran_oblique<T, Parameters>, T, Parameters>
  287. {
  288. par_ob_tran<T, Parameters> m_proj_parm;
  289. inline base_ob_tran_oblique(Parameters const& par,
  290. par_ob_tran<T, Parameters> const& proj_parm)
  291. : base_t_fi
  292. <
  293. base_ob_tran_oblique<T, Parameters>, T, Parameters
  294. >(*this, par)
  295. , m_proj_parm(proj_parm)
  296. {}
  297. // FORWARD(o_forward) spheroid
  298. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  299. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  300. {
  301. o_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  302. }
  303. // INVERSE(o_inverse) spheroid
  304. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  305. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  306. {
  307. o_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  308. }
  309. static inline std::string get_name()
  310. {
  311. return "ob_tran_oblique";
  312. }
  313. };
  314. // template class, using CRTP to implement forward/inverse
  315. template <typename T, typename Parameters>
  316. struct base_ob_tran_transverse
  317. : public base_t_fi<base_ob_tran_transverse<T, Parameters>, T, Parameters>
  318. {
  319. par_ob_tran<T, Parameters> m_proj_parm;
  320. inline base_ob_tran_transverse(Parameters const& par,
  321. par_ob_tran<T, Parameters> const& proj_parm)
  322. : base_t_fi
  323. <
  324. base_ob_tran_transverse<T, Parameters>, T, Parameters
  325. >(*this, par)
  326. , m_proj_parm(proj_parm)
  327. {}
  328. // FORWARD(t_forward) spheroid
  329. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  330. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  331. {
  332. t_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  333. }
  334. // INVERSE(t_inverse) spheroid
  335. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  336. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  337. {
  338. t_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  339. }
  340. static inline std::string get_name()
  341. {
  342. return "ob_tran_transverse";
  343. }
  344. };
  345. // template class, using CRTP to implement forward/inverse
  346. template <typename StaticParameters, typename T, typename Parameters>
  347. struct base_ob_tran_static
  348. : public base_t_fi<base_ob_tran_static<StaticParameters, T, Parameters>, T, Parameters>
  349. {
  350. par_ob_tran_static<StaticParameters, T, Parameters> m_proj_parm;
  351. bool m_is_oblique;
  352. inline base_ob_tran_static(StaticParameters const& params, Parameters const& par)
  353. : base_t_fi<base_ob_tran_static<StaticParameters, T, Parameters>, T, Parameters>(*this, par)
  354. , m_proj_parm(params, par)
  355. {}
  356. // FORWARD(o_forward) spheroid
  357. // Project coordinates from geographic (lon, lat) to cartesian (x, y)
  358. inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
  359. {
  360. if (m_is_oblique) {
  361. o_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  362. } else {
  363. t_forward(lp_lon, lp_lat, xy_x, xy_y, this->m_proj_parm);
  364. }
  365. }
  366. // INVERSE(o_inverse) spheroid
  367. // Project coordinates from cartesian (x, y) to geographic (lon, lat)
  368. inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
  369. {
  370. if (m_is_oblique) {
  371. o_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  372. } else {
  373. t_inverse(xy_x, xy_y, lp_lon, lp_lat, this->m_proj_parm);
  374. }
  375. }
  376. static inline std::string get_name()
  377. {
  378. return "ob_tran";
  379. }
  380. };
  381. }} // namespace detail::ob_tran
  382. #endif // doxygen
  383. /*!
  384. \brief General Oblique Transformation projection
  385. \ingroup projections
  386. \tparam Geographic latlong point type
  387. \tparam Cartesian xy point type
  388. \tparam Parameters parameter type
  389. \par Projection characteristics
  390. - Miscellaneous
  391. - Spheroid
  392. \par Projection parameters
  393. - o_proj (string)
  394. - Plus projection parameters
  395. - o_lat_p (degrees)
  396. - o_lon_p (degrees)
  397. - New pole
  398. - o_alpha: Alpha (degrees)
  399. - o_lon_c (degrees)
  400. - o_lat_c (degrees)
  401. - o_lon_1 (degrees)
  402. - o_lat_1: Latitude of first standard parallel (degrees)
  403. - o_lon_2 (degrees)
  404. - o_lat_2: Latitude of second standard parallel (degrees)
  405. \par Example
  406. \image html ex_ob_tran.gif
  407. */
  408. template <typename T, typename Parameters>
  409. struct ob_tran_oblique : public detail::ob_tran::base_ob_tran_oblique<T, Parameters>
  410. {
  411. inline ob_tran_oblique(Parameters const& par,
  412. detail::ob_tran::par_ob_tran<T, Parameters> const& proj_parm)
  413. : detail::ob_tran::base_ob_tran_oblique<T, Parameters>(par, proj_parm)
  414. {
  415. // already done
  416. //detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm);
  417. }
  418. };
  419. /*!
  420. \brief General Oblique Transformation 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. - Miscellaneous
  427. - Spheroid
  428. \par Projection parameters
  429. - o_proj (string)
  430. - Plus projection parameters
  431. - o_lat_p (degrees)
  432. - o_lon_p (degrees)
  433. - New pole
  434. - o_alpha: Alpha (degrees)
  435. - o_lon_c (degrees)
  436. - o_lat_c (degrees)
  437. - o_lon_1 (degrees)
  438. - o_lat_1: Latitude of first standard parallel (degrees)
  439. - o_lon_2 (degrees)
  440. - o_lat_2: Latitude of second standard parallel (degrees)
  441. \par Example
  442. \image html ex_ob_tran.gif
  443. */
  444. template <typename T, typename Parameters>
  445. struct ob_tran_transverse : public detail::ob_tran::base_ob_tran_transverse<T, Parameters>
  446. {
  447. inline ob_tran_transverse(Parameters const& par,
  448. detail::ob_tran::par_ob_tran<T, Parameters> const& proj_parm)
  449. : detail::ob_tran::base_ob_tran_transverse<T, Parameters>(par, proj_parm)
  450. {
  451. // already done
  452. //detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm);
  453. }
  454. };
  455. /*!
  456. \brief General Oblique Transformation projection
  457. \ingroup projections
  458. \tparam Geographic latlong point type
  459. \tparam Cartesian xy point type
  460. \tparam Parameters parameter type
  461. \par Projection characteristics
  462. - Miscellaneous
  463. - Spheroid
  464. \par Projection parameters
  465. - o_proj (string)
  466. - Plus projection parameters
  467. - o_lat_p (degrees)
  468. - o_lon_p (degrees)
  469. - New pole
  470. - o_alpha: Alpha (degrees)
  471. - o_lon_c (degrees)
  472. - o_lat_c (degrees)
  473. - o_lon_1 (degrees)
  474. - o_lat_1: Latitude of first standard parallel (degrees)
  475. - o_lon_2 (degrees)
  476. - o_lat_2: Latitude of second standard parallel (degrees)
  477. \par Example
  478. \image html ex_ob_tran.gif
  479. */
  480. template <typename StaticParameters, typename T, typename Parameters>
  481. struct ob_tran_static : public detail::ob_tran::base_ob_tran_static<StaticParameters, T, Parameters>
  482. {
  483. inline ob_tran_static(StaticParameters const& params, Parameters const& par)
  484. : detail::ob_tran::base_ob_tran_static<StaticParameters, T, Parameters>(params, par)
  485. {
  486. T phip = detail::ob_tran::setup_ob_tran<T>(params, this->m_par, this->m_proj_parm);
  487. this->m_is_oblique = fabs(phip) > detail::ob_tran::tolerance;
  488. }
  489. };
  490. #ifndef DOXYGEN_NO_DETAIL
  491. namespace detail
  492. {
  493. // Static projection
  494. template <typename SP, typename CT, typename P>
  495. struct static_projection_type<srs::spar::proj_ob_tran, srs_sphere_tag, SP, CT, P>
  496. {
  497. typedef ob_tran_static<SP, CT, P> type;
  498. };
  499. template <typename SP, typename CT, typename P>
  500. struct static_projection_type<srs::spar::proj_ob_tran, srs_spheroid_tag, SP, CT, P>
  501. {
  502. typedef ob_tran_static<SP, CT, P> type;
  503. };
  504. // Factory entry(s)
  505. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_BEGIN(ob_tran_entry)
  506. {
  507. Parameters parameters_copy = parameters;
  508. detail::ob_tran::par_ob_tran<T, Parameters> proj_parm(params, parameters_copy);
  509. T phip = detail::ob_tran::setup_ob_tran<T>(params, parameters_copy, proj_parm);
  510. if (fabs(phip) > detail::ob_tran::tolerance)
  511. return new base_v_fi<ob_tran_oblique<T, Parameters>, T, Parameters>(parameters_copy, proj_parm);
  512. else
  513. return new base_v_fi<ob_tran_transverse<T, Parameters>, T, Parameters>(parameters_copy, proj_parm);
  514. }
  515. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_END
  516. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(ob_tran_init)
  517. {
  518. BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(ob_tran, ob_tran_entry)
  519. }
  520. } // namespace detail
  521. #endif // doxygen
  522. } // namespace projections
  523. }} // namespace boost::geometry
  524. #endif // BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP