diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-12-28 17:07:44 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-12-28 17:07:44 +0100 |
| commit | 882d84b086010e2a5088be11362db16217beab99 (patch) | |
| tree | cb0d1bf1d4fd8a3d8c30a97600d023a34ba3f8d1 /src | |
| parent | 1cafe3e602d3f697c8d2daaa9b634f3ad23b0d53 (diff) | |
| download | PROJ-882d84b086010e2a5088be11362db16217beab99.tar.gz PROJ-882d84b086010e2a5088be11362db16217beab99.zip | |
C API: add proj_crs_is_derived()
Diffstat (limited to 'src')
| -rw-r--r-- | src/iso19111/c_api.cpp | 23 | ||||
| -rw-r--r-- | src/proj.h | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index cb0c113a..ae13b40d 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -1840,6 +1840,29 @@ PJ *proj_crs_get_geodetic_crs(PJ_CONTEXT *ctx, const PJ *crs) { // --------------------------------------------------------------------------- +/** \brief Returns whether a CRS is a derived CRS. + * + * @param ctx PROJ context, or NULL for default context + * @param crs Object of type CRS (must not be NULL) + * @return TRUE if the CRS is a derived CRS. + * @since 8.0 + */ +int proj_crs_is_derived(PJ_CONTEXT *ctx, const PJ *crs) { + if (!crs) { + proj_context_errno_set(ctx, PROJ_ERR_OTHER_API_MISUSE); + proj_log_error(ctx, __FUNCTION__, "missing required input"); + return false; + } + auto l_crs = dynamic_cast<const CRS *>(crs->iso_obj.get()); + if (!l_crs) { + proj_log_error(ctx, __FUNCTION__, "Object is not a CRS"); + return false; + } + return dynamic_cast<const DerivedCRS *>(l_crs) != nullptr; +} + +// --------------------------------------------------------------------------- + /** \brief Get a CRS component from a CompoundCRS * * The returned object must be unreferenced with proj_destroy() after @@ -1271,6 +1271,8 @@ int PROJ_DLL proj_get_suggested_operation(PJ_CONTEXT *ctx, /* ------------------------------------------------------------------------- */ +int PROJ_DLL proj_crs_is_derived(PJ_CONTEXT *ctx, const PJ *crs); + PJ PROJ_DLL *proj_crs_get_geodetic_crs(PJ_CONTEXT *ctx, const PJ *crs); PJ PROJ_DLL *proj_crs_get_horizontal_datum(PJ_CONTEXT *ctx, const PJ *crs); |
