aboutsummaryrefslogtreecommitdiff
path: root/src/c_api.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-12-14 00:06:01 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-12-14 00:06:01 +0100
commit6aff5d7b0e1061dbd7b45ae032daea087bf8e1bc (patch)
tree7193ddb4bb589f16fd71cb0bb3a7fde0783faeeb /src/c_api.cpp
parent17b8566f303e0585d7cd775afd5d39da8058fdc3 (diff)
downloadPROJ-6aff5d7b0e1061dbd7b45ae032daea087bf8e1bc.tar.gz
PROJ-6aff5d7b0e1061dbd7b45ae032daea087bf8e1bc.zip
C API: add proj_coordoperation_get_towgs84_values()
Diffstat (limited to 'src/c_api.cpp')
-rw-r--r--src/c_api.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/c_api.cpp b/src/c_api.cpp
index 0f189eaa..82b9f715 100644
--- a/src/c_api.cpp
+++ b/src/c_api.cpp
@@ -5501,6 +5501,52 @@ int proj_coordoperation_get_param(
// ---------------------------------------------------------------------------
+/** \brief Return the parameters of a Helmert transformation as WKT1 TOWGS84
+ * values.
+ *
+ * @param ctx PROJ context, or NULL for default context
+ * @param coordoperation Objet of type Transformation, that can be represented
+ * as a WKT1 TOWGS84 node (must not be NULL)
+ * @param out_values Pointer to an array of value_count double values.
+ * @param value_count Size of out_values array.
+ * @param emit_error_if_incompatible Boolean to inicate if an error must be
+ * logged if coordoperation is not compatible with a WKT1 TOWGS84
+ * representation.
+ * @return TRUE in case of success, or FALSE if coordoperation is not
+ * compatible with a WKT1 TOWGS84 representation.
+ */
+
+int proj_coordoperation_get_towgs84_values(PJ_CONTEXT *ctx,
+ const PJ_OBJ *coordoperation,
+ double *out_values, int value_count,
+ int emit_error_if_incompatible) {
+ SANITIZE_CTX(ctx);
+ assert(coordoperation);
+ auto transf =
+ dynamic_cast<const Transformation *>(coordoperation->obj.get());
+ if (!transf) {
+ if (emit_error_if_incompatible) {
+ proj_log_error(ctx, __FUNCTION__, "Object is not a Transformation");
+ }
+ return FALSE;
+ }
+ try {
+ auto values = transf->getTOWGS84Parameters();
+ for (int i = 0;
+ i < value_count && static_cast<size_t>(i) < values.size(); i++) {
+ out_values[i] = values[i];
+ }
+ return TRUE;
+ } catch (const std::exception &e) {
+ if (emit_error_if_incompatible) {
+ proj_log_error(ctx, __FUNCTION__, e.what());
+ }
+ return FALSE;
+ }
+}
+
+// ---------------------------------------------------------------------------
+
/** \brief Return the number of grids used by a CoordinateOperation
*
* @param ctx PROJ context, or NULL for default context