diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-09-15 13:43:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-15 13:43:35 +0200 |
| commit | dcc0acb22124a3b463415532d918fb649f72a1cf (patch) | |
| tree | 80110c1a85f1b1b790a86c4575806f6616323335 | |
| parent | 6dcbdb941c0e1faef8f60a80c6c3aab483850bcb (diff) | |
| parent | 6da584d4134d15f8617e750651cf377b3f48a7b8 (diff) | |
| download | PROJ-dcc0acb22124a3b463415532d918fb649f72a1cf.tar.gz PROJ-dcc0acb22124a3b463415532d918fb649f72a1cf.zip | |
Merge pull request #1611 from rouault/fix1563
cs2cs: autopromote CRS to 3D when there's a mix of 2D and 3D (fixes #1563)
| -rw-r--r-- | src/apps/cs2cs.cpp | 26 | ||||
| -rw-r--r-- | test/cli/Makefile.am | 2 | ||||
| -rw-r--r-- | test/cli/td_out.dist | 3 | ||||
| -rwxr-xr-x | test/cli/testdatumfile | 8 |
4 files changed, 36 insertions, 3 deletions
diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index 3099c3e8..ed885dc6 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -43,6 +43,7 @@ // PROJ include order is sensitive // clang-format off #include "proj.h" +#include "proj_experimental.h" #include "proj_internal.h" #include "emess.h" #include "utils.h" @@ -591,12 +592,33 @@ int main(int argc, char **argv) { } srcIsGeog = true; } + proj_destroy(src); + proj_destroy(dst); + + src = proj_create(nullptr, pj_add_type_crs_if_needed(fromStr).c_str()); + dst = proj_create(nullptr, pj_add_type_crs_if_needed(toStr).c_str()); + + if( proj_get_type(src) == PJ_TYPE_COMPOUND_CRS || + proj_get_type(dst) == PJ_TYPE_COMPOUND_CRS ) { + auto src3D = proj_crs_promote_to_3D(nullptr, nullptr, src); + if( src3D ) { + proj_destroy(src); + src = src3D; + } + + auto dst3D = proj_crs_promote_to_3D(nullptr, nullptr, dst); + if( dst3D ) { + proj_destroy(dst); + dst = dst3D; + } + } + + transformation = proj_create_crs_to_crs_from_pj(nullptr, src, dst, + nullptr, nullptr); proj_destroy(src); proj_destroy(dst); - transformation = proj_create_crs_to_crs(nullptr, fromStr.c_str(), - toStr.c_str(), nullptr); if (!transformation) { emess(3, "cannot initialize transformation\ncause: %s", pj_strerrno(pj_errno)); diff --git a/test/cli/Makefile.am b/test/cli/Makefile.am index 47cb1e7f..db47370c 100644 --- a/test/cli/Makefile.am +++ b/test/cli/Makefile.am @@ -39,7 +39,7 @@ testvarious-check: PROJ_LIB=$(PROJ_LIB) $(TESTVARIOUS) $(CS2CSEXE) testdatumfile-check: - @if [ -f $(PROJ_LIB)/conus -a -f $(PROJ_LIB)/ntv1_can.dat -a -f $(PROJ_LIB)/MD -a -f $(PROJ_LIB)/ntf_r93.gsb ]; then \ + @if [ -f $(PROJ_LIB)/conus -a -f $(PROJ_LIB)/ntv1_can.dat -a -f $(PROJ_LIB)/MD -a -f $(PROJ_LIB)/ntf_r93.gsb -a -f $(PROJ_LIB)/egm96_15.gtx ]; then \ PROJ_LIB=$(PROJ_LIB) $(TESTDATUMFILE) $(CS2CSEXE) ; \ fi diff --git a/test/cli/td_out.dist b/test/cli/td_out.dist index cdbe0fa9..417d5203 100644 --- a/test/cli/td_out.dist +++ b/test/cli/td_out.dist @@ -27,3 +27,6 @@ edge or even a wee bit outside (#141). NAD27 -> NAD83: 1st through ntv1, 2nd through conus 44d00'00.000"N 111d00'00.000"W 0.0 43d59'59.732"N 111d0'3.208"W 0.000 39d00'00.000"N 111d00'00.000"W 0.0 38d59'59.912"N 111d0'2.604"W 0.000 +############################################################## +WGS84 -> WGS84+EGM96 +49N 2E 0 2.00 49.00 -44.64 diff --git a/test/cli/testdatumfile b/test/cli/testdatumfile index 5b56f077..b528cfa7 100755 --- a/test/cli/testdatumfile +++ b/test/cli/testdatumfile @@ -105,6 +105,14 @@ $EXE NAD27 NAD83 -E >>${OUT} <<EOF 39d00'00.000"N 111d00'00.000"W 0.0 EOF +# +echo "##############################################################" >> ${OUT} +echo "WGS84 -> WGS84+EGM96" >> ${OUT} +# +$EXE +init=epsg:4326 +to +init=epsg:4326 +geoidgrids=egm96_15.gtx -E >>${OUT} <<EOF +49N 2E 0 +EOF + # Cleanup rm -rf "dir with \" space" |
