diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-12-15 01:12:58 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-12-15 17:24:54 +0100 |
| commit | 1d803550e7059729cf2734fc6190993e8b8404bf (patch) | |
| tree | 9ead2265d639388da39ad52aa88cd9861b508831 /src/4D_api.cpp | |
| parent | 2abc0aaf3a03493aaa3f940e1d420d8d9a7b804f (diff) | |
| download | PROJ-1d803550e7059729cf2734fc6190993e8b8404bf.tar.gz PROJ-1d803550e7059729cf2734fc6190993e8b8404bf.zip | |
proj_trans_array(): make it transform all coordinates even when an error occurs
Diffstat (limited to 'src/4D_api.cpp')
| -rw-r--r-- | src/4D_api.cpp | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp index 612be716..556a8c2d 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -377,18 +377,43 @@ int proj_trans_array (PJ *P, PJ_DIRECTION direction, size_t n, PJ_COORD *coord) /****************************************************************************** Batch transform an array of PJ_COORD. + Performs transformation on all points, even if errors occur on some points. + + Individual points that fail to transform will have their components set to + HUGE_VAL + Returns 0 if all coordinates are transformed without error, otherwise - returns error number. + returns a precise error number if all coordinates that fail to transform + for the same reason, or a generic error code if they fail for different + reasons. ******************************************************************************/ size_t i; + int retErrno = 0; + bool hasSetRetErrno = false; + bool sameRetErrno = true; for (i = 0; i < n; i++) { + proj_context_errno_set(P->ctx, 0); coord[i] = proj_trans (P, direction, coord[i]); - if (proj_errno(P)) - return proj_errno (P); - } + int thisErrno = proj_errno(P); + if( thisErrno != 0 ) + { + if( !hasSetRetErrno ) + { + retErrno = thisErrno; + hasSetRetErrno = true; + } + else if( sameRetErrno && retErrno != thisErrno ) + { + sameRetErrno = false; + retErrno = PROJ_ERR_COORD_TRANSFM; + } + } + } + + proj_context_errno_set(P->ctx, retErrno); - return 0; + return retErrno; } |
