diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-12-27 16:22:09 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-27 16:22:09 +0100 |
| commit | 6bb14fa874562eb4879a3b80b51b22cd2add058e (patch) | |
| tree | 450cb1f8db7247c224fc309465cea0f22b045bc8 /src/init.cpp | |
| parent | a56272923f6246edf8d41776659de2ba9d509793 (diff) | |
| download | PROJ-6bb14fa874562eb4879a3b80b51b22cd2add058e.tar.gz PROJ-6bb14fa874562eb4879a3b80b51b22cd2add058e.zip | |
Add an hardcoded +ellps=GRS80 when there is no datum/ellipsoid specification (refs #201)
Diffstat (limited to 'src/init.cpp')
| -rw-r--r-- | src/init.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp index 72ed69fe..4274f5b4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -330,6 +330,43 @@ Expand key from buffer or (if not in buffer) from init file return init_items; } + + +static void append_default_ellipsoid_to_paralist (paralist *start) { + if (nullptr==start) + 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; + auto proj = pj_param_exists (start, "proj"); + if (nullptr==proj) + return; + if (strlen (proj->param) < 6) + return; + if (0==strcmp ("pipeline", proj->param + 5)) + 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); + + /* 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) { /****************************************************************************** @@ -594,6 +631,8 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i return nullptr; } + append_default_ellipsoid_to_paralist (start); + /* Allocate projection structure */ PIN = proj(nullptr); if (nullptr==PIN) { |
