aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Knudsen <thokn@sdfe.dk>2018-02-11 19:13:10 +0100
committerThomas Knudsen <thokn@sdfe.dk>2018-02-12 11:19:34 +0100
commit5480a1ffaa38e16dd592beeaa42deb7e2cf4eadb (patch)
tree5f0d064b4dacdfa6c3d7ed4e5fb1c0e8c22bc214 /src
parentd3cc97a0cce7f01cf878be4ace8ac0bef538dd39 (diff)
downloadPROJ-5480a1ffaa38e16dd592beeaa42deb7e2cf4eadb.tar.gz
PROJ-5480a1ffaa38e16dd592beeaa42deb7e2cf4eadb.zip
Repair prior attempt to default to WGS84 if explicit ellps not needed
Diffstat (limited to 'src')
-rw-r--r--src/gie.c13
-rw-r--r--src/pj_init.c25
2 files changed, 23 insertions, 15 deletions
diff --git a/src/gie.c b/src/gie.c
index 5acec578..577ad7cf 100644
--- a/src/gie.c
+++ b/src/gie.c
@@ -1836,12 +1836,12 @@ static int pj_cart_selftest (void) {
/* linear in and out */
P = proj_create(PJ_DEFAULT_CTX,
- " +proj=helmert +ellps=GRS80"
+ " +proj=helmert"
" +x=0.0127 +y=0.0065 +z=-0.0209 +s=0.00195"
" +rx=-0.00039 +ry=0.00080 +rz=-0.00114"
" +dx=-0.0029 +dy=-0.0002 +dz=-0.0006 +ds=0.00001"
" +drx=-0.00011 +dry=-0.00019 +drz=0.00007"
- " +t_epoch=1988.0 +transpose"
+ " +t_epoch=1988.0 +transpose +no_defs"
);
if (0==P) return 0;
if (proj_angular_input (P, PJ_FWD)) return 116;
@@ -1853,8 +1853,12 @@ static int pj_cart_selftest (void) {
if (proj_angular_input (P, PJ_INV)) return 121;
if (proj_angular_output (P, PJ_FWD)) return 122;
if (proj_angular_output (P, PJ_INV)) return 123;
- proj_destroy(P);
+ /* We specified "no_defs" but didn't give any ellipsoid info */
+ /* pj_init_ctx should defualt to WGS84 */
+ if (P->a != 6378137.0) return 124;
+ if (P->f != 1.0/298.257223563) return 125;
+ proj_destroy(P);
return 0;
}
@@ -1862,9 +1866,6 @@ static int pj_cart_selftest (void) {
-
-
-
static int test_time(const char* args, double tol, double t_in, double t_exp) {
PJ_COORD in, out;
PJ *P = proj_create(PJ_DEFAULT_CTX, args);
diff --git a/src/pj_init.c b/src/pj_init.c
index be3a2457..bf098686 100644
--- a/src/pj_init.c
+++ b/src/pj_init.c
@@ -592,16 +592,23 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
return pj_default_destructor (PIN, proj_errno(PIN));
err = pj_ellipsoid (PIN);
- if (PIN->need_ellps && 0 != err) {
- pj_log (ctx, PJ_LOG_DEBUG_MINOR, "pj_init_ctx: Must specify ellipsoid or sphere");
- return pj_default_destructor (PIN, proj_errno(PIN));
- }
- if (0==err) {
- PIN->a_orig = PIN->a;
- PIN->es_orig = PIN->es;
- if (pj_calc_ellipsoid_params (PIN, PIN->a, PIN->es))
- return pj_default_destructor (PIN, PJD_ERR_ECCENTRICITY_IS_ONE);
+
+ if (err) {
+ /* Didn't get an ellps, but doesn't need one: Get a free WGS84 */
+ if (PIN->need_ellps) {
+ pj_log (ctx, PJ_LOG_DEBUG_MINOR, "pj_init_ctx: Must specify ellipsoid or sphere");
+ return pj_default_destructor (PIN, proj_errno(PIN));
+ }
+ else {
+ PIN->f = 1.0/298.257223563;
+ PIN->a_orig = PIN->a = 6378137.0;
+ PIN->es_orig = PIN->es = PIN->f*(2-PIN->f);
+ }
}
+ PIN->a_orig = PIN->a;
+ PIN->es_orig = PIN->es;
+ if (pj_calc_ellipsoid_params (PIN, PIN->a, PIN->es))
+ return pj_default_destructor (PIN, PJD_ERR_ECCENTRICITY_IS_ONE);
/* Now that we have ellipse information check for WGS84 datum */
if( PIN->datum_type == PJD_3PARAM