Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline instanciation: fix performance issues on huge (broken) strings... #2824

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 10 additions & 24 deletions src/4D_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,11 +784,8 @@ PJ *pj_create_internal (PJ_CONTEXT *ctx, const char *definition) {
It may even use free formatting "proj = utm; zone =32 ellps= GRS80".
Note that the semicolon separator is allowed, but not required.
**************************************************************************************/
PJ *P;
char *args, **argv;
size_t argc, n;
int ret;
int allow_init_epsg;

if (nullptr==ctx)
ctx = pj_get_default_ctx ();
Expand Down Expand Up @@ -816,19 +813,11 @@ PJ *pj_create_internal (PJ_CONTEXT *ctx, const char *definition) {
return nullptr;
}

/* ...and let pj_init_ctx do the hard work */
/* New interface: forbid init=epsg:XXXX syntax by default */
allow_init_epsg = proj_context_get_use_proj4_init_rules(ctx, FALSE);
P = pj_init_ctx_with_allow_init_epsg (ctx, (int) argc, argv, allow_init_epsg);
PJ* P = pj_create_argv_internal (ctx, (int) argc, argv);

free (argv);
free (args);

/* Support cs2cs-style modifiers */
ret = cs2cs_emulation_setup (P);
if (0==ret)
return proj_destroy (P);

return P;
}

Expand Down Expand Up @@ -867,28 +856,25 @@ indicator, as in {"+proj=utm", "+zone=32"}, or leave it out, as in {"proj=utm",
/*************************************************************************************/
PJ *pj_create_argv_internal (PJ_CONTEXT *ctx, int argc, char **argv) {
/**************************************************************************************
Same as proj_create_argv() but calls pj_create_internal() instead of proj_create() internally
For use by pipeline init function.
**************************************************************************************/
PJ *P;
const char *c;

if (nullptr==ctx)
ctx = pj_get_default_ctx ();
if (nullptr==argv) {
proj_context_errno_set(ctx, PROJ_ERR_INVALID_OP_MISSING_ARG);
return nullptr;
}

/* We assume that free format is used, and build a full proj_create compatible string */
c = pj_make_args (argc, argv);
if (nullptr==c) {
proj_context_errno_set(ctx, PROJ_ERR_OTHER /*ENOMEM*/);
return nullptr;
}
/* ...and let pj_init_ctx do the hard work */
/* New interface: forbid init=epsg:XXXX syntax by default */
const int allow_init_epsg = proj_context_get_use_proj4_init_rules(ctx, FALSE);
PJ* P = pj_init_ctx_with_allow_init_epsg (ctx, argc, argv, allow_init_epsg);

P = pj_create_internal (ctx, c);
/* Support cs2cs-style modifiers */
int ret = cs2cs_emulation_setup (P);
if (0==ret)
return proj_destroy (P);

free ((char *) c);
return P;
}

Expand Down