pj_strerrno.hpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // Boost.Geometry
  2. // This file is manually converted from PROJ4
  3. // This file was modified by Oracle on 2017, 2018.
  4. // Modifications copyright (c) 2017-2018, 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. // This file was converted to Geometry Library by Adam Wulkiewicz
  13. // Original copyright notice:
  14. // None
  15. /* list of projection system pj_errno values */
  16. #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_STRERRNO_HPP
  17. #define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_STRERRNO_HPP
  18. #include <cerrno>
  19. #include <cstring>
  20. #include <sstream>
  21. #include <string>
  22. namespace boost { namespace geometry { namespace projections
  23. {
  24. namespace detail
  25. {
  26. static const char *
  27. pj_err_list[] = {
  28. "no arguments in initialization list", /* -1 */
  29. "no options found in 'init' file", /* -2 */
  30. "no colon in init= string", /* -3 */
  31. "projection not named", /* -4 */
  32. "unknown projection id", /* -5 */
  33. "effective eccentricity = 1.", /* -6 */
  34. "unknown unit conversion id", /* -7 */
  35. "invalid boolean param argument", /* -8 */
  36. "unknown elliptical parameter name", /* -9 */
  37. "reciprocal flattening (1/f) = 0", /* -10 */
  38. "|radius reference latitude| > 90", /* -11 */
  39. "squared eccentricity < 0", /* -12 */
  40. "major axis or radius = 0 or not given", /* -13 */
  41. "latitude or longitude exceeded limits", /* -14 */
  42. "invalid x or y", /* -15 */
  43. "improperly formed DMS value", /* -16 */
  44. "non-convergent inverse meridional dist", /* -17 */
  45. "non-convergent inverse phi2", /* -18 */
  46. "acos/asin: |arg| >1.+1e-14", /* -19 */
  47. "tolerance condition error", /* -20 */
  48. "conic lat_1 = -lat_2", /* -21 */
  49. "lat_1 >= 90", /* -22 */
  50. "lat_1 = 0", /* -23 */
  51. "lat_ts >= 90", /* -24 */
  52. "no distance between control points", /* -25 */
  53. "projection not selected to be rotated", /* -26 */
  54. "W <= 0 or M <= 0", /* -27 */
  55. "lsat not in 1-5 range", /* -28 */
  56. "path not in range", /* -29 */
  57. "h <= 0", /* -30 */
  58. "k <= 0", /* -31 */
  59. "lat_0 = 0 or 90 or alpha = 90", /* -32 */
  60. "lat_1=lat_2 or lat_1=0 or lat_2=90", /* -33 */
  61. "elliptical usage required", /* -34 */
  62. "invalid UTM zone number", /* -35 */
  63. "arg(s) out of range for Tcheby eval", /* -36 */
  64. "failed to find projection to be rotated", /* -37 */
  65. "failed to load datum shift file", /* -38 */
  66. "both n & m must be spec'd and > 0", /* -39 */
  67. "n <= 0, n > 1 or not specified", /* -40 */
  68. "lat_1 or lat_2 not specified", /* -41 */
  69. "|lat_1| == |lat_2|", /* -42 */
  70. "lat_0 is pi/2 from mean lat", /* -43 */
  71. "unparseable coordinate system definition", /* -44 */
  72. "geocentric transformation missing z or ellps", /* -45 */
  73. "unknown prime meridian conversion id", /* -46 */
  74. "illegal axis orientation combination", /* -47 */
  75. "point not within available datum shift grids", /* -48 */
  76. "invalid sweep axis, choose x or y", /* -49 */
  77. "malformed pipeline", /* -50 */
  78. "unit conversion factor must be > 0", /* -51 */
  79. "invalid scale", /* -52 */
  80. "non-convergent computation", /* -53 */
  81. "missing required arguments", /* -54 */
  82. "lat_0 = 0", /* -55 */
  83. "ellipsoidal usage unsupported", /* -56 */
  84. "only one +init allowed for non-pipeline operations", /* -57 */
  85. "argument not numerical or out of range", /* -58 */
  86. /* When adding error messages, remember to update ID defines in
  87. projects.h, and transient_error array in pj_transform */
  88. };
  89. inline std::string pj_generic_strerrno(std::string const& msg, int err)
  90. {
  91. std::stringstream ss;
  92. ss << msg << " (" << err << ")";
  93. return ss.str();
  94. }
  95. inline std::string pj_strerrno(int err) {
  96. if (0==err)
  97. {
  98. return "";
  99. }
  100. else if (err > 0)
  101. {
  102. // std::strerror function may be not thread-safe
  103. //return std::strerror(err);
  104. switch(err)
  105. {
  106. #ifdef EINVAL
  107. case EINVAL:
  108. return "Invalid argument";
  109. #endif
  110. #ifdef EDOM
  111. case EDOM:
  112. return "Math argument out of domain of func";
  113. #endif
  114. #ifdef ERANGE
  115. case ERANGE:
  116. return "Math result not representable";
  117. #endif
  118. default:
  119. return pj_generic_strerrno("system error", err);
  120. }
  121. }
  122. else /*if (err < 0)*/
  123. {
  124. size_t adjusted_err = - err - 1;
  125. if (adjusted_err < (sizeof(pj_err_list) / sizeof(char *)))
  126. {
  127. return(pj_err_list[adjusted_err]);
  128. }
  129. else
  130. {
  131. return pj_generic_strerrno("invalid projection system error", err);
  132. }
  133. }
  134. }
  135. } // namespace detail
  136. }}} // namespace boost::geometry::projections
  137. #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_STRERRNO_HPP