aboutsummaryrefslogtreecommitdiff
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
parente1edf114105b0f528ef662f79297603617297a6b (diff)
downloadPROJ-53a81c447114ee34b744c01ae2656cce0f250a9c.tar.gz
PROJ-53a81c447114ee34b744c01ae2656cce0f250a9c.zip
Move PJ_OBJ members into struct PJconsts
-rw-r--r--src/ell_set.cpp50
-rw-r--r--src/proj_internal.h1
-rw-r--r--src/projects.h18
3 files changed, 35 insertions, 34 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
diff --git a/src/proj_internal.h b/src/proj_internal.h
index e0999d88..d5c807fb 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -115,7 +115,6 @@ void proj_context_log_debug (PJ_CONTEXT *ctx, const char *fmt, ...);
int pj_ellipsoid (PJ *);
void pj_inherit_ellipsoid_def (const PJ *src, PJ *dst);
-void pj_erase_ellipsoid_def (PJ *P);
int pj_calc_ellipsoid_params (PJ *P, double a, double es);
/* Geographical to geocentric latitude - another of the "simple, but useful" */
diff --git a/src/projects.h b/src/projects.h
index 8371b99f..4be56d8a 100644
--- a/src/projects.h
+++ b/src/projects.h
@@ -57,6 +57,11 @@
#include <stdlib.h>
#include <string.h>
+#include "proj/common.hpp"
+#include "proj/coordinateoperation.hpp"
+#include <string>
+#include <vector>
+
#ifndef PROJ_DLL
#ifdef PROJ_MSVC_DLL_EXPORT
#define PROJ_DLL __declspec(dllexport)
@@ -474,6 +479,17 @@ struct PJconsts {
PJ_Region last_after_region = {0,0,0,0}; /* TODO: Description needed */
double last_after_date = 0.0; /* TODO: Description needed */
+ /*************************************************************************************
+ ISO-19111 interface
+ **************************************************************************************/
+
+ NS_PROJ::common::IdentifiedObjectPtr iso_obj{};
+
+ // cached results
+ mutable std::string lastWKT{};
+ mutable std::string lastPROJString{};
+ mutable bool gridsNeededAsked = false;
+ mutable std::vector<NS_PROJ::operation::GridDescription> gridsNeeded{};
/*************************************************************************************
@@ -482,6 +498,8 @@ struct PJconsts {
**************************************************************************************/
PJconsts();
+ PJconsts(const PJconsts &) = delete;
+ PJconsts &operator=(const PJconsts &) = delete;
};