/
| 378 | |
| 379 | /*****************************************************************************/ |
| 380 | int proj_trans_array(PJ *P, PJ_DIRECTION direction, size_t n, PJ_COORD *coord) { |
| 381 | /****************************************************************************** |
| 382 | Batch transform an array of PJ_COORD. |
| 383 | |
| 384 | Performs transformation on all points, even if errors occur on some |
| 385 | points. |
| 386 | |
| 387 | Individual points that fail to transform will have their components set |
| 388 | to HUGE_VAL |
| 389 | |
| 390 | Returns 0 if all coordinates are transformed without error, otherwise |
| 391 | returns a precise error number if all coordinates that fail to transform |
| 392 | for the same reason, or a generic error code if they fail for different |
| 393 | reasons. |
| 394 | ******************************************************************************/ |
| 395 | size_t i; |
| 396 | int retErrno = 0; |
| 397 | bool hasSetRetErrno = false; |
| 398 | bool sameRetErrno = true; |
| 399 | |
| 400 | for (i = 0; i < n; i++) { |
| 401 | proj_context_errno_set(P->ctx, 0); |
| 402 | coord[i] = proj_trans(P, direction, coord[i]); |
| 403 | int thisErrno = proj_errno(P); |
| 404 | if (thisErrno != 0) { |
| 405 | if (!hasSetRetErrno) { |
| 406 | retErrno = thisErrno; |
| 407 | hasSetRetErrno = true; |
| 408 | } else if (sameRetErrno && retErrno != thisErrno) { |
| 409 | sameRetErrno = false; |
| 410 | retErrno = PROJ_ERR_COORD_TRANSFM; |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | proj_context_errno_set(P->ctx, retErrno); |
| 416 | |
| 417 | return retErrno; |
| 418 | } |
| 419 | |
| 420 | /*************************************************************************************/ |
| 421 | size_t proj_trans_generic(PJ *P, PJ_DIRECTION direction, double *x, size_t sx, |