pj_datums.hpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // This file is manually converted from PROJ4
  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_PJ_DATUMS_HPP
  31. #define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUMS_HPP
  32. #include <boost/geometry/srs/projections/par_data.hpp>
  33. #include <boost/geometry/srs/projections/dpar.hpp>
  34. #include <string>
  35. namespace boost { namespace geometry { namespace projections {
  36. namespace detail {
  37. // Originally defined in projects.h
  38. template <typename T>
  39. struct pj_datums_type
  40. {
  41. std::string id; /* datum keyword */
  42. //std::string defn_n; /* e.g. "to_wgs84" */
  43. //std::string defn_v; /* e.g. "0,0,0" */
  44. //std::string ellipse_id; /* ie from ellipse table */
  45. //std::string comments; /* EPSG code, etc */
  46. srs::detail::nadgrids nadgrids;
  47. srs::detail::towgs84<T> towgs84;
  48. srs::dpar::value_ellps ellps;
  49. };
  50. // Originally defined in projects.h
  51. struct pj_prime_meridians_type
  52. {
  53. std::string id; /* prime meridian keyword */
  54. //std::string defn; /* offset from greenwich in DMS format. */
  55. double deg;
  56. };
  57. inline double dms2d(double d, double m, double s, bool east)
  58. {
  59. return (east ? 1 : -1) * (d + m / 60.0 + s / 3600.0);
  60. }
  61. /*
  62. * The ellipse code must match one from pj_ellps.c. The datum id should
  63. * be kept to 12 characters or less if possible. Use the official OGC
  64. * datum name for the comments if available.
  65. */
  66. template <typename T>
  67. inline std::pair<const pj_datums_type<T>*, int> pj_get_datums()
  68. {
  69. static const pj_datums_type<T> pj_datums[] =
  70. {
  71. {"WGS84", //"towgs84", "0,0,0",
  72. //"WGS84", "",
  73. srs::detail::nadgrids(),
  74. srs::detail::towgs84<T>(0,0,0),
  75. srs::dpar::ellps_wgs84},
  76. {"GGRS87", //"towgs84", "-199.87,74.79,246.62",
  77. //"GRS80", "Greek_Geodetic_Reference_System_1987",
  78. srs::detail::nadgrids(),
  79. srs::detail::towgs84<T>(-199.87,74.79,246.62),
  80. srs::dpar::ellps_grs80},
  81. {"NAD83", //"towgs84", "0,0,0",
  82. //"GRS80", "North_American_Datum_1983",
  83. srs::detail::nadgrids(),
  84. srs::detail::towgs84<T>(0,0,0),
  85. srs::dpar::ellps_grs80},
  86. {"NAD27", //"nadgrids", "@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",
  87. //"clrk66", "North_American_Datum_1927",
  88. srs::detail::nadgrids("@conus","@alaska","@ntv2_0.gsb","@ntv1_can.dat"),
  89. srs::detail::towgs84<T>(),
  90. srs::dpar::ellps_clrk66},
  91. {"potsdam", //"towgs84", "598.1,73.7,418.2,0.202,0.045,-2.455,6.7",
  92. //"bessel", "Potsdam Rauenberg 1950 DHDN",
  93. srs::detail::nadgrids(),
  94. srs::detail::towgs84<T>(598.1,73.7,418.2,0.202,0.045,-2.455,6.7),
  95. srs::dpar::ellps_bessel},
  96. {"carthage", //"towgs84", "-263.0,6.0,431.0",
  97. //"clrk80ign", "Carthage 1934 Tunisia",
  98. srs::detail::nadgrids(),
  99. srs::detail::towgs84<T>(-263.0,6.0,431.0),
  100. srs::dpar::ellps_clrk80ign},
  101. {"hermannskogel", //"towgs84", "577.326,90.129,463.919,5.137,1.474,5.297,2.4232",
  102. //"bessel", "Hermannskogel",
  103. srs::detail::nadgrids(),
  104. srs::detail::towgs84<T>(577.326,90.129,463.919,5.137,1.474,5.297,2.4232),
  105. srs::dpar::ellps_bessel},
  106. {"ire65", //"towgs84", "482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",
  107. //"mod_airy", "Ireland 1965",
  108. srs::detail::nadgrids(),
  109. srs::detail::towgs84<T>(482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15),
  110. srs::dpar::ellps_mod_airy},
  111. {"nzgd49", //"towgs84", "59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",
  112. //"intl", "New Zealand Geodetic Datum 1949",
  113. srs::detail::nadgrids(),
  114. srs::detail::towgs84<T>(59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993),
  115. srs::dpar::ellps_intl},
  116. {"OSGB36", //"towgs84", "446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",
  117. //"airy", "Airy 1830",
  118. srs::detail::nadgrids(),
  119. srs::detail::towgs84<T>(446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894),
  120. srs::dpar::ellps_airy}
  121. };
  122. return std::make_pair(pj_datums, (int)(sizeof(pj_datums) / sizeof(pj_datums[0])));
  123. }
  124. static const pj_prime_meridians_type pj_prime_meridians[] =
  125. {
  126. /* id definition */
  127. /* -- ---------- */
  128. { "greenwich", /*"0dE",*/ 0 },
  129. { "lisbon", /*"9d07'54.862\"W",*/ dms2d( 9, 7,54.862,false) },
  130. { "paris", /*"2d20'14.025\"E",*/ dms2d( 2,20,14.025,true) },
  131. { "bogota", /*"74d04'51.3\"W",*/ dms2d( 74, 4,51.3, false) },
  132. { "madrid", /*"3d41'16.58\"W",*/ dms2d( 3,41,16.58, false) },
  133. { "rome", /*"12d27'8.4\"E",*/ dms2d( 12,27, 8.4, true) },
  134. { "bern", /*"7d26'22.5\"E",*/ dms2d( 7,26,22.5, true) },
  135. { "jakarta", /*"106d48'27.79\"E",*/ dms2d(106,48,27.79, true) },
  136. { "ferro", /*"17d40'W",*/ dms2d( 17,40, 0, false) },
  137. { "brussels", /*"4d22'4.71\"E",*/ dms2d( 4,22,4.71, true) },
  138. { "stockholm", /*"18d3'29.8\"E",*/ dms2d( 18, 3,29.8, true) },
  139. { "athens", /*"23d42'58.815\"E",*/ dms2d( 23,42,58.815,true) },
  140. { "oslo", /*"10d43'22.5\"E",*/ dms2d( 10,43,22.5, true) }
  141. };
  142. } // namespace detail
  143. }}} // namespace boost::geometry::projections
  144. #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUMS_HPP