aboutsummaryrefslogtreecommitdiff
path: root/src/c_api.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-12-06 21:28:16 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-12-06 21:49:59 +0100
commitf06045c2f0145ec2290913fa144cd690e70736fd (patch)
tree555131a028f47e9225eb54d836f973c84e40a816 /src/c_api.cpp
parent4022e2093a6773458c2453e42089c987da6efbf9 (diff)
downloadPROJ-f06045c2f0145ec2290913fa144cd690e70736fd.tar.gz
PROJ-f06045c2f0145ec2290913fa144cd690e70736fd.zip
Add API to retrieve non-deprecated equivalent of an object
Diffstat (limited to 'src/c_api.cpp')
-rw-r--r--src/c_api.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/c_api.cpp b/src/c_api.cpp
index e1f34012..78ca1c24 100644
--- a/src/c_api.cpp
+++ b/src/c_api.cpp
@@ -791,6 +791,36 @@ int proj_obj_is_deprecated(const PJ_OBJ *obj) {
// ---------------------------------------------------------------------------
+/** \brief Return a list of non-deprecated objects related to the passed one
+ *
+ * @param ctx Context, or NULL for default context.
+ * @param obj Object (of type CRS for now) for which non-deprecated objects
+ * must be searched. Must not be NULL
+ * @return a result set that must be unreferenced with
+ * proj_obj_list_unref(), or NULL in case of error.
+ */
+PJ_OBJ_LIST *proj_obj_get_non_deprecated(PJ_CONTEXT *ctx, const PJ_OBJ *obj) {
+ assert(obj);
+ SANITIZE_CTX(ctx);
+ auto crs = dynamic_cast<const CRS *>(obj->obj.get());
+ if (!crs) {
+ return nullptr;
+ }
+ try {
+ std::vector<IdentifiedObjectNNPtr> objects;
+ auto res = crs->getNonDeprecated(getDBcontext(ctx));
+ for (const auto &resObj : res) {
+ objects.push_back(resObj);
+ }
+ return new PJ_OBJ_LIST(std::move(objects));
+ } catch (const std::exception &e) {
+ proj_log_error(ctx, __FUNCTION__, e.what());
+ }
+ return nullptr;
+}
+
+// ---------------------------------------------------------------------------
+
/** \brief Return whether two objects are equivalent.
*
* @param obj Object (must not be NULL)