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

Function pj_init_ctx_with_allow_init_epsg

ThirdParty/libproj/vtklibproj/src/init.cpp:426–784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424
425
426PJ *
427pj_init_ctx_with_allow_init_epsg(PJ_CONTEXT *ctx, int argc, char **argv, int allow_init_epsg) {
428 const char *s;
429 char *name;
430 PJ_CONSTRUCTOR proj;
431 paralist *curr, *init, *start;
432 int i;
433 int err;
434 PJ *PIN = nullptr;
435 int n_pipelines = 0;
436 int n_inits = 0;
437 const PJ_UNITS *units;
438 const PJ_PRIME_MERIDIANS *prime_meridians;
439
440 if (nullptr==ctx)
441 ctx = pj_get_default_ctx ();
442
443 ctx->last_errno = 0;
444
445 if (argc <= 0) {
446 pj_log(ctx, PJ_LOG_ERROR, _("No arguments"));
447 proj_context_errno_set (ctx, PROJ_ERR_INVALID_OP_MISSING_ARG);
448 return nullptr;
449 }
450
451 /* count occurrences of pipelines and inits */
452 for (i = 0; i < argc; ++i) {
453 if (!strcmp (argv[i], "+proj=pipeline") || !strcmp(argv[i], "proj=pipeline") )
454 n_pipelines++;
455 if (!strncmp (argv[i], "+init=", 6) || !strncmp(argv[i], "init=", 5))
456 n_inits++;
457 }
458
459 /* can't have nested pipelines directly */
460 if (n_pipelines > 1) {
461 pj_log(ctx, PJ_LOG_ERROR, _("Nested pipelines are not supported"));
462 proj_context_errno_set (ctx, PROJ_ERR_INVALID_OP_WRONG_SYNTAX);
463 return nullptr;
464 }
465
466 /* don't allow more than one +init in non-pipeline operations */
467 if (n_pipelines == 0 && n_inits > 1) {
468 pj_log(ctx, PJ_LOG_ERROR, _("Too many inits"));
469 proj_context_errno_set (ctx, PROJ_ERR_INVALID_OP_WRONG_SYNTAX);
470 return nullptr;
471 }
472
473
474 /* put arguments into internal linked list */
475 start = curr = pj_mkparam(argv[0]);
476 if (!curr) {
477 free_params (ctx, start, PROJ_ERR_OTHER /*ENOMEM*/);
478 return nullptr;
479 }
480
481 for (i = 1; i < argc; ++i) {
482 curr->next = pj_mkparam(argv[i]);
483 if (!curr->next) {

Callers 1

pj_create_internalFunction · 0.85

Calls 15

pj_get_default_ctxFunction · 0.85
pj_logFunction · 0.85
proj_context_errno_setFunction · 0.85
pj_mkparamFunction · 0.85
free_paramsFunction · 0.85
pj_param_existsFunction · 0.85
pj_expand_init_internalFunction · 0.85
locate_constructorFunction · 0.85
pj_datum_setFunction · 0.85
pj_default_destructorFunction · 0.85
proj_errnoFunction · 0.85

Tested by

no test coverage detected