diff options
| author | Frank Warmerdam <warmerdam@pobox.com> | 2011-11-22 22:51:47 +0000 |
|---|---|---|
| committer | Frank Warmerdam <warmerdam@pobox.com> | 2011-11-22 22:51:47 +0000 |
| commit | cf37b02b5540ddf8fb1d9fcf4658a55e3fcaeb33 (patch) | |
| tree | 111b38c0a3d5a0b7b54c790130aebd107c8a2781 /src/pj_gridinfo.c | |
| parent | d2d560d04c4a1cf78ba3cedb8be9993e3037870c (diff) | |
| download | PROJ-cf37b02b5540ddf8fb1d9fcf4658a55e3fcaeb33.tar.gz PROJ-cf37b02b5540ddf8fb1d9fcf4658a55e3fcaeb33.zip | |
implement support for ctable2 format (read/write)
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@2121 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src/pj_gridinfo.c')
| -rw-r--r-- | src/pj_gridinfo.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/pj_gridinfo.c b/src/pj_gridinfo.c index 34e65fb2..cba1e672 100644 --- a/src/pj_gridinfo.c +++ b/src/pj_gridinfo.c @@ -122,8 +122,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) return 0; /* -------------------------------------------------------------------- */ -/* ctable is currently loaded on initialization though there is */ -/* no real reason not to support delayed loading for it as well. */ +/* Original platform specific CTable format. */ /* -------------------------------------------------------------------- */ if( strcmp(gi->format,"ctable") == 0 ) { @@ -146,6 +145,29 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) } /* -------------------------------------------------------------------- */ +/* CTable2 format. */ +/* -------------------------------------------------------------------- */ + else if( strcmp(gi->format,"ctable2") == 0 ) + { + FILE *fid; + int result; + + fid = pj_open_lib( ctx, gi->filename, "rb" ); + + if( fid == NULL ) + { + pj_ctx_set_errno( ctx, -38 ); + return 0; + } + + result = nad_ctable2_load( ctx, gi->ct, fid ); + + fclose( fid ); + + return result; + } + +/* -------------------------------------------------------------------- */ /* NTv1 format. */ /* We process one line at a time. Note that the array storage */ /* direction (e-w) is different in the NTv1 file and what */ @@ -810,6 +832,22 @@ PJ_GRIDINFO *pj_gridinfo_init( projCtx ctx, const char *gridname ) pj_gridinfo_init_gtx( ctx, fp, gilist ); } + else if( strncmp(header+0,"CTABLE V2",9) == 0 ) + { + struct CTABLE *ct = nad_ctable2_init( ctx, fp ); + + gilist->format = "ctable2"; + gilist->ct = ct; + + pj_log( ctx, PJ_LOG_DEBUG_MAJOR, + "Ctable2 %s %dx%d: LL=(%.9g,%.9g) UR=(%.9g,%.9g)\n", + ct->id, + ct->lim.lam, ct->lim.phi, + ct->ll.lam * RAD_TO_DEG, ct->ll.phi * RAD_TO_DEG, + (ct->ll.lam + (ct->lim.lam-1)*ct->del.lam) * RAD_TO_DEG, + (ct->ll.phi + (ct->lim.phi-1)*ct->del.phi) * RAD_TO_DEG ); + } + else { struct CTABLE *ct = nad_ctable_init( ctx, fp ); |
