diff options
| author | Nyall Dawson <nyall.dawson@gmail.com> | 2019-05-31 20:47:45 +1000 |
|---|---|---|
| committer | Nyall Dawson <nyall.dawson@gmail.com> | 2019-06-01 06:51:33 +1000 |
| commit | e24f462fa7da48eeabb254b8678e0257b0aef405 (patch) | |
| tree | 83bef32021460c2ccc96b8c3465a15adefb143de /src | |
| parent | 69b1aafe11c0559f0a88d86db7e57ff99a4a6641 (diff) | |
| download | PROJ-e24f462fa7da48eeabb254b8678e0257b0aef405.tar.gz PROJ-e24f462fa7da48eeabb254b8678e0257b0aef405.zip | |
Add proj_grid_get_info_from_database to allow retrieval of grid
metadata from a grid filename
Diffstat (limited to 'src')
| -rw-r--r-- | src/iso19111/c_api.cpp | 59 | ||||
| -rw-r--r-- | src/proj.h | 9 |
2 files changed, 68 insertions, 0 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index 5d2216e8..1e3a331c 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -626,6 +626,65 @@ int proj_uom_get_info_from_database(PJ_CONTEXT *ctx, const char *auth_name, // --------------------------------------------------------------------------- +/** \brief Get information for a grid from a database lookup. + * + * @param ctx Context, or NULL for default context. + * @param grid_name Grid name (must not be NULL) + * @param out_full_name Pointer to a string value to store the grid full + * filename. or NULL + * @param out_package_name Pointer to a string value to store the package name + * where + * the grid might be found. or NULL + * @param out_url Pointer to a string value to store the grid URL or the + * package URL where the grid might be found. or NULL + * @param out_direct_download Pointer to a int (boolean) value to store whether + * *out_url can be downloaded directly. or NULL + * @param out_open_license Pointer to a int (boolean) value to store whether + * the grid is released with an open license. or NULL + * @param out_available Pointer to a int (boolean) value to store whether the + * grid is available at runtime. or NULL + * @return TRUE in case of success. + */ +int PROJ_DLL proj_grid_get_info_from_database( + PJ_CONTEXT *ctx, const char *grid_name, const char **out_full_name, + const char **out_package_name, const char **out_url, + int *out_direct_download, int *out_open_license, int *out_available) { + assert(grid_name); + SANITIZE_CTX(ctx); + try { + auto db_context = getDBcontext(ctx); + bool direct_download; + bool open_license; + bool available; + if (!db_context->lookForGridInfo( + grid_name, ctx->cpp_context->lastGridFullName_, + ctx->cpp_context->lastGridPackageName_, + ctx->cpp_context->lastGridUrl_, direct_download, open_license, + available)) + return false; + + if (out_full_name) + *out_full_name = ctx->cpp_context->lastGridFullName_.c_str(); + if (out_package_name) + *out_package_name = ctx->cpp_context->lastGridPackageName_.c_str(); + if (out_url) + *out_url = ctx->cpp_context->lastGridUrl_.c_str(); + if (out_direct_download) + *out_direct_download = direct_download ? 1 : 0; + if (out_open_license) + *out_open_license = open_license ? 1 : 0; + if (out_available) + *out_available = available ? 1 : 0; + + return true; + } catch (const std::exception &e) { + proj_log_error(ctx, __FUNCTION__, e.what()); + } + return false; +} + +// --------------------------------------------------------------------------- + /** \brief Return GeodeticCRS that use the specified datum. * * @param ctx Context, or NULL for default context. @@ -787,6 +787,15 @@ int PROJ_DLL proj_uom_get_info_from_database(PJ_CONTEXT *ctx, double *out_conv_factor, const char **out_category); +int PROJ_DLL proj_grid_get_info_from_database(PJ_CONTEXT *ctx, + const char *grid_name, + const char **out_full_name, + const char **out_package_name, + const char **out_url, + int *out_direct_download, + int *out_open_license, + int *out_available); + PJ PROJ_DLL *proj_clone(PJ_CONTEXT *ctx, const PJ *obj); PJ_OBJ_LIST PROJ_DLL *proj_create_from_name(PJ_CONTEXT *ctx, |
