MCPcopy Create free account
hub / github.com/OSGeo/PROJ / pj_param

Function pj_param

src/param.cpp:129–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127/************************************************************************/
128
129PROJVALUE pj_param(PJ_CONTEXT *ctx, paralist *pl, const char *opt) {
130
131 int type;
132 unsigned l;
133 PROJVALUE value = {0};
134
135 if (ctx == nullptr)
136 ctx = pj_get_default_ctx();
137
138 type = *opt++;
139
140 if (nullptr == strchr("tbirds", type)) {
141 fprintf(stderr, "invalid request to pj_param, fatal\n");
142 exit(1);
143 }
144
145 pl = pj_param_exists(pl, opt);
146 if (type == 't') {
147 value.i = pl != nullptr;
148 return value;
149 }
150
151 /* Not found */
152 if (nullptr == pl) {
153 /* Return value after the switch, so that the return path is */
154 /* taken in all cases */
155 switch (type) {
156 case 'b':
157 case 'i':
158 value.i = 0;
159 break;
160 case 'd':
161 case 'r':
162 value.f = 0.;
163 break;
164 case 's':
165 value.s = nullptr;
166 break;
167 }
168 return value;
169 }
170
171 /* Found parameter - now find its value */
172 pl->used |= 1;
173 l = (int)strlen(opt);
174 opt = pl->param + l;
175 if (*opt == '=')
176 ++opt;
177
178 switch (type) {
179 case 'i': /* integer input */
180 value.i = atoi(opt);
181 for (const char *ptr = opt; *ptr != '\0'; ++ptr) {
182 if (!(*ptr >= '0' && *ptr <= '9')) {
183 proj_context_errno_set(ctx,
184 PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE);
185 value.i = 0;
186 }

Callers 15

pj_generic_grid_initFunction · 0.85
pj_hgrid_initFunction · 0.85
pj_vgrid_initFunction · 0.85
proj_init_infoFunction · 0.85
pipeline.cppFile · 0.85
proj_pj_infoFunction · 0.85
pj_datum_setFunction · 0.85
geod_setFunction · 0.85
PJ_PROJECTIONFunction · 0.85
PJ_PROJECTIONFunction · 0.85
PJ_PROJECTIONFunction · 0.85

Calls 5

pj_get_default_ctxFunction · 0.85
pj_param_existsFunction · 0.85
proj_context_errno_setFunction · 0.85
pj_atofFunction · 0.85
dmstor_ctxFunction · 0.85

Tested by

no test coverage detected