aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-10-11 20:13:42 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-10-11 20:13:42 +0200
commit686713479eb0b39feb5369b82647f96edf809b6c (patch)
tree2a27a48120eafa170aa4e391d0706c614c9c174a
parentd1a0d95da549f7d32bcd8be408afe1fca62a6fb2 (diff)
downloadPROJ-686713479eb0b39feb5369b82647f96edf809b6c.tar.gz
PROJ-686713479eb0b39feb5369b82647f96edf809b6c.zip
C API: add proj_dynamic_datum_get_frame_reference_epoch()
-rw-r--r--scripts/reference_exported_symbols.txt1
-rw-r--r--src/iso19111/c_api.cpp34
-rw-r--r--src/proj.h3
-rw-r--r--test/unit/test_c_api.cpp4
4 files changed, 42 insertions, 0 deletions
diff --git a/scripts/reference_exported_symbols.txt b/scripts/reference_exported_symbols.txt
index 6cb20c08..8f225b3b 100644
--- a/scripts/reference_exported_symbols.txt
+++ b/scripts/reference_exported_symbols.txt
@@ -989,6 +989,7 @@ proj_degree_output
proj_destroy
proj_dmstor
proj_download_file
+proj_dynamic_datum_get_frame_reference_epoch
proj_ellipsoid_get_parameters
proj_errno
proj_errno_reset
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp
index c152df88..cad76431 100644
--- a/src/iso19111/c_api.cpp
+++ b/src/iso19111/c_api.cpp
@@ -8163,6 +8163,40 @@ PJ *proj_crs_get_datum_forced(PJ_CONTEXT *ctx, const PJ *crs) {
// ---------------------------------------------------------------------------
+/** \brief Returns the frame reference epoch of a dynamic geodetic or vertical
+ * reference frame.
+ *
+ * @param ctx PROJ context, or NULL for default context
+ * @param datum Object of type DynamicGeodeticReferenceFrame or
+ * DynamicVerticalReferenceFrame (must not be NULL)
+ * @return the frame reference epoch as decimal year, or -1 in case of error.
+ *
+ * @since 7.2
+ */
+double proj_dynamic_datum_get_frame_reference_epoch(PJ_CONTEXT *ctx,
+ const PJ *datum) {
+ SANITIZE_CTX(ctx);
+ if (!datum) {
+ proj_log_error(ctx, __FUNCTION__, "missing required input");
+ return -1;
+ }
+ auto dgrf = dynamic_cast<const DynamicGeodeticReferenceFrame *>(
+ datum->iso_obj.get());
+ auto dvrf = dynamic_cast<const DynamicVerticalReferenceFrame *>(
+ datum->iso_obj.get());
+ if (!dgrf && !dvrf) {
+ proj_log_error(ctx, __FUNCTION__, "Object is not a "
+ "DynamicGeodeticReferenceFrame or "
+ "DynamicVerticalReferenceFrame");
+ return -1;
+ }
+ const auto &frameReferenceEpoch =
+ dgrf ? dgrf->frameReferenceEpoch() : dvrf->frameReferenceEpoch();
+ return frameReferenceEpoch.value();
+}
+
+// ---------------------------------------------------------------------------
+
/** \brief Returns the coordinate system of a SingleCRS.
*
* The returned object must be unreferenced with proj_destroy() after
diff --git a/src/proj.h b/src/proj.h
index 92966526..b758663a 100644
--- a/src/proj.h
+++ b/src/proj.h
@@ -1263,6 +1263,9 @@ PJ PROJ_DLL *proj_datum_ensemble_get_member(PJ_CONTEXT *ctx,
const PJ *datum_ensemble,
int member_index);
+double PROJ_DLL proj_dynamic_datum_get_frame_reference_epoch(PJ_CONTEXT *ctx,
+ const PJ *datum);
+
PJ PROJ_DLL *proj_crs_get_coordinate_system(PJ_CONTEXT *ctx, const PJ *crs);
PJ_COORDINATE_SYSTEM_TYPE PROJ_DLL proj_cs_get_type(PJ_CONTEXT *ctx,
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index c7053291..c0db3880 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -852,6 +852,8 @@ TEST_F(CApi, proj_create_from_database) {
ObjectKeeper keeper(datum);
EXPECT_EQ(proj_get_type(datum),
PJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME);
+ EXPECT_EQ(proj_dynamic_datum_get_frame_reference_epoch(m_ctxt, datum),
+ 2005.0);
}
{
// Norway Normal Null 2000
@@ -861,6 +863,8 @@ TEST_F(CApi, proj_create_from_database) {
ObjectKeeper keeper(datum);
EXPECT_EQ(proj_get_type(datum),
PJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME);
+ EXPECT_EQ(proj_dynamic_datum_get_frame_reference_epoch(m_ctxt, datum),
+ 2000.0);
}
{
auto op = proj_create_from_database(m_ctxt, "EPSG", "16031",