| 407 | |
| 408 | |
| 409 | static int parse_coefs (PJ *P, double *coefs, const char *param, int ncoefs) { |
| 410 | char *buf, *init, *next = nullptr; |
| 411 | int i; |
| 412 | |
| 413 | buf = static_cast<char*>(calloc (strlen (param) + 2, sizeof(char))); |
| 414 | if (nullptr==buf) { |
| 415 | proj_log_error (P, "No memory left"); |
| 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | sprintf (buf, "t%s", param); |
| 420 | if (0==pj_param (P->ctx, P->params, buf).i) { |
| 421 | free (buf); |
| 422 | return 0; |
| 423 | } |
| 424 | sprintf (buf, "s%s", param); |
| 425 | init = pj_param(P->ctx, P->params, buf).s; |
| 426 | free (buf); |
| 427 | |
| 428 | for (i = 0; i < ncoefs; i++) { |
| 429 | if (i > 0) { |
| 430 | if ( next == nullptr || ','!=*next) { |
| 431 | proj_log_error (P, "Malformed polynomium set %s. need %d coefs", param, ncoefs); |
| 432 | return 0; |
| 433 | } |
| 434 | init = ++next; |
| 435 | } |
| 436 | coefs[i] = pj_strtod (init, &next); |
| 437 | } |
| 438 | return 1; |
| 439 | } |
| 440 | |
| 441 | |
| 442 | /*********************************************************************/ |
no test coverage detected