/
| 393 | |
| 394 | /***********************************************************************/ |
| 395 | static double get_unit_conversion_factor(const char *name, int *p_is_linear, |
| 396 | const char **p_normalized_name) { |
| 397 | /***********************************************************************/ |
| 398 | int i; |
| 399 | const char *s; |
| 400 | const PJ_UNITS *units = pj_list_linear_units(); |
| 401 | |
| 402 | /* Try first with linear units */ |
| 403 | for (i = 0; (s = units[i].id); ++i) { |
| 404 | if (strcmp(s, name) == 0) { |
| 405 | if (p_normalized_name) { |
| 406 | *p_normalized_name = units[i].name; |
| 407 | } |
| 408 | if (p_is_linear) { |
| 409 | *p_is_linear = 1; |
| 410 | } |
| 411 | return units[i].factor; |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | /* And then angular units */ |
| 416 | units = pj_list_angular_units(); |
| 417 | for (i = 0; (s = units[i].id); ++i) { |
| 418 | if (strcmp(s, name) == 0) { |
| 419 | if (p_normalized_name) { |
| 420 | *p_normalized_name = units[i].name; |
| 421 | } |
| 422 | if (p_is_linear) { |
| 423 | *p_is_linear = 0; |
| 424 | } |
| 425 | return units[i].factor; |
| 426 | } |
| 427 | } |
| 428 | if (p_normalized_name) { |
| 429 | *p_normalized_name = nullptr; |
| 430 | } |
| 431 | if (p_is_linear) { |
| 432 | *p_is_linear = -1; |
| 433 | } |
| 434 | return 0.0; |
| 435 | } |
| 436 | |
| 437 | /***********************************************************************/ |
| 438 | PJ *PJ_CONVERSION(unitconvert, 0) { |
no test coverage detected