diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2018-12-27 22:16:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-27 22:16:10 +0100 |
| commit | 123011447a2d7d25041cc3e466408a0d81bb4d3b (patch) | |
| tree | 450cb1f8db7247c224fc309465cea0f22b045bc8 /src | |
| parent | 81ec8c0b58d66333fccd3703dab62a11132a0331 (diff) | |
| parent | 6bb14fa874562eb4879a3b80b51b22cd2add058e (diff) | |
| download | PROJ-123011447a2d7d25041cc3e466408a0d81bb4d3b.tar.gz PROJ-123011447a2d7d25041cc3e466408a0d81bb4d3b.zip | |
Merge pull request #1210 from rouault/remove_proj_defs_dat
Remove proj_def.dat (#201)
Diffstat (limited to 'src')
| -rw-r--r-- | src/init.cpp | 81 | ||||
| -rw-r--r-- | src/projections/lagrng.cpp | 5 | ||||
| -rw-r--r-- | src/tests/multistresstest.cpp | 13 | ||||
| -rw-r--r-- | src/tests/test228.cpp | 5 | ||||
| -rw-r--r-- | src/transformations/deformation.cpp | 3 |
5 files changed, 31 insertions, 76 deletions
diff --git a/src/init.cpp b/src/init.cpp index 5710031c..4274f5b4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -332,74 +332,41 @@ Expand key from buffer or (if not in buffer) from init file -static paralist *append_defaults_to_paralist (PJ_CONTEXT *ctx, paralist *start, const char *key, int allow_init_epsg) { - paralist *defaults, *last = nullptr; - char keystring[ID_TAG_MAX + 20]; - paralist *next, *proj; - int err; - +static void append_default_ellipsoid_to_paralist (paralist *start) { if (nullptr==start) - return nullptr; - - if (strlen(key) > ID_TAG_MAX) - return nullptr; + return; /* Set defaults, unless inhibited (either explicitly through a "no_defs" token */ /* or implicitly, because we are initializing a pipeline) */ if (pj_param_exists (start, "no_defs")) - return start; - proj = pj_param_exists (start, "proj"); + return; + auto proj = pj_param_exists (start, "proj"); if (nullptr==proj) - return start; + return; if (strlen (proj->param) < 6) - return start; + return; if (0==strcmp ("pipeline", proj->param + 5)) - return start; - - err = pj_ctx_get_errno (ctx); - pj_ctx_set_errno (ctx, 0); + return; + + /* Don't default ellipse if datum, ellps or any ellipsoid information is set */ + if (pj_param_exists (start, "datum")) return; + if (pj_param_exists (start, "ellps")) return; + if (pj_param_exists (start, "a")) return; + if (pj_param_exists (start, "b")) return; + if (pj_param_exists (start, "rf")) return; + if (pj_param_exists (start, "f")) return; + if (pj_param_exists (start, "e")) return; + if (pj_param_exists (start, "es")) return; /* Locate end of start-list */ + paralist *last = nullptr; for (last = start; last->next; last = last->next); - strcpy (keystring, "proj_def.dat:"); - strcat (keystring, key); - defaults = get_init (ctx, keystring, allow_init_epsg); - - /* Defaults are optional - so we don't care if we cannot open the file */ - pj_ctx_set_errno (ctx, err); - - if (!defaults) - return last; - - /* Loop over all default items */ - for (next = defaults; next; next = next->next) { - - /* Don't override existing parameter value of same name */ - if (pj_param_exists (start, next->param)) - continue; - - /* Don't default ellipse if datum, ellps or any ellipsoid information is set */ - if (0==strncmp(next->param,"ellps=", 6)) { - if (pj_param_exists (start, "datum")) continue; - if (pj_param_exists (start, "ellps")) continue; - if (pj_param_exists (start, "a")) continue; - if (pj_param_exists (start, "b")) continue; - if (pj_param_exists (start, "rf")) continue; - if (pj_param_exists (start, "f")) continue; - if (pj_param_exists (start, "e")) continue; - if (pj_param_exists (start, "es")) continue; - } - - /* If we're here, it's OK to append the current default item */ - last = last->next = pj_mkparam(next->param); - } - last->next = nullptr; - - pj_dealloc_params (ctx, defaults, 0); - return last; + /* If we're here, it's OK to append the current default item */ + last->next = pj_mkparam("ellps=GRS80"); } + /*****************************************************************************/ static paralist *pj_expand_init_internal(PJ_CONTEXT *ctx, paralist *init, int allow_init_epsg) { /****************************************************************************** @@ -664,11 +631,7 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i return nullptr; } - - /* Append general and projection specific defaults to the definition list */ - append_defaults_to_paralist (ctx, start, "general", allow_init_epsg); - append_defaults_to_paralist (ctx, start, name, allow_init_epsg); - + append_default_ellipsoid_to_paralist (start); /* Allocate projection structure */ PIN = proj(nullptr); diff --git a/src/projections/lagrng.cpp b/src/projections/lagrng.cpp index 8c0150aa..a119ea31 100644 --- a/src/projections/lagrng.cpp +++ b/src/projections/lagrng.cpp @@ -76,7 +76,10 @@ PJ *PROJECTION(lagrng) { return pj_default_destructor (P, ENOMEM); P->opaque = Q; - Q->w = pj_param(P->ctx, P->params, "dW").f; + if( pj_param(P->ctx, P->params, "tW").i ) + Q->w = pj_param(P->ctx, P->params, "dW").f; + else + Q->w = 2; if (Q->w <= 0) return pj_default_destructor(P, PJD_ERR_W_OR_M_ZERO_OR_LESS); Q->hw = 0.5 * Q->w; diff --git a/src/tests/multistresstest.cpp b/src/tests/multistresstest.cpp index 234783b3..33d2d738 100644 --- a/src/tests/multistresstest.cpp +++ b/src/tests/multistresstest.cpp @@ -46,7 +46,6 @@ #define num_threads 10 static int num_iterations = 1000000; static int reinit_every_iteration=0; -static int add_no_defs = 0; typedef struct { const char *src_def; @@ -179,15 +178,7 @@ static volatile int active_thread_count = 0; static projPJ custom_pj_init_plus_ctx(projCtx ctx, const char* def) { - if( add_no_defs ) - { - char szBuffer[256]; - strcpy(szBuffer, def); - strcat(szBuffer, " +no_defs"); - return pj_init_plus_ctx(ctx, szBuffer); - } - else - return pj_init_plus_ctx(ctx, def); + return pj_init_plus_ctx(ctx, def); } /************************************************************************/ @@ -462,8 +453,6 @@ int main( int argc, char **argv ) { if( strcmp(argv[i], "-reinit") == 0 ) reinit_every_iteration = 1; - else if( strcmp(argv[i], "-add_no_defs") == 0 ) - add_no_defs = 1; else if( strcmp(argv[i], "-num_iterations") == 0 && i+1 < argc ) { num_iterations = atoi(argv[i+1]); diff --git a/src/tests/test228.cpp b/src/tests/test228.cpp index fcacd7c9..4fadda94 100644 --- a/src/tests/test228.cpp +++ b/src/tests/test228.cpp @@ -36,10 +36,9 @@ static void* thread_main(void* unused) p_proj_ctxt=pj_ctx_alloc(); p_WGS84_proj=pj_init_plus_ctx(p_proj_ctxt,"+proj=longlat " - "+ellps=WGS84 +datum=WGS84 +no_defs"); + "+ellps=WGS84 +datum=WGS84"); p_OSGB36_proj=pj_init_plus_ctx(p_proj_ctxt, - "+proj=longlat +ellps=airy +datum=OSGB36 +nadgrids=OSTN02_NTv2.gsb " - "+no_defs"); + "+proj=longlat +ellps=airy +datum=OSGB36 +nadgrids=OSTN02_NTv2.gsb"); while(run) { diff --git a/src/transformations/deformation.cpp b/src/transformations/deformation.cpp index 6c30f21c..0197cf5c 100644 --- a/src/transformations/deformation.cpp +++ b/src/transformations/deformation.cpp @@ -269,7 +269,8 @@ PJ *TRANSFORMATION(deformation,1) { return destructor(P, ENOMEM); P->opaque = (void *) Q; - Q->cart = proj_create(P->ctx, "+proj=cart"); + // Pass a dummy ellipsoid definition that will be overridden just afterwards + Q->cart = proj_create(P->ctx, "+proj=cart +a=1"); if (Q->cart == nullptr) return destructor(P, ENOMEM); |
