MCPcopy Create free account
hub / github.com/Kitware/VTK / PROJECTION

Function PROJECTION

ThirdParty/libproj/vtklibproj/src/transformations/horner.cpp:443–535  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

441
442/*********************************************************************/
443PJ *PROJECTION(horner) {
444/*********************************************************************/
445 int degree = 0, n, complex_polynomia = 0;
446 HORNER *Q;
447 P->fwd4d = horner_forward_4d;
448 P->inv4d = horner_reverse_4d;
449 P->fwd3d = nullptr;
450 P->inv3d = nullptr;
451 P->fwd = nullptr;
452 P->inv = nullptr;
453 P->left = P->right = PJ_IO_UNITS_PROJECTED;
454 P->destructor = horner_freeup;
455
456 /* Polynomial degree specified? */
457 if (pj_param (P->ctx, P->params, "tdeg").i) { /* degree specified? */
458 degree = pj_param(P->ctx, P->params, "ideg").i;
459 if (degree < 0 || degree > 10000) {
460 /* What are reasonable minimum and maximums for degree? */
461 proj_log_error (P, _("Degree is unreasonable: %d"), degree);
462 return horner_freeup (P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE);
463 }
464 } else {
465 proj_log_error (P, _("Must specify polynomial degree, (+deg=n)"));
466 return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG);
467 }
468
469 if (pj_param (P->ctx, P->params, "tfwd_c").i || pj_param (P->ctx, P->params, "tinv_c").i) /* complex polynomium? */
470 complex_polynomia = 1;
471
472 Q = horner_alloc (degree, complex_polynomia);
473 if (Q == nullptr)
474 return horner_freeup (P, PROJ_ERR_OTHER /*ENOMEM*/);
475 P->opaque = Q;
476
477 if (complex_polynomia) {
478 /* Westings and/or southings? */
479 Q->uneg = pj_param_exists (P->params, "uneg") ? 1 : 0;
480 Q->vneg = pj_param_exists (P->params, "vneg") ? 1 : 0;
481
482 n = 2*degree + 2;
483 if (0==parse_coefs (P, Q->fwd_c, "fwd_c", n))
484 {
485 proj_log_error (P, _("missing fwd_c"));
486 return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG);
487 }
488 if (0==parse_coefs (P, Q->inv_c, "inv_c", n))
489 {
490 proj_log_error (P, _("missing inv_c"));
491 return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG);
492 }
493 P->fwd4d = complex_horner_forward_4d;
494 P->inv4d = complex_horner_reverse_4d;
495 }
496
497 else {
498 n = horner_number_of_coefficients (degree);
499 if (0==parse_coefs (P, Q->fwd_u, "fwd_u", n))
500 {

Callers

nothing calls this directly

Calls 6

pj_paramFunction · 0.85
proj_log_errorFunction · 0.85
horner_freeupFunction · 0.85
horner_allocFunction · 0.85
pj_param_existsFunction · 0.85
parse_coefsFunction · 0.85

Tested by

no test coverage detected