diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-09-26 12:16:15 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-09-26 12:23:56 +0200 |
| commit | 24405e60078abf9693a9d1a058824c4edd8d4f2b (patch) | |
| tree | 16a2109f41570bf2a083961e6726ca9fd6259b99 /src/4D_api.cpp | |
| parent | 6da6b21d6d01d9bc6973600c2fd336a2a515306b (diff) | |
| download | PROJ-24405e60078abf9693a9d1a058824c4edd8d4f2b.tar.gz PROJ-24405e60078abf9693a9d1a058824c4edd8d4f2b.zip | |
proj_create_crs_to_crs(): fix when there are only transformations with ballpark steps
Currently we would discard all operations, resulting in a PJ object with
zero candidates. Better use those operations if nothing better is available.
Was seen on transforming from ETRS89 / UTM zone 31N + EGM96 height to WGS 84 (G1762).
The horizontal transformation from ETRS89 to WGS 84 (G1762) is a ballpark one.
Diffstat (limited to 'src/4D_api.cpp')
| -rw-r--r-- | src/4D_api.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp index db1d9516..4b47c4e9 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -1137,6 +1137,8 @@ PJ *proj_create_crs_to_crs_from_pj (PJ_CONTEXT *ctx, const PJ *source_crs, cons try { + bool skipDefaultTransforms = true; + // Iterate over source->target candidate transformations and reproject // their long-lat bounding box into the source CRS. for( int i = 0; i < op_count; i++ ) @@ -1149,12 +1151,25 @@ PJ *proj_create_crs_to_crs_from_pj (PJ_CONTEXT *ctx, const PJ *source_crs, cons double north_lat = 0.0; const char* name = proj_get_name(op); - if( name && (strstr(name, "Ballpark geographic offset") || + bool canUseOp = true; + if( skipDefaultTransforms && + name && (strstr(name, "Ballpark geographic offset") || strstr(name, "Ballpark geocentric translation")) ) { - // Skip default transformations + // Skip default transformations unless there is already one at + // the beginning (in which case all of them will have one) + if( i == 0 ) + { + skipDefaultTransforms = false; + } + else + { + canUseOp = false; + } } - else if( proj_get_area_of_use(ctx, op, + + if( canUseOp && + proj_get_area_of_use(ctx, op, &west_lon, &south_lat, &east_lon, &north_lat, nullptr) ) { if( west_lon <= east_lon ) |
