aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/c_api.cpp23
-rw-r--r--src/proj.h2
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
diff --git a/src/proj.h b/src/proj.h
index b16f54ea..4b417dc4 100644
--- a/src/proj.h
+++ b/src/proj.h
@@ -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);