1 /* list of projection system pj_errno values */
2
3 #include <stddef.h>
4 #include <stdio.h>
5 #include <string.h>
6
7 #include "proj.h"
8 #include "proj_config.h"
9 #include "proj_internal.h"
10
11 static const char * const
12 pj_err_list[] = {
13 "no arguments in initialization list", /* -1 */
14 "no options found in 'init' file", /* -2 */
15 "no colon in init= string", /* -3 */
16 "projection not named", /* -4 */
17 "unknown projection id", /* -5 */
18 "effective eccentricity < 0 or >= 1.", /* -6 */
19 "unknown unit conversion id", /* -7 */
20 "invalid boolean param argument", /* -8 */
21 "unknown elliptical parameter name", /* -9 */
22 "reciprocal flattening (1/f) = 0", /* -10 */
23 "|radius reference latitude| > 90", /* -11 */
24 "squared eccentricity < 0", /* -12 */
25 "major axis or radius = 0 or not given", /* -13 */
26 "latitude or longitude exceeded limits", /* -14 */
27 "invalid x or y", /* -15 */
28 "improperly formed DMS value", /* -16 */
29 "non-convergent inverse meridional dist", /* -17 */
30 "non-convergent inverse phi2", /* -18 */
31 "acos/asin: |arg| >1.+1e-14", /* -19 */
32 "tolerance condition error", /* -20 */
33 "conic lat_1 = -lat_2", /* -21 */
34 "lat_0, lat_1 or lat_2 >= 90", /* -22 */
35 "lat_1 = 0", /* -23 */
36 "lat_ts >= 90", /* -24 */
37 "no distance between control points", /* -25 */
38 "projection not selected to be rotated", /* -26 */
39 "W <= 0 or M <= 0", /* -27 */
40 "lsat not in 1-5 range", /* -28 */
41 "path not in range", /* -29 */
42 "h <= 0 or h > 1e10 * a", /* -30 */
43 "k <= 0", /* -31 */
44 "lat_1=lat_2 or lat_1=0 or lat_2=90", /* -32 */
45 "lat_0 = 0 or 90 or alpha = 90", /* -33 */
46 "elliptical usage required", /* -34 */
47 "invalid UTM zone number", /* -35 */
48 "", /* no longer used */ /* -36 */
49 "failed to find projection to be rotated", /* -37 */
50 "failed to load datum shift file", /* -38 */
51 "both n & m must be spec'd and > 0", /* -39 */
52 "n <= 0, n > 1 or not specified", /* -40 */
53 "lat_1 or lat_2 not specified", /* -41 */
54 "|lat_1| == |lat_2|", /* -42 */
55 "lat_0 is pi/2 from mean lat", /* -43 */
56 "unparseable coordinate system definition", /* -44 */
57 "geocentric transformation missing z or ellps", /* -45 */
58 "unknown prime meridian conversion id", /* -46 */
59 "illegal axis orientation combination", /* -47 */
60 "point not within available datum shift grids", /* -48 */
61 "invalid sweep axis, choose x or y", /* -49 */
62 "malformed pipeline", /* -50 */
63 "unit conversion factor must be > 0", /* -51 */
64 "invalid scale", /* -52 */
65 "non-convergent computation", /* -53 */
66 "missing required arguments", /* -54 */
67 "lat_0 = 0", /* -55 */
68 "ellipsoidal usage unsupported", /* -56 */
69 "only one +init allowed for non-pipeline operations", /* -57 */
70 "argument not numerical or out of range", /* -58 */
71 "inconsistent unit type between input and output", /* -59 */
72 "arguments are mutually exclusive", /* -60 */
73 "generic error of unknown origin", /* -61 */
74 "network error", /* -62 */
75
76 /* When adding error messages, remember to update ID defines in
77 projects.h, and transient_error array in pj_transform */
78 };
79
pj_strerrno(int err)80 char *pj_strerrno(int err) {
81 const int max_error = 9999;
82 static char note[50];
83 size_t adjusted_err;
84
85 if (0==err)
86 return nullptr;
87
88 /* System error codes are positive */
89 if (err > 0) {
90 #ifdef HAVE_STRERROR
91 return strerror(err);
92 #else
93 /* Defend string boundary against exorbitantly large err values */
94 /* which may occur on platforms with 64-bit ints */
95 sprintf(note, "no system list, errno: %d\n",
96 (err < max_error) ? err: max_error);
97 return note;
98 #endif
99 }
100
101 /* PROJ.4 error codes are negative: -1 to -9999 */
102 adjusted_err = err < -max_error ? max_error : -err - 1;
103 if (adjusted_err < (sizeof(pj_err_list) / sizeof(char *)))
104 return (char *)pj_err_list[adjusted_err];
105
106 sprintf(note, "invalid projection system error (%d)",
107 (err > -max_error) ? err: -max_error);
108 return note;
109 }
110
proj_errno_string(int err)111 const char* proj_errno_string(int err) {
112 return pj_strerrno(err);
113 }
114