From 234eba764d7fea67b597d8f9ed5225e651f4a945 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Mon, 26 Mar 2018 23:36:15 +0200 Subject: Validate that units match between pipeline steps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As suggested in [0], steps in a pipeline are now checked for compliance. If the right side units in step n differ from the left side units in step n+1 the pipeline can't be constructed and an error is raised. [0] https://lists.osgeo.org/pipermail/grass-dev/2018-March/088123.html --- src/PJ_pipeline.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/PJ_pipeline.c b/src/PJ_pipeline.c index 2791a4e8..b60e05a8 100644 --- a/src/PJ_pipeline.c +++ b/src/PJ_pipeline.c @@ -470,6 +470,19 @@ PJ *OPERATION(pipeline,0) { } } + /* Check that output units from step i are compatible with expected units in step i+1 */ + for (i = 1; i < nsteps; i++) { + enum pj_io_units unit_returned = pj_right (P->opaque->pipeline[i]); + enum pj_io_units unit_expected = pj_left (P->opaque->pipeline[i+1]); + + if ( unit_returned == PJ_IO_UNITS_WHATEVER || unit_expected == PJ_IO_UNITS_WHATEVER ) + continue; + if ( unit_returned != unit_expected ) { + proj_log_error (P, "Pipeline: Mismatched units between step %d and %d", i, i+1); + return destructor (P, PJD_ERR_MALFORMED_PIPELINE); + } + } + proj_log_trace (P, "Pipeline: %d steps built. Determining i/o characteristics", nsteps); /* Determine forward input (= reverse output) data type */ -- cgit v1.2.3 From bcd647fe82e45efd51c3a64e348b99b38c839e2b Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Tue, 27 Mar 2018 00:07:24 +0200 Subject: Change units of axisswap to 'whatever' Since units are validated during pipeline setup we need to make sure that axisswap can be used for more than just projected outputs. --- src/PJ_axisswap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/PJ_axisswap.c b/src/PJ_axisswap.c index 44446d9c..0b81a733 100644 --- a/src/PJ_axisswap.c +++ b/src/PJ_axisswap.c @@ -277,8 +277,8 @@ PJ *CONVERSION(axisswap,0) { P->left = PJ_IO_UNITS_ANGULAR; P->right = PJ_IO_UNITS_ANGULAR; } else { - P->left = PJ_IO_UNITS_PROJECTED; - P->right = PJ_IO_UNITS_PROJECTED; + P->left = PJ_IO_UNITS_WHATEVER; + P->right = PJ_IO_UNITS_WHATEVER; } -- cgit v1.2.3