File indexing completed on 2025-01-18 09:35:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_STRERRNO_HPP
0024 #define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_STRERRNO_HPP
0025
0026 #include <cerrno>
0027 #include <cstring>
0028 #include <sstream>
0029 #include <string>
0030
0031 namespace boost { namespace geometry { namespace projections
0032 {
0033
0034 namespace detail
0035 {
0036
0037
0038
0039 enum error_type
0040 {
0041 error_no_args = -1,
0042 error_no_option_in_init_file = -2,
0043 error_no_colon_in_init_string = -3,
0044 error_proj_not_named = -4,
0045 error_unknown_projection_id = -5,
0046 error_eccentricity_is_one = -6,
0047 error_unknow_unit_id = -7,
0048 error_invalid_boolean_param = -8,
0049 error_unknown_ellp_param = -9,
0050 error_rev_flattening_is_zero = -10,
0051 error_ref_rad_larger_than_90 = -11,
0052 error_es_less_than_zero = -12,
0053 error_major_axis_not_given = -13,
0054 error_lat_or_lon_exceed_limit = -14,
0055 error_invalid_x_or_y = -15,
0056 error_wrong_format_dms_value = -16,
0057 error_non_conv_inv_meri_dist = -17,
0058 error_non_con_inv_phi2 = -18,
0059 error_acos_asin_arg_too_large = -19,
0060 error_tolerance_condition = -20,
0061 error_conic_lat_equal = -21,
0062 error_lat_larger_than_90 = -22,
0063 error_lat1_is_zero = -23,
0064 error_lat_ts_larger_than_90 = -24,
0065 error_control_point_no_dist = -25,
0066 error_no_rotation_proj = -26,
0067 error_w_or_m_zero_or_less = -27,
0068 error_lsat_not_in_range = -28,
0069 error_path_not_in_range = -29,
0070 error_h_less_than_zero = -30,
0071 error_k_less_than_zero = -31,
0072 error_lat_1_or_2_zero_or_90 = -32,
0073 error_lat_0_or_alpha_eq_90 = -33,
0074 error_ellipsoid_use_required = -34,
0075 error_invalid_utm_zone = -35,
0076 error_tcheby_val_out_of_range = -36,
0077 error_failed_to_find_proj = -37,
0078 error_failed_to_load_grid = -38,
0079 error_invalid_m_or_n = -39,
0080 error_n_out_of_range = -40,
0081 error_lat_1_2_unspecified = -41,
0082 error_abs_lat1_eq_abs_lat2 = -42,
0083 error_lat_0_half_pi_from_mean = -43,
0084 error_unparseable_cs_def = -44,
0085 error_geocentric = -45,
0086 error_unknown_prime_meridian = -46,
0087 error_axis = -47,
0088 error_grid_area = -48,
0089 error_invalid_sweep_axis = -49,
0090 error_malformed_pipeline = -50,
0091 error_unit_factor_less_than_0 = -51,
0092 error_invalid_scale = -52,
0093 error_non_convergent = -53,
0094 error_missing_args = -54,
0095 error_lat_0_is_zero = -55,
0096 error_ellipsoidal_unsupported = -56,
0097 error_too_many_inits = -57,
0098 error_invalid_arg = -58
0099 };
0100
0101 static const char *
0102 pj_err_list[] = {
0103 "no arguments in initialization list",
0104 "no options found in 'init' file",
0105 "no colon in init= string",
0106 "projection not named",
0107 "unknown projection id",
0108 "effective eccentricity = 1.",
0109 "unknown unit conversion id",
0110 "invalid boolean param argument",
0111 "unknown elliptical parameter name",
0112 "reciprocal flattening (1/f) = 0",
0113 "|radius reference latitude| > 90",
0114 "squared eccentricity < 0",
0115 "major axis or radius = 0 or not given",
0116 "latitude or longitude exceeded limits",
0117 "invalid x or y",
0118 "improperly formed DMS value",
0119 "non-convergent inverse meridional dist",
0120 "non-convergent inverse phi2",
0121 "acos/asin: |arg| >1.+1e-14",
0122 "tolerance condition error",
0123 "conic lat_1 = -lat_2",
0124 "lat_1 >= 90",
0125 "lat_1 = 0",
0126 "lat_ts >= 90",
0127 "no distance between control points",
0128 "projection not selected to be rotated",
0129 "W <= 0 or M <= 0",
0130 "lsat not in 1-5 range",
0131 "path not in range",
0132 "h <= 0",
0133 "k <= 0",
0134 "lat_0 = 0 or 90 or alpha = 90",
0135 "lat_1=lat_2 or lat_1=0 or lat_2=90",
0136 "elliptical usage required",
0137 "invalid UTM zone number",
0138 "arg(s) out of range for Tcheby eval",
0139 "failed to find projection to be rotated",
0140 "failed to load datum shift file",
0141 "both n & m must be spec'd and > 0",
0142 "n <= 0, n > 1 or not specified",
0143 "lat_1 or lat_2 not specified",
0144 "|lat_1| == |lat_2|",
0145 "lat_0 is pi/2 from mean lat",
0146 "unparseable coordinate system definition",
0147 "geocentric transformation missing z or ellps",
0148 "unknown prime meridian conversion id",
0149 "illegal axis orientation combination",
0150 "point not within available datum shift grids",
0151 "invalid sweep axis, choose x or y",
0152 "malformed pipeline",
0153 "unit conversion factor must be > 0",
0154 "invalid scale",
0155 "non-convergent computation",
0156 "missing required arguments",
0157 "lat_0 = 0",
0158 "ellipsoidal usage unsupported",
0159 "only one +init allowed for non-pipeline operations",
0160 "argument not numerical or out of range",
0161
0162
0163
0164 };
0165
0166 inline std::string pj_generic_strerrno(std::string const& msg, int err)
0167 {
0168 std::stringstream ss;
0169 ss << msg << " (" << err << ")";
0170 return ss.str();
0171 }
0172
0173 inline std::string pj_strerrno(int err) {
0174 if (0==err)
0175 {
0176 return "";
0177 }
0178 else if (err > 0)
0179 {
0180
0181
0182
0183 switch(err)
0184 {
0185 #ifdef EINVAL
0186 case EINVAL:
0187 return "Invalid argument";
0188 #endif
0189 #ifdef EDOM
0190 case EDOM:
0191 return "Math argument out of domain of func";
0192 #endif
0193 #ifdef ERANGE
0194 case ERANGE:
0195 return "Math result not representable";
0196 #endif
0197 default:
0198 return pj_generic_strerrno("system error", err);
0199 }
0200 }
0201 else
0202 {
0203 size_t adjusted_err = - err - 1;
0204 if (adjusted_err < (sizeof(pj_err_list) / sizeof(char *)))
0205 {
0206 return(pj_err_list[adjusted_err]);
0207 }
0208 else
0209 {
0210 return pj_generic_strerrno("invalid projection system error", err);
0211 }
0212 }
0213 }
0214
0215 }
0216
0217 }}}
0218
0219 #endif