diff options
| author | Javier Jimenez Shaw <j1@jimenezshaw.com> | 2021-04-24 10:37:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-24 10:37:19 +0200 |
| commit | 93dc8422c4cddf5fa52824222143effa6bb4d67f (patch) | |
| tree | 53f8aba4764a68887e50e6d59fa2ec7162b93144 /src/iso19111/c_api.cpp | |
| parent | a002a3e9da175228494faca7219bce4e7e9effe6 (diff) | |
| download | PROJ-93dc8422c4cddf5fa52824222143effa6bb4d67f.tar.gz PROJ-93dc8422c4cddf5fa52824222143effa6bb4d67f.zip | |
Add proj_get_geoid_models_from_database() (#2681)
to list all geoid model names that apply to a vertical CRS
Diffstat (limited to 'src/iso19111/c_api.cpp')
| -rw-r--r-- | src/iso19111/c_api.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index ce7f2ae2..f8d9e685 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -9162,3 +9162,46 @@ PROJ_STRING_LIST proj_get_insert_statements( } return nullptr; } + +// --------------------------------------------------------------------------- + +/** \brief Returns a list of geoid models available for that crs + * + * The list includes the geoid models connected directly with the crs, + * or via "Height Depth Reversal" or "Change of Vertical Unit" transformations. + * The returned list is NULL terminated and must be freed with + * proj_string_list_destroy(). + * + * @param ctx Context, or NULL for default context. + * @param auth_name Authority name (must not be NULL) + * @param code Object code (must not be NULL) + * @param options should be set to NULL for now + * @return list of geoid models names (to be freed with + * proj_string_list_destroy()), or NULL in case of error. + * @since 8.1 + */ +PROJ_STRING_LIST +proj_get_geoid_models_from_database(PJ_CONTEXT *ctx, const char *auth_name, + const char *code, + const char *const *options) { + SANITIZE_CTX(ctx); + if (!auth_name || !code) { + proj_context_errno_set(ctx, PROJ_ERR_OTHER_API_MISUSE); + proj_log_error(ctx, __FUNCTION__, "missing required input"); + return nullptr; + } + (void)options; + try { + const std::string codeStr(code); + auto factory = AuthorityFactory::create(getDBcontext(ctx), auth_name); + auto geoidModels = factory->getGeoidModels(codeStr); + ctx->safeAutoCloseDbIfNeeded(); + return to_string_list(std::move(geoidModels)); + } catch (const std::exception &e) { + proj_log_error(ctx, __FUNCTION__, e.what()); + } + ctx->safeAutoCloseDbIfNeeded(); + return nullptr; +} + +// --------------------------------------------------------------------------- |
