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

Function pj_create_internal

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

/

Source from the content-addressed store, hash-verified

773
774/*************************************************************************************/
775PJ *pj_create_internal (PJ_CONTEXT *ctx, const char *definition) {
776/*************************************************************************************/
777
778/**************************************************************************************
779 Create a new PJ object in the context ctx, using the given definition. If ctx==0,
780 the default context is used, if definition==0, or invalid, a null-pointer is
781 returned. The definition may use '+' as argument start indicator, as in
782 "+proj=utm +zone=32", or leave it out, as in "proj=utm zone=32".
783
784 It may even use free formatting "proj = utm; zone =32 ellps= GRS80".
785 Note that the semicolon separator is allowed, but not required.
786**************************************************************************************/
787 PJ *P;
788 char *args, **argv;
789 size_t argc, n;
790 int ret;
791 int allow_init_epsg;
792
793 if (nullptr==ctx)
794 ctx = pj_get_default_ctx ();
795
796 /* Make a copy that we can manipulate */
797 n = strlen (definition);
798 args = (char *) malloc (n + 1);
799 if (nullptr==args) {
800 proj_context_errno_set(ctx, PROJ_ERR_OTHER /*ENOMEM*/);
801 return nullptr;
802 }
803 strcpy (args, definition);
804
805 argc = pj_trim_argc (args);
806 if (argc==0) {
807 free (args);
808 proj_context_errno_set(ctx, PROJ_ERR_INVALID_OP_MISSING_ARG);
809 return nullptr;
810 }
811
812 argv = pj_trim_argv (argc, args);
813 if (!argv) {
814 free(args);
815 proj_context_errno_set(ctx, PROJ_ERR_OTHER /*ENOMEM*/);
816 return nullptr;
817 }
818
819 /* ...and let pj_init_ctx do the hard work */
820 /* New interface: forbid init=epsg:XXXX syntax by default */
821 allow_init_epsg = proj_context_get_use_proj4_init_rules(ctx, FALSE);
822 P = pj_init_ctx_with_allow_init_epsg (ctx, (int) argc, argv, allow_init_epsg);
823
824 free (argv);
825 free (args);
826
827 /* Support cs2cs-style modifiers */
828 ret = cs2cs_emulation_setup (P);
829 if (0==ret)
830 return proj_destroy (P);
831
832 return P;

Callers 4

cs2cs_emulation_setupFunction · 0.85
pj_create_argv_internalFunction · 0.85
pj_obj_createFunction · 0.85
createFromPROJStringMethod · 0.85

Calls 8

pj_get_default_ctxFunction · 0.85
proj_context_errno_setFunction · 0.85
pj_trim_argcFunction · 0.85
pj_trim_argvFunction · 0.85
cs2cs_emulation_setupFunction · 0.85
proj_destroyFunction · 0.85

Tested by

no test coverage detected