diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-02-19 22:14:15 +0100 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2020-02-20 09:57:45 +0100 |
| commit | 86530f3146ec091c26652e60067088dc3e067fae (patch) | |
| tree | 7189e4c3622a51f6b2262e9b320a6f7afd6e6468 | |
| parent | deb3ccf5bb2f304d20f3ce09be8fd07be4817510 (diff) | |
| download | PROJ-86530f3146ec091c26652e60067088dc3e067fae.tar.gz PROJ-86530f3146ec091c26652e60067088dc3e067fae.zip | |
Fix wrong byte-swapping for NTv2 grids affecting master after RFC4 work (fixes #1938)
And add testing of both little-endian and big-endian NTv2 files
| -rw-r--r-- | data/Makefile.am | 2 | ||||
| -rw-r--r-- | data/tests/test_hgrid_big_endian.gsb | bin | 0 -> 624 bytes | |||
| -rw-r--r-- | data/tests/test_hgrid_little_endian.gsb | bin | 0 -> 624 bytes | |||
| -rw-r--r-- | src/grids.cpp | 5 | ||||
| -rw-r--r-- | test/gie/more_builtins.gie | 20 |
5 files changed, 26 insertions, 1 deletions
diff --git a/data/Makefile.am b/data/Makefile.am index b48e87a4..e284c6e0 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -87,6 +87,8 @@ EXTRA_DIST = proj.ini GL27 nad.lst nad27 nad83 \ tests/nkgrf03vel_realigned_z_extract.gtx \ tests/test_hgrid_with_two_level_of_subgrids_no_grid_name.tif \ tests/us_noaa_geoid06_ak_subset_at_antimeridian.tif \ + tests/test_hgrid_little_endian.gsb \ + tests/test_hgrid_big_endian.gsb \ generate_all_sql_in.cmake sql_filelist.cmake \ $(SQL_ORDERED_LIST) diff --git a/data/tests/test_hgrid_big_endian.gsb b/data/tests/test_hgrid_big_endian.gsb Binary files differnew file mode 100644 index 00000000..91f2189d --- /dev/null +++ b/data/tests/test_hgrid_big_endian.gsb diff --git a/data/tests/test_hgrid_little_endian.gsb b/data/tests/test_hgrid_little_endian.gsb Binary files differnew file mode 100644 index 00000000..13b37392 --- /dev/null +++ b/data/tests/test_hgrid_little_endian.gsb diff --git a/src/grids.cpp b/src/grids.cpp index ec447a33..ee5ecf52 100644 --- a/src/grids.cpp +++ b/src/grids.cpp @@ -1899,7 +1899,10 @@ std::unique_ptr<NTv2GridSet> NTv2GridSet::open(PJ_CONTEXT *ctx, if (must_swap) { // 6 double values: southLat, northLat, eastLon, westLon, resLat, // resLon - swap_words(header + OFFSET_SOUTH_LAT, sizeof(double), 6); + for (int i = 0; i < 6; i++) { + swap_words(header + OFFSET_SOUTH_LAT + 16 * i, sizeof(double), + 1); + } swap_words(header + OFFSET_GS_COUNT, sizeof(int), 1); } diff --git a/test/gie/more_builtins.gie b/test/gie/more_builtins.gie index 424f941d..78a504ff 100644 --- a/test/gie/more_builtins.gie +++ b/test/gie/more_builtins.gie @@ -854,4 +854,24 @@ accept 0 0 0 expect 0 90 -6356752.314140356 +------------------------------------------------------------------------------- +# Test handling of endianness of NTv2 grids +------------------------------------------------------------------------------- +------------------------------------------------------------------------------- +operation +proj=hgridshift +grids=tests/test_hgrid_little_endian.gsb +------------------------------------------------------------------------------- +tolerance 2 mm +accept 4.5 52.5 0 +expect 5.875 55.375 0 +------------------------------------------------------------------------------- + +------------------------------------------------------------------------------- +operation +proj=hgridshift +grids=tests/test_hgrid_big_endian.gsb +------------------------------------------------------------------------------- +tolerance 2 mm +accept 4.5 52.5 0 +expect 5.875 55.375 0 +------------------------------------------------------------------------------- + + </gie> |
