From 715ec0b90aec05f15554c6591ea8cfd09d5cf043 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Mon, 12 Feb 2018 20:44:00 +0100 Subject: Ensure cs2cs emulation gets correct ellipsoid defn (#798) Copy ellipsoid definition for proj=cart directly into the proj_create call, rather than calling pj_inherit_ellipsoid_def afterwards. Previously, the ellipsoid definition was left out from the call. pj_init_ctx would then pick up WGS84 from proj_def.dat, and the init would succeed (and the possibly wrong ellipsoid definition would later on be overwritten with the correct values by pj_inherit_ellipsoid_def. But if PROJ_LIB was not set or proj_def.dat was inaccessible for other reasons, things went wrong. --- src/pj_geocent.c | 2 +- src/proj_4D_api.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pj_geocent.c b/src/pj_geocent.c index 6530b103..3d771c43 100644 --- a/src/pj_geocent.c +++ b/src/pj_geocent.c @@ -48,7 +48,7 @@ static LP inverse(XY xy, PJ *P) { return lp; } -PJ *PROJECTION(geocent) { +PJ *CONVERSION (geocent, 0) { P->is_geocent = 1; P->x0 = 0.0; P->y0 = 0.0; diff --git a/src/proj_4D_api.c b/src/proj_4D_api.c index 796e5769..dab4b409 100644 --- a/src/proj_4D_api.c +++ b/src/proj_4D_api.c @@ -414,6 +414,8 @@ static int pj_cs2cs_emulation_setup (PJ *P) { If any cs2cs style modifiers are given (axis=..., towgs84=..., ) create the 4D API equivalent operations, so the preparation and finalization steps in the pj_inv/pj_fwd invocators can emulate the behaviour of pj_transform and the cs2cs app. + +Returns 1 on success, 0 on failure **************************************************************************************/ PJ *Q; paralist *p; @@ -502,12 +504,11 @@ invocators can emulate the behaviour of pj_transform and the cs2cs app. /* We also need cartesian/geographical transformations if we are working in */ /* geocentric/cartesian space or we need to do a Helmert transform. */ if (P->is_geocent || P->helmert) { - char def[100]; - sprintf (def, "break_cs2cs_recursion proj=cart"); + char def[150]; + sprintf (def, "break_cs2cs_recursion proj=cart a=%40.20g f=%40.20g", P->a, P->f); Q = proj_create (P->ctx, def); if (0==Q) return 0; - pj_inherit_ellipsoid_def (P, Q); P->cart = skip_prep_fin (Q); sprintf (def, "break_cs2cs_recursion proj=cart ellps=WGS84"); @@ -521,6 +522,7 @@ invocators can emulate the behaviour of pj_transform and the cs2cs app. } + /*************************************************************************************/ PJ *proj_create (PJ_CONTEXT *ctx, const char *definition) { /************************************************************************************** -- cgit v1.2.3