From c9b32000d5fc12705bea92e6509fbedb37193012 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 26 Dec 2018 13:42:46 +0100 Subject: Make ISO-19111 objects of type CoordinateOperation directly usable with proj_trans() and similar methods --- src/4D_api.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/4D_api.cpp') 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(P->iso_obj.get()); + if( conv ) { + pjinfo.accuracy = 0.0; + } else { + auto op = dynamic_cast(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) -- cgit v1.2.3