/
| 364 | |
| 365 | /*****************************************************************************/ |
| 366 | static paralist *pj_expand_init_internal(PJ_CONTEXT *ctx, paralist *init, |
| 367 | int allow_init_epsg) { |
| 368 | /****************************************************************************** |
| 369 | Append expansion of <key> to the paralist <init>. The expansion is appended, |
| 370 | rather than inserted at <init>'s place, since <init> may contain |
| 371 | overrides to the expansion. These must take precedence, and hence come first |
| 372 | in the expanded list. |
| 373 | |
| 374 | Consider e.g. the key 'foo:bar' which (hypothetically) expands to 'proj=utm |
| 375 | zone=32 ellps=GRS80', i.e. a UTM projection on the GRS80 ellipsoid. |
| 376 | |
| 377 | The expression 'init=foo:bar ellps=intl' will then expand to: |
| 378 | |
| 379 | 'init=foo:bar ellps=intl proj=utm zone=32 ellps=GRS80', |
| 380 | |
| 381 | where 'ellps=intl' precedes 'ellps=GRS80', and hence takes precedence, |
| 382 | turning the expansion into an UTM projection on the Hayford ellipsoid. |
| 383 | |
| 384 | Note that 'init=foo:bar' stays in the list. It is ignored after expansion. |
| 385 | |
| 386 | ******************************************************************************/ |
| 387 | paralist *last; |
| 388 | paralist *expn; |
| 389 | |
| 390 | /* Nowhere to start? */ |
| 391 | if (nullptr == init) |
| 392 | return nullptr; |
| 393 | |
| 394 | expn = get_init(ctx, init->param, allow_init_epsg); |
| 395 | |
| 396 | /* Nothing in expansion? */ |
| 397 | if (nullptr == expn) |
| 398 | return nullptr; |
| 399 | |
| 400 | /* Locate the end of the list */ |
| 401 | for (last = init; last && last->next; last = last->next) |
| 402 | ; |
| 403 | |
| 404 | /* Then append and return */ |
| 405 | last->next = expn; |
| 406 | return init; |
| 407 | } |
| 408 | |
| 409 | paralist *pj_expand_init(PJ_CONTEXT *ctx, paralist *init) { |
| 410 | return pj_expand_init_internal(ctx, init, TRUE); |
no test coverage detected