aboutsummaryrefslogtreecommitdiff
path: root/src/gie.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/gie.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/gie.c')
-rw-r--r--src/gie.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/gie.c b/src/gie.c
index 8a1d356e..c6440a2d 100644
--- a/src/gie.c
+++ b/src/gie.c
@@ -184,6 +184,7 @@ typedef struct {
int total_ok, total_ko;
int grand_ok, grand_ko;
size_t operation_lineno;
+ size_t dimensions_given, dimensions_given_at_last_accept;
double tolerance;
const char *curr_file;
FILE *fout;
@@ -581,10 +582,13 @@ Attempt to interpret args as a PJ_COORD.
const char *endp, *prev = args;
PJ_COORD a = proj_coord (0,0,0,0);
- for (i = 0; i < 4; i++) {
+ for (i = 0, T.dimensions_given = 0; i < 4; i++, T.dimensions_given++) {
double d = proj_strtod (prev, (char **) &endp);
+
+ /* Break out if there were no more numerals */
if (prev==endp)
return i > 1? a: proj_coord_error ();
+
a.v[i] = d;
prev = endp;
}
@@ -601,6 +605,7 @@ Read ("ACCEPT") a 2, 3, or 4 dimensional input coordinate.
T.a = parse_coord (args);
if (T.verbosity > 3)
printf ("# %s\n", args);
+ T.dimensions_given_at_last_accept = T.dimensions_given;
return 0;
}
@@ -693,6 +698,19 @@ static int expect_failure_with_errno_message (int expected, int got) {
}
+/* For test purposes, we want to call a transformation of the same */
+/* dimensionality as the number of dimensions given in accept */
+static PJ_COORD expect_trans_n_dim (PJ_COORD ci) {
+ if (4==T.dimensions_given_at_last_accept)
+ return proj_trans (T.P, T.dir, ci);
+
+ if (3==T.dimensions_given_at_last_accept)
+ return pj_approx_3D_trans (T.P, T.dir, ci);
+
+ return pj_approx_2D_trans (T.P, T.dir, ci);
+}
+
+
/*****************************************************************************/
static int expect (const char *args) {
/*****************************************************************************
@@ -733,7 +751,7 @@ Tell GIE what to expect, when transforming the ACCEPTed input
/* Try to carry out the operation - and expect failure */
ci = proj_angular_input (T.P, T.dir)? torad_coord (T.a): T.a;
- co = proj_trans (T.P, T.dir, ci);
+ co = expect_trans_n_dim (ci);
/* Failed to fail? - that's a failure */
if (co.xyz.x!=HUGE_VAL)
@@ -775,7 +793,7 @@ Tell GIE what to expect, when transforming the ACCEPTed input
printf ("ACCEPTS %.4f %.4f %.4f %.4f\n", ci.v[0],ci.v[1],ci.v[2],ci.v[3]);
/* angular output from proj_trans comes in radians */
- co = proj_trans (T.P, T.dir, ci);
+ co = expect_trans_n_dim (ci);
T.b = proj_angular_output (T.P, T.dir)? todeg_coord (co): co;
if (T.verbosity > 3)
printf ("GOT %.4f %.4f %.4f %.4f\n", ci.v[0],ci.v[1],ci.v[2],ci.v[3]);