projects.hpp 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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/mpl/if.hpp>
  38. #include <boost/type_traits/is_pod.hpp>
  39. namespace boost { namespace geometry { namespace projections
  40. {
  41. #ifndef DOXYGEN_NO_DETAIL
  42. namespace detail
  43. {
  44. /* datum_type values */
  45. enum datum_type
  46. {
  47. datum_unknown = 0,
  48. datum_3param = 1,
  49. datum_7param = 2,
  50. datum_gridshift = 3,
  51. datum_wgs84 = 4 /* WGS84 (or anything considered equivelent) */
  52. };
  53. /* library errors */
  54. enum error_type
  55. {
  56. error_no_args = -1,
  57. error_no_option_in_init_file = -2,
  58. error_no_colon_in_init_string = -3,
  59. error_proj_not_named = -4,
  60. error_unknown_projection_id = -5,
  61. error_eccentricity_is_one = -6,
  62. error_unknow_unit_id = -7,
  63. error_invalid_boolean_param = -8,
  64. error_unknown_ellp_param = -9,
  65. error_rev_flattening_is_zero = -10,
  66. error_ref_rad_larger_than_90 = -11,
  67. error_es_less_than_zero = -12,
  68. error_major_axis_not_given = -13,
  69. error_lat_or_lon_exceed_limit = -14,
  70. error_invalid_x_or_y = -15,
  71. error_wrong_format_dms_value = -16,
  72. error_non_conv_inv_meri_dist = -17,
  73. error_non_con_inv_phi2 = -18,
  74. error_acos_asin_arg_too_large = -19,
  75. error_tolerance_condition = -20,
  76. error_conic_lat_equal = -21,
  77. error_lat_larger_than_90 = -22,
  78. error_lat1_is_zero = -23,
  79. error_lat_ts_larger_than_90 = -24,
  80. error_control_point_no_dist = -25,
  81. error_no_rotation_proj = -26,
  82. error_w_or_m_zero_or_less = -27,
  83. error_lsat_not_in_range = -28,
  84. error_path_not_in_range = -29,
  85. error_h_less_than_zero = -30,
  86. error_k_less_than_zero = -31,
  87. error_lat_1_or_2_zero_or_90 = -32,
  88. error_lat_0_or_alpha_eq_90 = -33,
  89. error_ellipsoid_use_required = -34,
  90. error_invalid_utm_zone = -35,
  91. error_tcheby_val_out_of_range = -36,
  92. error_failed_to_find_proj = -37,
  93. error_failed_to_load_grid = -38,
  94. error_invalid_m_or_n = -39,
  95. error_n_out_of_range = -40,
  96. error_lat_1_2_unspecified = -41,
  97. error_abs_lat1_eq_abs_lat2 = -42,
  98. error_lat_0_half_pi_from_mean = -43,
  99. error_unparseable_cs_def = -44,
  100. error_geocentric = -45,
  101. error_unknown_prime_meridian = -46,
  102. error_axis = -47,
  103. error_grid_area = -48,
  104. error_invalid_sweep_axis = -49,
  105. error_malformed_pipeline = -50,
  106. error_unit_factor_less_than_0 = -51,
  107. error_invalid_scale = -52,
  108. error_non_convergent = -53,
  109. error_missing_args = -54,
  110. error_lat_0_is_zero = -55,
  111. error_ellipsoidal_unsupported = -56,
  112. error_too_many_inits = -57,
  113. error_invalid_arg = -58
  114. };
  115. template <typename T>
  116. struct pvalue
  117. {
  118. std::string param;
  119. std::string s;
  120. //int used;
  121. };
  122. // Originally defined in proj_internal.h
  123. //enum pj_io_units {
  124. // pj_io_units_whatever = 0, /* Doesn't matter (or depends on pipeline neighbours) */
  125. // pj_io_units_classic = 1, /* Scaled meters (right), projected system */
  126. // pj_io_units_projected = 2, /* Meters, projected system */
  127. // pj_io_units_cartesian = 3, /* Meters, 3D cartesian system */
  128. // pj_io_units_angular = 4 /* Radians */
  129. //};
  130. // Originally defined in proj_internal.h
  131. /* Maximum latitudinal overshoot accepted */
  132. //static const double pj_epsilon_lat = 1e-12;
  133. template <typename T>
  134. struct pj_consts
  135. {
  136. // E L L I P S O I D P A R A M E T E R S
  137. T a; /* semimajor axis (radius if eccentricity==0) */
  138. T ra; /* 1/a */
  139. T e; /* first eccentricity */
  140. T es; /* first eccentricity squared */
  141. T one_es; /* 1 - e^2 */
  142. T rone_es; /* 1/one_es */
  143. T es_orig, a_orig; /* es and a before any +proj related adjustment */
  144. // C O O R D I N A T E H A N D L I N G
  145. int over; /* over-range flag */
  146. int geoc; /* geocentric latitude flag */
  147. int is_latlong; /* proj=latlong ... not really a projection at all */
  148. int is_geocent; /* proj=geocent ... not really a projection at all */
  149. //int need_ellps; /* 0 for operations that are purely cartesian */
  150. //enum pj_io_units left; /* Flags for input/output coordinate types */
  151. //enum pj_io_units right;
  152. // C A R T O G R A P H I C O F F S E T S
  153. T lam0, phi0; /* central longitude, latitude */
  154. T x0, y0/*, z0, t0*/; /* false easting and northing (and height and time) */
  155. // S C A L I N G
  156. T k0; /* general scaling factor */
  157. T to_meter, fr_meter; /* cartesian scaling */
  158. T vto_meter, vfr_meter; /* Vertical scaling. Internal unit [m] */
  159. // D A T U M S A N D H E I G H T S Y S T E M S
  160. detail::datum_type datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
  161. T datum_params[7]; /* Parameters for 3PARAM and 7PARAM */
  162. T from_greenwich; /* prime meridian offset (in radians) */
  163. T long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/
  164. bool is_long_wrap_set;
  165. // Initialize all variables
  166. pj_consts()
  167. : a(0), ra(0)
  168. , e(0), es(0), one_es(0), rone_es(0)
  169. , es_orig(0), a_orig(0)
  170. , over(0), geoc(0), is_latlong(0), is_geocent(0)
  171. //, need_ellps(1)
  172. //, left(PJ_IO_UNITS_ANGULAR), right(PJ_IO_UNITS_CLASSIC)
  173. , lam0(0), phi0(0)
  174. , x0(0), y0(0)/*, z0(0), t0(0)*/
  175. , k0(0) , to_meter(0), fr_meter(0), vto_meter(0), vfr_meter(0)
  176. , datum_type(datum_unknown)
  177. #if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) && (!defined(_MSC_VER) || (_MSC_VER >= 1900)) // workaround for VC++ 12 (aka 2013)
  178. , datum_params{0, 0, 0, 0, 0, 0, 0}
  179. #endif
  180. , from_greenwich(0), long_wrap_center(0), is_long_wrap_set(false)
  181. {
  182. #if defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) || (defined(_MSC_VER) && (_MSC_VER < 1900)) // workaround for VC++ 12 (aka 2013)
  183. std::fill(datum_params, datum_params + 7, T(0));
  184. #endif
  185. }
  186. };
  187. // PROJ4 complex. Might be replaced with std::complex
  188. template <typename T>
  189. struct pj_complex { T r, i; };
  190. } // namespace detail
  191. #endif // DOXYGEN_NO_DETAIL
  192. /*!
  193. \brief parameters, projection parameters
  194. \details This structure initializes all projections
  195. \ingroup projection
  196. */
  197. template <typename T>
  198. struct parameters : public detail::pj_consts<T>
  199. {
  200. typedef T type;
  201. std::string name;
  202. std::vector<detail::pvalue<T> > params;
  203. };
  204. }}} // namespace boost::geometry::projections
  205. #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP