aboutsummaryrefslogtreecommitdiff
path: root/src/4D_api.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/4D_api.cpp')
-rw-r--r--src/4D_api.cpp35
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;
}