aboutsummaryrefslogtreecommitdiff
path: root/src/pj_internal.c
diff options
context:
space:
mode:
authorThomas Knudsen <busstoptaktik@users.noreply.github.com>2018-01-03 21:06:58 +0100
committerGitHub <noreply@github.com>2018-01-03 21:06:58 +0100
commita3a67fb366e4628e5bda9e30b93b73648665e4d3 (patch)
tree30d49dbe319a16c5ba058ff886512116238b4c0e /src/pj_internal.c
parent403f930355926aced5caba5bfbcc230ad152cf86 (diff)
downloadPROJ-a3a67fb366e4628e5bda9e30b93b73648665e4d3.tar.gz
PROJ-a3a67fb366e4628e5bda9e30b93b73648665e4d3.zip
Introduce preparation/finalization steps in fwd/inv subsystem, supporting arbitrary dimensionality in test code
* Call trans func of same dimensionality as input in gie * Refactor prep/fin code for pj_fwd/pj_inv 2D,3D,4D * Remove prime meridian handling from pj_transform (now handled in pj_fwd_prepare/pj_inv_finalize) * Introduce prep/fin skips, mostly in support of axisswap and pipeline drivers * Refactor fwd/inv subsystem * pj_transform: Let pj_fwd/inv handle scaling * Let pj_fwd/inv3d fall back to 2D eventually
Diffstat (limited to 'src/pj_internal.c')
-rw-r--r--src/pj_internal.c76
1 files changed, 51 insertions, 25 deletions
diff --git a/src/pj_internal.c b/src/pj_internal.c
index 7bfd192b..88fb2b62 100644
--- a/src/pj_internal.c
+++ b/src/pj_internal.c
@@ -8,7 +8,7 @@
* Author: Thomas Knudsen, thokn@sdfe.dk, 2017-07-05
*
******************************************************************************
- * Copyright (c) 2016, 2017, Thomas Knudsen/SDFE
+ * Copyright (c) 2016, 2017, 2018, Thomas Knudsen/SDFE
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -28,16 +28,15 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
-#define PJ_INTERNAL_C
-#include "proj_internal.h"
-#include "projects.h"
-#include <geodesic.h>
-
#include <ctype.h>
#include <stddef.h>
#include <stdarg.h>
#include <errno.h>
+#include <geodesic.h>
+#include "proj_internal.h"
+#include "projects.h"
+
enum pj_io_units pj_left (PJ *P) {
enum pj_io_units u = P->inverted? P->right: P->left;
@@ -62,32 +61,59 @@ PJ_COORD proj_coord_error (void) {
}
-PJ_COORD pj_fwd4d (PJ_COORD coo, PJ *P) {
- if (0!=P->fwd4d)
- return P->fwd4d (coo, P);
- if (0!=P->fwd3d) {
- coo.xyz = pj_fwd3d (coo.lpz, P);
- return coo;
- }
- if (0!=P->fwd) {
- coo.xy = pj_fwd (coo.lp, P);
+
+/**************************************************************************************/
+PJ_COORD pj_approx_2D_trans (PJ *P, PJ_DIRECTION direction, PJ_COORD coo) {
+/***************************************************************************************
+Behave mostly as proj_trans, but attempt to use 2D interfaces only.
+Used in gie.c, to enforce testing 2D code, and by PJ_pipeline.c to implement
+chained calls starting out with a call to its 2D interface.
+***************************************************************************************/
+ if (0==P)
return coo;
+ if (P->inverted)
+ direction = -direction;
+ switch (direction) {
+ case PJ_FWD:
+ coo.xy = pj_fwd (coo.lp, P);
+ return coo;
+ case PJ_INV:
+ coo.lp = pj_inv (coo.xy, P);
+ return coo;
+ case PJ_IDENT:
+ return coo;
+ default:
+ break;
}
proj_errno_set (P, EINVAL);
return proj_coord_error ();
}
-PJ_COORD pj_inv4d (PJ_COORD coo, PJ *P) {
- if (0!=P->inv4d)
- return P->inv4d (coo, P);
- if (0!=P->inv3d) {
- coo.lpz = pj_inv3d (coo.xyz, P);
- return coo;
- }
- if (0!=P->inv) {
- coo.lp = pj_inv (coo.xy, P);
+/**************************************************************************************/
+PJ_COORD pj_approx_3D_trans (PJ *P, PJ_DIRECTION direction, PJ_COORD coo) {
+/***************************************************************************************
+Companion to pj_approx_2D_trans.
+
+Behave mostly as proj_trans, but attempt to use 3D interfaces only.
+Used in gie.c, to enforce testing 3D code, and by PJ_pipeline.c to implement
+chained calls starting out with a call to its 3D interface.
+***************************************************************************************/
+ if (0==P)
return coo;
+ if (P->inverted)
+ direction = -direction;
+ switch (direction) {
+ case PJ_FWD:
+ coo.xyz = pj_fwd3d (coo.lpz, P);
+ return coo;
+ case PJ_INV:
+ coo.lpz = pj_inv3d (coo.xyz, P);
+ return coo;
+ case PJ_IDENT:
+ return coo;
+ default:
+ break;
}
proj_errno_set (P, EINVAL);
return proj_coord_error ();
@@ -96,7 +122,6 @@ PJ_COORD pj_inv4d (PJ_COORD coo, PJ *P) {
-
/* Move P to a new context - or to the default context if 0 is specified */
void proj_context_set (PJ *P, PJ_CONTEXT *ctx) {
if (0==ctx)
@@ -105,6 +130,7 @@ void proj_context_set (PJ *P, PJ_CONTEXT *ctx) {
return;
}
+
void proj_context_inherit (PJ *parent, PJ *child) {
if (0==parent)
pj_set_ctx (child, pj_get_default_ctx());