aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@mines-paris.org>2019-03-20 11:42:39 +0100
committerGitHub <noreply@github.com>2019-03-20 11:42:39 +0100
commitd92832266a4e073d061886ce995e81064c1938e1 (patch)
tree4d76364a28e521a9563a138e26738ed8c0348903 /src
parentaa98cb82554e0bddb8af18a1ca4330c8b7191a3a (diff)
parent32a64dbbf0de76c74ef3568046062753fe63c3e1 (diff)
downloadPROJ-d92832266a4e073d061886ce995e81064c1938e1.tar.gz
PROJ-d92832266a4e073d061886ce995e81064c1938e1.zip
Merge pull request #1334 from OSGeo/backport-1333-on-6.0
Backport #1333 on 6.0
Diffstat (limited to 'src')
-rw-r--r--src/4D_api.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp
index 4f13f238..d0b2748e 100644
--- a/src/4D_api.cpp
+++ b/src/4D_api.cpp
@@ -51,6 +51,7 @@
#include "proj/common.hpp"
#include "proj/coordinateoperation.hpp"
#include "proj/internal/internal.hpp"
+#include "proj/internal/io_internal.hpp"
using namespace NS_PROJ::internal;
@@ -192,6 +193,8 @@ similarly, but prefers the 2D resp. 3D interfaces if available.
direction = opposite_direction(direction);
if( !P->alternativeCoordinateOperations.empty() ) {
+ // Do a first pass and select the first coordinate operation whose area
+ // of use is compatible with the input coordinate
int i = 0;
for( const auto &alt: P->alternativeCoordinateOperations ) {
if( direction == PJ_FWD ) {
@@ -223,6 +226,35 @@ similarly, but prefers the 2D resp. 3D interfaces if available.
}
i ++;
}
+
+ // In case we did not find an operation whose area of use is compatible
+ // with the input coordinate, then goes through again the list, and
+ // use the first operation that does not require grids.
+ i = 0;
+ for( const auto &alt: P->alternativeCoordinateOperations ) {
+ auto coordOperation = dynamic_cast<
+ NS_PROJ::operation::CoordinateOperation*>(alt.pj->iso_obj.get());
+ if( coordOperation ) {
+ if( coordOperation->gridsNeeded(P->ctx->cpp_context ?
+ P->ctx->cpp_context->databaseContext.as_nullable() :
+ nullptr).empty() ) {
+ if( P->iCurCoordOp != i ) {
+ std::string msg("Using coordinate operation ");
+ msg += alt.name;
+ pj_log(P->ctx, PJ_LOG_TRACE, msg.c_str());
+ P->iCurCoordOp = i;
+ }
+ if( direction == PJ_FWD ) {
+ return pj_fwd4d( coord, alt.pj );
+ }
+ else {
+ return pj_inv4d( coord, alt.pj );
+ }
+ }
+ }
+ i++;
+ }
+
proj_errno_set (P, EINVAL);
return proj_coord_error ();
}