diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-10-08 15:47:48 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-10-08 15:56:30 +0200 |
| commit | f080fc81167f7b091252c24828c288884ffdbfba (patch) | |
| tree | 33875cfbaf7b6dc3fe907ab32de4c2bb94e908f6 | |
| parent | cc33c1324b5c815901f056abd8baa49ffb064ccd (diff) | |
| download | PROJ-f080fc81167f7b091252c24828c288884ffdbfba.tar.gz PROJ-f080fc81167f7b091252c24828c288884ffdbfba.zip | |
NTv1 grid shift: fix file offset for reading of shift values in ntv1_can.dat
When investigating the format of NTv1 and comparing PROJ code with the actual
header of ntv1_can.dat, I discovered that the longitude & latitude shift values
started at offset 192, whereas PROJ assumed that the header was 176 bytes only.
This caused PROJ to use the wrong offsets values (shift of one grid sample by
longitude). So the effect was moderately visible, especially on the latitude,
but when comparing with NTv2, one can see that the longitude value after the
fix seems to closer to NTv2.
old:
echo "60.5 -100.5 0" | PROJ_LIB=/usr/share/proj src/cct -d 8 +proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=ntv1_can.dat +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1
60.50022624 -100.50040292 0.00000000 inf
new:
echo "60.5 -100.5 0" | PROJ_LIB=/usr/share/proj src/cct -d 8 +proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=ntv1_can.dat +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1
60.50022403 -100.50041841 0.00000000 inf
echo "60.5 -100.5 0" | PROJ_LIB=/usr/share/proj src/cct -d 8 +proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=$HOME/proj/proj-datumgrid/north-america/ntv2_0.gsb +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1
60.50022348 -100.50041978 0.00000000 inf
old:
$ echo "80.1 -70.9 0" | PROJ_LIB=/usr/share/proj src/cct -d 8 +proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=ntv1_can.dat +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1
80.10096789 -70.89746834 0.00000000 inf
new:
$ echo "80.1 -70.9 0" | PROJ_LIB=/usr/share/proj src/cct -d 8 +proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=ntv1_can.dat +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1
80.10096858 -70.89749190 0.00000000 inf
$ echo "80.1 -70.9 0" | PROJ_LIB=/usr/share/proj src/cct -d 8 +proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=hgridshift +grids=$HOME/proj/proj-datumgrid/north-america/ntv2_0.gsb +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1
80.10096782 -70.89749276 0.00000000 inf
| -rw-r--r-- | src/pj_gridinfo.c | 4 | ||||
| -rw-r--r-- | test/old/td_out.dist | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/pj_gridinfo.c b/src/pj_gridinfo.c index f201f39e..de0e8d31 100644 --- a/src/pj_gridinfo.c +++ b/src/pj_gridinfo.c @@ -660,7 +660,7 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist ) static int pj_gridinfo_init_ntv1( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi ) { - unsigned char header[176]; + unsigned char header[192]; /* 12 records of 16 bytes */ struct CTABLE *ct; LP ur; @@ -731,7 +731,7 @@ static int pj_gridinfo_init_ntv1( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi ) ct->cvs = NULL; gi->ct = ct; - gi->grid_offset = pj_ctx_ftell( ctx, fid ); + gi->grid_offset = (long) sizeof(header); gi->format = "ntv1"; return 1; diff --git a/test/old/td_out.dist b/test/old/td_out.dist index 060d14d2..f6b2a219 100644 --- a/test/old/td_out.dist +++ b/test/old/td_out.dist @@ -1,6 +1,6 @@ ############################################################## 1st through ntv1, 2nd through conus -111d00'00.000"W 44d00'00.000"N 0.0 111d0'3.085"W 43d59'59.756"N 0.000 +111d00'00.000"W 44d00'00.000"N 0.0 111d0'3.208"W 43d59'59.732"N 0.000 111d00'00.000"W 39d00'00.000"N 0.0 111d0'2.604"W 38d59'59.912"N 0.000 ############################################################## As above, but without ntv1 everything goes through conus file. |
