aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/source/operations/options/ellps.rst2
-rw-r--r--docs/source/usage/differences.rst5
-rw-r--r--src/init.cpp39
-rw-r--r--test/gie/ellipsoid.gie3
-rw-r--r--test/unit/gie_self_tests.cpp4
5 files changed, 47 insertions, 6 deletions
diff --git a/docs/source/operations/options/ellps.rst b/docs/source/operations/options/ellps.rst
index af98d377..b754f741 100644
--- a/docs/source/operations/options/ellps.rst
+++ b/docs/source/operations/options/ellps.rst
@@ -2,4 +2,4 @@
See :option:`proj -le` for a list of available ellipsoids.
- *Defaults to "WGS84".*
+ *Defaults to "GRS80".*
diff --git a/docs/source/usage/differences.rst b/docs/source/usage/differences.rst
index 1f7769d3..5694e4d0 100644
--- a/docs/source/usage/differences.rst
+++ b/docs/source/usage/differences.rst
@@ -66,5 +66,6 @@ Removal of proj_def.dat
-----------------------
Before PROJ 6, the proj_def.dat was used to provide general and per-projection
-parameters, when +no_defs was not specified. It has now been removed. In
-particular, the +ellps=WGS84 is no longer a default.
+parameters, when +no_defs was not specified. It has now been removed. In case,
+no ellipsoid or datum specification is provided in the PROJ string, the
+default ellipsoid is GRS80 (was WGS84 in previous PROJ versions).
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) {
diff --git a/test/gie/ellipsoid.gie b/test/gie/ellipsoid.gie
index 88419346..929eb799 100644
--- a/test/gie/ellipsoid.gie
+++ b/test/gie/ellipsoid.gie
@@ -58,7 +58,8 @@ operation proj=merc +a=-1
expect failure errno major_axis_not_given
operation proj=merc
-expect failure errno major_axis_not_given
+accept 0 0
+expect 0 0
operation proj=merc +es=-1
expect failure errno major_axis_not_given
diff --git a/test/unit/gie_self_tests.cpp b/test/unit/gie_self_tests.cpp
index 4e788358..9ff7a278 100644
--- a/test/unit/gie_self_tests.cpp
+++ b/test/unit/gie_self_tests.cpp
@@ -500,9 +500,9 @@ TEST(gie, io_predicates) {
ASSERT_FALSE(proj_angular_output(P, PJ_FWD));
ASSERT_FALSE(proj_angular_output(P, PJ_INV));
- /* pj_init_ctx should default to WGS84 */
+ /* pj_init_ctx should default to GRS80 */
ASSERT_EQ(P->a, 6378137.0);
- ASSERT_EQ(P->f, 1.0 / 298.257223563);
+ ASSERT_EQ(P->f, 1.0 / 298.257222101);
proj_destroy(P);
/* Test that pj_fwd* and pj_inv* returns NaNs when receiving NaN input */