]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | // Boost.Geometry |
2 | // This file is manually converted from PROJ4 | |
3 | ||
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 | ||
8 | // Use, modification and distribution is subject to the Boost Software License, | |
9 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
10 | // http://www.boost.org/LICENSE_1_0.txt) | |
11 | ||
12 | // This file is converted from PROJ4, http://trac.osgeo.org/proj | |
13 | // PROJ4 is originally written by Gerald Evenden (then of the USGS) | |
14 | // PROJ4 is maintained by Frank Warmerdam | |
15 | // This file was converted to Geometry Library by Adam Wulkiewicz | |
16 | ||
17 | // Original copyright notice: | |
18 | ||
19 | // None | |
20 | ||
21 | /* list of projection system pj_errno values */ | |
22 | ||
23 | #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_STRERRNO_HPP | |
24 | #define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_STRERRNO_HPP | |
25 | ||
26 | #include <cerrno> | |
27 | #include <cstring> | |
28 | #include <sstream> | |
29 | #include <string> | |
30 | ||
31 | namespace boost { namespace geometry { namespace projections | |
32 | { | |
33 | ||
34 | namespace detail | |
35 | { | |
36 | ||
92f5a8d4 TL |
37 | // Originally defined in projects.hpp |
38 | /* library errors */ | |
39 | enum error_type | |
40 | { | |
41 | error_no_args = -1, | |
42 | error_no_option_in_init_file = -2, | |
43 | error_no_colon_in_init_string = -3, | |
44 | error_proj_not_named = -4, | |
45 | error_unknown_projection_id = -5, | |
46 | error_eccentricity_is_one = -6, | |
47 | error_unknow_unit_id = -7, | |
48 | error_invalid_boolean_param = -8, | |
49 | error_unknown_ellp_param = -9, | |
50 | error_rev_flattening_is_zero = -10, | |
51 | error_ref_rad_larger_than_90 = -11, | |
52 | error_es_less_than_zero = -12, | |
53 | error_major_axis_not_given = -13, | |
54 | error_lat_or_lon_exceed_limit = -14, | |
55 | error_invalid_x_or_y = -15, | |
56 | error_wrong_format_dms_value = -16, | |
57 | error_non_conv_inv_meri_dist = -17, | |
58 | error_non_con_inv_phi2 = -18, | |
59 | error_acos_asin_arg_too_large = -19, | |
60 | error_tolerance_condition = -20, | |
61 | error_conic_lat_equal = -21, | |
62 | error_lat_larger_than_90 = -22, | |
63 | error_lat1_is_zero = -23, | |
64 | error_lat_ts_larger_than_90 = -24, | |
65 | error_control_point_no_dist = -25, | |
66 | error_no_rotation_proj = -26, | |
67 | error_w_or_m_zero_or_less = -27, | |
68 | error_lsat_not_in_range = -28, | |
69 | error_path_not_in_range = -29, | |
70 | error_h_less_than_zero = -30, | |
71 | error_k_less_than_zero = -31, | |
72 | error_lat_1_or_2_zero_or_90 = -32, | |
73 | error_lat_0_or_alpha_eq_90 = -33, | |
74 | error_ellipsoid_use_required = -34, | |
75 | error_invalid_utm_zone = -35, | |
76 | error_tcheby_val_out_of_range = -36, | |
77 | error_failed_to_find_proj = -37, | |
78 | error_failed_to_load_grid = -38, | |
79 | error_invalid_m_or_n = -39, | |
80 | error_n_out_of_range = -40, | |
81 | error_lat_1_2_unspecified = -41, | |
82 | error_abs_lat1_eq_abs_lat2 = -42, | |
83 | error_lat_0_half_pi_from_mean = -43, | |
84 | error_unparseable_cs_def = -44, | |
85 | error_geocentric = -45, | |
86 | error_unknown_prime_meridian = -46, | |
87 | error_axis = -47, | |
88 | error_grid_area = -48, | |
89 | error_invalid_sweep_axis = -49, | |
90 | error_malformed_pipeline = -50, | |
91 | error_unit_factor_less_than_0 = -51, | |
92 | error_invalid_scale = -52, | |
93 | error_non_convergent = -53, | |
94 | error_missing_args = -54, | |
95 | error_lat_0_is_zero = -55, | |
96 | error_ellipsoidal_unsupported = -56, | |
97 | error_too_many_inits = -57, | |
98 | error_invalid_arg = -58 | |
99 | }; | |
100 | ||
11fdf7f2 TL |
101 | static const char * |
102 | pj_err_list[] = { | |
103 | "no arguments in initialization list", /* -1 */ | |
104 | "no options found in 'init' file", /* -2 */ | |
105 | "no colon in init= string", /* -3 */ | |
106 | "projection not named", /* -4 */ | |
107 | "unknown projection id", /* -5 */ | |
108 | "effective eccentricity = 1.", /* -6 */ | |
109 | "unknown unit conversion id", /* -7 */ | |
110 | "invalid boolean param argument", /* -8 */ | |
111 | "unknown elliptical parameter name", /* -9 */ | |
112 | "reciprocal flattening (1/f) = 0", /* -10 */ | |
113 | "|radius reference latitude| > 90", /* -11 */ | |
114 | "squared eccentricity < 0", /* -12 */ | |
115 | "major axis or radius = 0 or not given", /* -13 */ | |
116 | "latitude or longitude exceeded limits", /* -14 */ | |
117 | "invalid x or y", /* -15 */ | |
118 | "improperly formed DMS value", /* -16 */ | |
119 | "non-convergent inverse meridional dist", /* -17 */ | |
120 | "non-convergent inverse phi2", /* -18 */ | |
121 | "acos/asin: |arg| >1.+1e-14", /* -19 */ | |
122 | "tolerance condition error", /* -20 */ | |
123 | "conic lat_1 = -lat_2", /* -21 */ | |
124 | "lat_1 >= 90", /* -22 */ | |
125 | "lat_1 = 0", /* -23 */ | |
126 | "lat_ts >= 90", /* -24 */ | |
127 | "no distance between control points", /* -25 */ | |
128 | "projection not selected to be rotated", /* -26 */ | |
129 | "W <= 0 or M <= 0", /* -27 */ | |
130 | "lsat not in 1-5 range", /* -28 */ | |
131 | "path not in range", /* -29 */ | |
132 | "h <= 0", /* -30 */ | |
133 | "k <= 0", /* -31 */ | |
134 | "lat_0 = 0 or 90 or alpha = 90", /* -32 */ | |
135 | "lat_1=lat_2 or lat_1=0 or lat_2=90", /* -33 */ | |
136 | "elliptical usage required", /* -34 */ | |
137 | "invalid UTM zone number", /* -35 */ | |
138 | "arg(s) out of range for Tcheby eval", /* -36 */ | |
139 | "failed to find projection to be rotated", /* -37 */ | |
140 | "failed to load datum shift file", /* -38 */ | |
141 | "both n & m must be spec'd and > 0", /* -39 */ | |
142 | "n <= 0, n > 1 or not specified", /* -40 */ | |
143 | "lat_1 or lat_2 not specified", /* -41 */ | |
144 | "|lat_1| == |lat_2|", /* -42 */ | |
145 | "lat_0 is pi/2 from mean lat", /* -43 */ | |
146 | "unparseable coordinate system definition", /* -44 */ | |
147 | "geocentric transformation missing z or ellps", /* -45 */ | |
148 | "unknown prime meridian conversion id", /* -46 */ | |
149 | "illegal axis orientation combination", /* -47 */ | |
150 | "point not within available datum shift grids", /* -48 */ | |
151 | "invalid sweep axis, choose x or y", /* -49 */ | |
152 | "malformed pipeline", /* -50 */ | |
92f5a8d4 TL |
153 | "unit conversion factor must be > 0", /* -51 */ |
154 | "invalid scale", /* -52 */ | |
155 | "non-convergent computation", /* -53 */ | |
156 | "missing required arguments", /* -54 */ | |
157 | "lat_0 = 0", /* -55 */ | |
158 | "ellipsoidal usage unsupported", /* -56 */ | |
159 | "only one +init allowed for non-pipeline operations", /* -57 */ | |
160 | "argument not numerical or out of range", /* -58 */ | |
161 | ||
162 | /* When adding error messages, remember to update ID defines in | |
163 | projects.h, and transient_error array in pj_transform */ | |
11fdf7f2 TL |
164 | }; |
165 | ||
166 | inline std::string pj_generic_strerrno(std::string const& msg, int err) | |
167 | { | |
168 | std::stringstream ss; | |
169 | ss << msg << " (" << err << ")"; | |
170 | return ss.str(); | |
171 | } | |
172 | ||
173 | inline std::string pj_strerrno(int err) { | |
174 | if (0==err) | |
175 | { | |
176 | return ""; | |
177 | } | |
178 | else if (err > 0) | |
179 | { | |
180 | // std::strerror function may be not thread-safe | |
181 | //return std::strerror(err); | |
182 | ||
183 | switch(err) | |
184 | { | |
185 | #ifdef EINVAL | |
186 | case EINVAL: | |
187 | return "Invalid argument"; | |
188 | #endif | |
189 | #ifdef EDOM | |
190 | case EDOM: | |
191 | return "Math argument out of domain of func"; | |
192 | #endif | |
193 | #ifdef ERANGE | |
194 | case ERANGE: | |
195 | return "Math result not representable"; | |
196 | #endif | |
197 | default: | |
198 | return pj_generic_strerrno("system error", err); | |
199 | } | |
200 | } | |
201 | else /*if (err < 0)*/ | |
202 | { | |
203 | size_t adjusted_err = - err - 1; | |
204 | if (adjusted_err < (sizeof(pj_err_list) / sizeof(char *))) | |
205 | { | |
206 | return(pj_err_list[adjusted_err]); | |
207 | } | |
208 | else | |
209 | { | |
210 | return pj_generic_strerrno("invalid projection system error", err); | |
211 | } | |
212 | } | |
213 | } | |
214 | ||
215 | } // namespace detail | |
216 | ||
217 | }}} // namespace boost::geometry::projections | |
218 | ||
219 | #endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_STRERRNO_HPP |