diff options
| author | Frank Warmerdam <warmerdam@pobox.com> | 1999-03-18 16:34:52 +0000 |
|---|---|---|
| committer | Frank Warmerdam <warmerdam@pobox.com> | 1999-03-18 16:34:52 +0000 |
| commit | 565a4bd035b9d4a83955808efef20f1d8dfa24cf (patch) | |
| tree | 75785fc897708023f1ccdaf40079afcbaaf0fd3a /src/nad_init.c | |
| download | PROJ-565a4bd035b9d4a83955808efef20f1d8dfa24cf.tar.gz PROJ-565a4bd035b9d4a83955808efef20f1d8dfa24cf.zip | |
New
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@776 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src/nad_init.c')
| -rw-r--r-- | src/nad_init.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/nad_init.c b/src/nad_init.c new file mode 100644 index 00000000..ed3b6273 --- /dev/null +++ b/src/nad_init.c @@ -0,0 +1,43 @@ +/* open structure for NAD27<->NAD83 conversion */ +#ifndef lint +static const char SCCSID[]="@(#)nad_init.c 4.5 94/10/30 GIE REL"; +#endif +#define PJ_LIB__ +#include <projects.h> +#include <stdio.h> +#include <errno.h> +extern FILE *pj_open_lib(char *, char *); + struct CTABLE * +nad_init(char *name) { + char fname[MAX_PATH_FILENAME+1]; + struct CTABLE *ct; + FILE *fid; + size_t i; + + errno = pj_errno = 0; + strcpy(fname, "nad2783/"); + strcat(fname, name); + if (!(fid = pj_open_lib(fname, "rb"))) { + pj_errno = errno; + return 0; + } + if (!(ct = pj_malloc(sizeof(struct CTABLE))) || + fread(ct, sizeof(struct CTABLE), 1, fid) != 1 || + !(ct->cvs = (FLP *)pj_malloc(i=sizeof(FLP)*ct->lim.lam*ct->lim.phi)) || + fread(ct->cvs, i, 1, fid) != 1) { + nad_free(ct); + pj_errno = -38; + ct = 0; + return 0; + } + fclose(fid); + pj_errno = 0; + return ct; +} + void +nad_free(struct CTABLE *ct) { + if (ct) { + pj_dalloc(ct->cvs); + pj_dalloc(ct); + } +} |
