projects.hpp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // This file is manually converted from PROJ4 (projects.h)
  3. // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // This file was modified by Oracle on 2017, 2018.
  5. // Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
  6. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. // This file is converted from PROJ4, http://trac.osgeo.org/proj
  11. // PROJ4 is originally written by Gerald Evenden (then of the USGS)
  12. // PROJ4 is maintained by Frank Warmerdam
  13. // PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
  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_IMPL_PROJECTS_HPP
  31. #define BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP
  32. #include <cstring>
  33. #include <string>
  34. #include <vector>
  35. #include <boost/config.hpp>
  36. #include <boost/geometry/srs/projections/constants.hpp>
  37. #include <boost/geometry/srs/projections/dpar.hpp>
  38. #include <boost/geometry/srs/projections/spar.hpp>
  39. #include <boost/mpl/if.hpp>
  40. #include <boost/type_traits/is_pod.hpp>
  41. namespace boost { namespace geometry { namespace projections
  42. {
  43. #ifndef DOXYGEN_NO_DETAIL
  44. namespace detail
  45. {
  46. /* datum_type values */
  47. enum datum_type
  48. {
  49. datum_unknown = 0,
  50. datum_3param = 1,
  51. datum_7param = 2,
  52. datum_gridshift = 3,
  53. datum_wgs84 = 4 /* WGS84 (or anything considered equivelent) */
  54. };
  55. // Originally defined in proj_internal.h
  56. //enum pj_io_units {
  57. // pj_io_units_whatever = 0, /* Doesn't matter (or depends on pipeline neighbours) */
  58. // pj_io_units_classic = 1, /* Scaled meters (right), projected system */
  59. // pj_io_units_projected = 2, /* Meters, projected system */
  60. // pj_io_units_cartesian = 3, /* Meters, 3D cartesian system */
  61. // pj_io_units_angular = 4 /* Radians */
  62. //};
  63. // Originally defined in proj_internal.h
  64. /* Maximum latitudinal overshoot accepted */
  65. //static const double pj_epsilon_lat = 1e-12;
  66. template <typename T>
  67. struct pj_consts
  68. {
  69. // E L L I P S O I D P A R A M E T E R S
  70. T a; /* semimajor axis (radius if eccentricity==0) */
  71. T ra; /* 1/a */
  72. T e; /* first eccentricity */
  73. T es; /* first eccentricity squared */
  74. T one_es; /* 1 - e^2 */
  75. T rone_es; /* 1/one_es */
  76. T es_orig, a_orig; /* es and a before any +proj related adjustment */
  77. // C A R T O G R A P H I C O F F S E T S
  78. T lam0, phi0; /* central longitude, latitude */
  79. T x0, y0/*, z0, t0*/; /* false easting and northing (and height and time) */
  80. // S C A L I N G
  81. T k0; /* general scaling factor */
  82. T to_meter, fr_meter; /* cartesian scaling */
  83. T vto_meter, vfr_meter; /* Vertical scaling. Internal unit [m] */
  84. // D A T U M S A N D H E I G H T S Y S T E M S
  85. T from_greenwich; /* prime meridian offset (in radians) */
  86. T long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/
  87. srs::detail::towgs84<T> datum_params; /* Parameters for 3PARAM and 7PARAM */
  88. srs::detail::nadgrids nadgrids; /* Names of horozontal grid files. */
  89. detail::datum_type datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
  90. bool is_long_wrap_set;
  91. // C O O R D I N A T E H A N D L I N G
  92. bool over; /* over-range flag */
  93. bool geoc; /* geocentric latitude flag */
  94. bool is_latlong; /* proj=latlong ... not really a projection at all */
  95. bool is_geocent; /* proj=geocent ... not really a projection at all */
  96. //bool need_ellps; /* 0 for operations that are purely cartesian */
  97. //enum pj_io_units left; /* Flags for input/output coordinate types */
  98. //enum pj_io_units right;
  99. // Initialize all variables
  100. pj_consts()
  101. : a(0), ra(0)
  102. , e(0), es(0), one_es(0), rone_es(0)
  103. , es_orig(0), a_orig(0)
  104. , lam0(0), phi0(0)
  105. , x0(0), y0(0)/*, z0(0), t0(0)*/
  106. , k0(0) , to_meter(0), fr_meter(0), vto_meter(0), vfr_meter(0)
  107. , from_greenwich(0), long_wrap_center(0)
  108. , datum_type(datum_unknown)
  109. , is_long_wrap_set(false)
  110. , over(false), geoc(false), is_latlong(false), is_geocent(false)
  111. //, need_ellps(true)
  112. //, left(PJ_IO_UNITS_ANGULAR), right(PJ_IO_UNITS_CLASSIC)
  113. {}
  114. };
  115. // PROJ4 complex. Might be replaced with std::complex
  116. template <typename T>
  117. struct pj_complex { T r, i; };
  118. } // namespace detail
  119. #endif // DOXYGEN_NO_DETAIL
  120. /*!
  121. \brief parameters, projection parameters
  122. \details This structure initializes all projections
  123. \ingroup projection
  124. */
  125. template <typename T>
  126. struct parameters : public detail::pj_consts<T>
  127. {
  128. typedef T type;
  129. struct proj_id
  130. {
  131. proj_id()
  132. : id(srs::dpar::proj_unknown)
  133. {}
  134. proj_id(srs::dpar::value_proj i)
  135. : id(i)
  136. {}
  137. proj_id(std::string const& s)
  138. : id(srs::dpar::proj_unknown)
  139. , name(s)
  140. {}
  141. bool is_unknown() const
  142. {
  143. return id == srs::dpar::proj_unknown && name.empty();
  144. }
  145. // Either one of these is set:
  146. srs::dpar::value_proj id; // id of projection
  147. std::string name; // name of projection
  148. };
  149. proj_id id;
  150. };
  151. }}} // namespace boost::geometry::projections
  152. #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP