MCPcopy Create free account
hub / github.com/Kitware/VTK / ellps_shape

Function ellps_shape

ThirdParty/libproj/vtklibproj/src/ell_set.cpp:246–353  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

244
245/***************************************************************************************/
246static int ellps_shape (PJ *P) {
247/***************************************************************************************/
248 const char *keys[] = {"rf", "f", "es", "e", "b"};
249 paralist *par = nullptr;
250 size_t i, len;
251
252 par = nullptr;
253 len = sizeof (keys) / sizeof (char *);
254
255 free(P->def_shape);
256 P->def_shape = nullptr;
257
258 /* Check which shape key is specified */
259 for (i = 0; i < len; i++) {
260 par = pj_get_param (P->params, keys[i]);
261 if (par)
262 break;
263 }
264
265 /* Not giving a shape parameter means selecting a sphere, unless shape */
266 /* has been selected previously via ellps=xxx */
267 if (nullptr==par && P->es != 0)
268 return 0;
269 if (nullptr==par && P->es==0) {
270 P->es = P->f = 0;
271 P->b = P->a;
272 return 0;
273 }
274
275 P->def_shape = pj_strdup(par->param);
276 par->used = 1;
277 P->es = P->f = P->b = P->e = P->rf = 0;
278
279 switch (i) {
280
281 /* reverse flattening, rf */
282 case 0:
283 P->rf = pj_atof (pj_param_value (par));
284 if (HUGE_VAL==P->rf || P->rf <= 0)
285 {
286 proj_log_error(P, _("Invalid value for rf. Should be > 0"));
287 return proj_errno_set (P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE);
288 }
289 P->f = 1 / P->rf;
290 P->es = 2*P->f - P->f*P->f;
291 break;
292
293 /* flattening, f */
294 case 1:
295 P->f = pj_atof (pj_param_value (par));
296 if (HUGE_VAL==P->f || P->f < 0)
297 {
298 proj_log_error(P, _("Invalid value for f. Should be >= 0"));
299 return proj_errno_set (P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE);
300 }
301
302 P->rf = P->f != 0.0 ? 1.0/P->f: HUGE_VAL;
303 P->es = 2*P->f - P->f*P->f;

Callers 2

pj_ellipsoidFunction · 0.85
ellps_ellpsFunction · 0.85

Calls 6

pj_get_paramFunction · 0.85
pj_strdupFunction · 0.85
pj_atofFunction · 0.85
pj_param_valueFunction · 0.85
proj_log_errorFunction · 0.85
proj_errno_setFunction · 0.85

Tested by

no test coverage detected