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

Function cs2cs_emulation_setup

ThirdParty/libproj/vtklibproj/src/4D_api.cpp:636–771  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

634
635/*************************************************************************************/
636static int cs2cs_emulation_setup (PJ *P) {
637/**************************************************************************************
638If any cs2cs style modifiers are given (axis=..., towgs84=..., ) create the 4D API
639equivalent operations, so the preparation and finalization steps in the pj_inv/pj_fwd
640invocators can emulate the behavior of pj_transform and the cs2cs app.
641
642Returns 1 on success, 0 on failure
643**************************************************************************************/
644 PJ *Q;
645 paralist *p;
646 int do_cart = 0;
647 if (nullptr==P)
648 return 0;
649
650 /* Don't recurse when calling proj_create (which calls us back) */
651 if (pj_param_exists (P->params, "break_cs2cs_recursion"))
652 return 1;
653
654 /* Swap axes? */
655 p = pj_param_exists (P->params, "axis");
656
657 const bool disable_grid_presence_check = pj_param_exists (
658 P->params, "disable_grid_presence_check") != nullptr;
659
660 /* Don't axisswap if data are already in "enu" order */
661 if (p && (0!=strcmp ("enu", p->param))) {
662 char *def = static_cast<char*>(malloc (100+strlen(P->axis)));
663 if (nullptr==def)
664 return 0;
665 sprintf (def, "break_cs2cs_recursion proj=axisswap axis=%s", P->axis);
666 Q = pj_create_internal (P->ctx, def);
667 free (def);
668 if (nullptr==Q)
669 return 0;
670 P->axisswap = skip_prep_fin(Q);
671 }
672
673 /* Geoid grid(s) given? */
674 p = pj_param_exists (P->params, "geoidgrids");
675 if (!disable_grid_presence_check && p && strlen (p->param) > strlen ("geoidgrids=")) {
676 char *gridnames = p->param + strlen ("geoidgrids=");
677 char *def = static_cast<char*>(malloc (100+2*strlen(gridnames)));
678 if (nullptr==def)
679 return 0;
680 sprintf (def, "break_cs2cs_recursion proj=vgridshift grids=%s",
681 pj_double_quote_string_param_if_needed(gridnames).c_str());
682 Q = pj_create_internal (P->ctx, def);
683 free (def);
684 if (nullptr==Q)
685 return 0;
686 P->vgridshift = skip_prep_fin(Q);
687 }
688
689 /* Datum shift grid(s) given? */
690 p = pj_param_exists (P->params, "nadgrids");
691 if (!disable_grid_presence_check && p && strlen (p->param) > strlen ("nadgrids=")) {
692 char *gridnames = p->param + strlen ("nadgrids=");
693 char *def = static_cast<char*>(malloc (100+2*strlen(gridnames)));

Callers 1

pj_create_internalFunction · 0.85

Calls 7

pj_param_existsFunction · 0.85
sprintfFunction · 0.85
pj_create_internalFunction · 0.85
skip_prep_finFunction · 0.85
pj_inherit_ellipsoid_defFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected