aboutsummaryrefslogtreecommitdiff
path: root/src/ell_set.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-12-26 11:55:11 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-12-30 17:37:56 +0100
commit53a81c447114ee34b744c01ae2656cce0f250a9c (patch)
tree008f6eec141060aa99ea1997d32cab466c68f248 /src/ell_set.cpp
parente1edf114105b0f528ef662f79297603617297a6b (diff)
downloadPROJ-53a81c447114ee34b744c01ae2656cce0f250a9c.tar.gz
PROJ-53a81c447114ee34b744c01ae2656cce0f250a9c.zip
Move PJ_OBJ members into struct PJconsts
Diffstat (limited to 'src/ell_set.cpp')
-rw-r--r--src/ell_set.cpp50
1 files changed, 17 insertions, 33 deletions
diff --git a/src/ell_set.cpp b/src/ell_set.cpp
index 486230a5..ee819917 100644
--- a/src/ell_set.cpp
+++ b/src/ell_set.cpp
@@ -127,7 +127,6 @@ int pj_ellipsoid (PJ *P) {
/***************************************************************************************/
static int ellps_ellps (PJ *P) {
/***************************************************************************************/
- PJ B;
const PJ_ELLPS *ellps;
paralist *par = nullptr;
char *name;
@@ -138,11 +137,6 @@ static int ellps_ellps (PJ *P) {
if (nullptr==par)
return 0;
- /* Otherwise produce a fake PJ to make ellps_size/ellps_shape do the hard work for us */
-
- /* First move B into P's context to get error messages onto the right channel */
- B.ctx = P->ctx;
-
/* Then look up the right size and shape parameters from the builtin list */
if (strlen (par->param) < 7)
return proj_errno_set (P, PJD_ERR_INVALID_ARG);
@@ -151,23 +145,28 @@ static int ellps_ellps (PJ *P) {
if (nullptr==ellps)
return proj_errno_set (P, PJD_ERR_UNKNOWN_ELLP_PARAM);
- /* Now, get things ready for ellps_size/ellps_shape, make them do their thing, and clean up */
+ /* Now, get things ready for ellps_size/ellps_shape, make them do their thing */
err = proj_errno_reset (P);
- B = *P;
- pj_erase_ellipsoid_def (&B);
- B.params = pj_mkparam (ellps->major);
- B.params->next = pj_mkparam (ellps->ell);
- ellps_size (&B);
- ellps_shape (&B);
+ paralist* new_params = pj_mkparam (ellps->major);
+ new_params->next = pj_mkparam (ellps->ell);
+ paralist* old_params = P->params;
+ P->params = new_params;
+
+ {
+ PJ empty_PJ;
+ pj_inherit_ellipsoid_def(&empty_PJ, P);
+ }
+ ellps_size (P);
+ ellps_shape (P);
- pj_dealloc (B.params->next);
- pj_dealloc (B.params);
- if (proj_errno (&B))
- return proj_errno (&B);
+ P->params = old_params;
+ pj_dealloc (new_params->next);
+ pj_dealloc (new_params);
+ if (proj_errno (P))
+ return proj_errno (P);
/* Finally update P and sail home */
- pj_inherit_ellipsoid_def (&B, P);
P->def_ellps = par->param;
par->used = 1;
@@ -440,21 +439,6 @@ static const PJ_ELLPS *pj_find_ellps (const char *name) {
/**************************************************************************************/
-void pj_erase_ellipsoid_def (PJ *P) {
-/***************************************************************************************
- Erase all ellipsoidal parameters in P
-***************************************************************************************/
- PJ B;
-
- /* Make a blank PJ to copy from */
- memset (&B, 0, sizeof (B));
-
- /* And use it to overwrite all existing ellipsoid defs */
- pj_inherit_ellipsoid_def (&B, P);
-}
-
-
-/**************************************************************************************/
void pj_inherit_ellipsoid_def (const PJ *src, PJ *dst) {
/***************************************************************************************
Brute force copy the ellipsoidal parameters from src to dst. This code was