aboutsummaryrefslogtreecommitdiff
path: root/src/4D_api.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-12-26 13:42:46 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-12-30 21:48:52 +0100
commitc9b32000d5fc12705bea92e6509fbedb37193012 (patch)
tree1a5aa97d1fe4abfc76dac0eb1048c613085616ad /src/4D_api.cpp
parent9bb2d68766c5cc064352cc89045447949e090508 (diff)
downloadPROJ-c9b32000d5fc12705bea92e6509fbedb37193012.tar.gz
PROJ-c9b32000d5fc12705bea92e6509fbedb37193012.zip
Make ISO-19111 objects of type CoordinateOperation directly usable with proj_trans() and similar methods
Diffstat (limited to 'src/4D_api.cpp')
-rw-r--r--src/4D_api.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp
index 96d76ad8..43ffe72c 100644
--- a/src/4D_api.cpp
+++ b/src/4D_api.cpp
@@ -42,6 +42,9 @@
#include "projects.h"
#include "geodesic.h"
+#include "proj/common.hpp"
+#include "proj/coordinateoperation.hpp"
+
/* Initialize PJ_COORD struct */
PJ_COORD proj_coord (double x, double y, double z, double t) {
@@ -1070,9 +1073,6 @@ PJ_PROJ_INFO proj_pj_info(PJ *P) {
memset(&pjinfo, 0, sizeof(PJ_PROJ_INFO));
- /* Expected accuracy of the transformation. Hardcoded for now, will be improved */
- /* later. Most likely to be used when a transformation is set up with */
- /* proj_create_crs_to_crs in a future version that leverages the EPSG database. */
pjinfo.accuracy = -1.0;
if (nullptr==P)
@@ -1082,8 +1082,30 @@ PJ_PROJ_INFO proj_pj_info(PJ *P) {
if (pj_param(P->ctx, P->params, "tproj").i)
pjinfo.id = pj_param(P->ctx, P->params, "sproj").s;
- /* projection description */
- pjinfo.description = P->descr;
+ /* coordinate operation description */
+ if( P->iso_obj ) {
+ pjinfo.description = P->iso_obj->nameStr().c_str();
+ } else {
+ pjinfo.description = P->descr;
+ }
+
+ // accuracy
+ if( P->iso_obj ) {
+ auto conv = dynamic_cast<const NS_PROJ::operation::Conversion*>(P->iso_obj.get());
+ if( conv ) {
+ pjinfo.accuracy = 0.0;
+ } else {
+ auto op = dynamic_cast<const NS_PROJ::operation::CoordinateOperation*>(P->iso_obj.get());
+ if( op ) {
+ const auto& accuracies = op->coordinateOperationAccuracies();
+ if( !accuracies.empty() ) {
+ try {
+ pjinfo.accuracy = std::stod(accuracies[0]->value());
+ } catch ( const std::exception& ) {}
+ }
+ }
+ }
+ }
/* projection definition */
if (P->def_full)