\brief Return a metadata from the database. * * The returned pointer remains valid while ctx is valid, and until * proj_context_get_database_metadata() is called. * * Available keys: * * - DATABASE.LAYOUT.VERSION.MAJOR * - DATABASE.LAYOUT.VERSION.MINOR * - EPSG.VERSION * - EPSG.DATE * - ESRI.VERSION * - ESRI.DATE * - IGNF.SOURCE * - IGNF.VERSION * - IGNF.DATE * - NKG.SOURCE * - NK
| 442 | * @return value, or nullptr |
| 443 | */ |
| 444 | const char *proj_context_get_database_metadata(PJ_CONTEXT *ctx, |
| 445 | const char *key) { |
| 446 | SANITIZE_CTX(ctx); |
| 447 | if (!key) { |
| 448 | proj_context_errno_set(ctx, PROJ_ERR_OTHER_API_MISUSE); |
| 449 | proj_log_error(ctx, __FUNCTION__, "missing required input"); |
| 450 | return nullptr; |
| 451 | } |
| 452 | try { |
| 453 | // temporary variable must be used as getDBcontext() might create |
| 454 | // ctx->cpp_context |
| 455 | auto osVal(getDBcontext(ctx)->getMetadata(key)); |
| 456 | if (osVal == nullptr) { |
| 457 | return nullptr; |
| 458 | } |
| 459 | ctx->get_cpp_context()->lastDbMetadataItem_ = osVal; |
| 460 | return ctx->cpp_context->lastDbMetadataItem_.c_str(); |
| 461 | } catch (const std::exception &e) { |
| 462 | proj_log_error(ctx, __FUNCTION__, e.what()); |
| 463 | return nullptr; |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | // --------------------------------------------------------------------------- |
| 468 |