MCPcopy Create free account
hub / github.com/OSGeo/PROJ / proj_trans_array

Function proj_trans_array

src/trans.cpp:380–418  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

378
379/*****************************************************************************/
380int 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/*************************************************************************************/
421size_t proj_trans_generic(PJ *P, PJ_DIRECTION direction, double *x, size_t sx,

Callers 1

TESTFunction · 0.85

Calls 3

proj_context_errno_setFunction · 0.85
proj_transFunction · 0.85
proj_errnoFunction · 0.85

Tested by 1

TESTFunction · 0.68