aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/Makefile.am2
-rw-r--r--data/tests/test_hgrid_big_endian.gsbbin0 -> 624 bytes
-rw-r--r--data/tests/test_hgrid_little_endian.gsbbin0 -> 624 bytes
-rw-r--r--src/grids.cpp5
-rw-r--r--test/gie/more_builtins.gie20
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
new file mode 100644
index 00000000..91f2189d
--- /dev/null
+++ b/data/tests/test_hgrid_big_endian.gsb
Binary files differ
diff --git a/data/tests/test_hgrid_little_endian.gsb b/data/tests/test_hgrid_little_endian.gsb
new file mode 100644
index 00000000..13b37392
--- /dev/null
+++ b/data/tests/test_hgrid_little_endian.gsb
Binary files differ
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>