aboutsummaryrefslogtreecommitdiff
path: root/src/c_api.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-12-14 14:59:27 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-12-14 14:59:27 +0100
commitba313759523d6d24f7e027f5ddae230656141b3b (patch)
treef80872c682383fee0e5f232bcc3ced2e4bdb4bc9 /src/c_api.cpp
parent4638b45730ab29b2891e57474fa9ee130d6b38a4 (diff)
downloadPROJ-ba313759523d6d24f7e027f5ddae230656141b3b.tar.gz
PROJ-ba313759523d6d24f7e027f5ddae230656141b3b.zip
Advanced C API: add proj_obj_alter_id()
Diffstat (limited to 'src/c_api.cpp')
-rw-r--r--src/c_api.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/c_api.cpp b/src/c_api.cpp
index b09cbbf2..aa9d7e70 100644
--- a/src/c_api.cpp
+++ b/src/c_api.cpp
@@ -2415,6 +2415,39 @@ PJ_OBJ PROJ_DLL *proj_obj_alter_name(PJ_CONTEXT *ctx, const PJ_OBJ *obj,
// ---------------------------------------------------------------------------
+/** \brief Return a copy of the object with its identifier changed/set
+ *
+ * Currently, only implemented on CRS objects.
+ *
+ * The returned object must be unreferenced with proj_obj_destroy() after
+ * use.
+ * It should be used by at most one thread at a time.
+ *
+ * @param ctx PROJ context, or NULL for default context
+ * @param obj Object of type CRS. Must not be NULL
+ * @param auth_name Authority name. Must not be NULL
+ * @param code Code. Must not be NULL
+ *
+ * @return Object that must be unreferenced with
+ * proj_obj_destroy(), or NULL in case of error.
+ */
+PJ_OBJ PROJ_DLL *proj_obj_alter_id(PJ_CONTEXT *ctx, const PJ_OBJ *obj,
+ const char *auth_name, const char *code) {
+ SANITIZE_CTX(ctx);
+ auto crs = dynamic_cast<const CRS *>(obj->obj.get());
+ if (!crs) {
+ return nullptr;
+ }
+ try {
+ return PJ_OBJ::create(crs->alterId(auth_name, code));
+ } catch (const std::exception &e) {
+ proj_log_error(ctx, __FUNCTION__, e.what());
+ }
+ return nullptr;
+}
+
+// ---------------------------------------------------------------------------
+
/** \brief Return a copy of the CRS with its geodetic CRS changed
*
* Currently, when obj is a GeodeticCRS, it returns a clone of new_geod_crs