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/nad2bin.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/nad2bin.c')
| -rw-r--r-- | src/nad2bin.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/nad2bin.c b/src/nad2bin.c new file mode 100644 index 00000000..3cf5c34e --- /dev/null +++ b/src/nad2bin.c @@ -0,0 +1,68 @@ +/* Convert bivariate ASCII NAD27 to NAD83 tables to binary structure */ +#ifndef lint +static const char SCCSID[]="@(#)nad2bin.c 4.2 93/08/25 GIE REL"; +#endif +#include <stdio.h> +#include <stdlib.h> +#define PJ_LIB__ +#include <projects.h> +#define U_SEC_TO_RAD 4.848136811095359935899141023e-12 + static char +*usage = "<ASCII_dist_table local_bin_table"; + void +main(int argc, char **argv) { + struct CTABLE ct; + FLP *p, t; + size_t tsize; + int i, j, ichk; + long lam, laml, phi, phil; + FILE *bin; + + if (argc != 2) { + fprintf(stderr,"usage: %s %s\n", argv[0], usage); + exit(1); + } + fgets(ct.id, MAX_TAB_ID, stdin); + scanf("%d %d %*d %lf %lf %lf %lf", &ct.lim.lam, &ct.lim.phi, + &ct.ll.lam, &ct.del.lam, &ct.ll.phi, &ct.del.phi); + if (!(ct.cvs = (FLP *)malloc(tsize = ct.lim.lam * ct.lim.phi * + sizeof(FLP)))) { + perror("mem. alloc"); + exit(1); + } + ct.ll.lam *= DEG_TO_RAD; + ct.ll.phi *= DEG_TO_RAD; + ct.del.lam *= DEG_TO_RAD; + ct.del.phi *= DEG_TO_RAD; + /* load table */ + for (p = ct.cvs, i = 0; i < ct.lim.phi; ++i) { + scanf("%d:%ld %ld", &ichk, &laml, &phil); + if (ichk != i) { + fprintf(stderr,"format check on row\n"); + exit(1); + } + t.lam = laml * U_SEC_TO_RAD; + t.phi = phil * U_SEC_TO_RAD; + *p++ = t; + for (j = 1; j < ct.lim.lam; ++j) { + scanf("%ld %ld", &lam, &phi); + t.lam = (laml += lam) * U_SEC_TO_RAD; + t.phi = (phil += phi) * U_SEC_TO_RAD; + *p++ = t; + } + } + if (feof(stdin)) { + fprintf(stderr, "premature EOF\n"); + exit(1); + } + if (!(bin = freopen(argv[1], "wb", stdout))) { + perror(argv[1]); + exit(2); + } + if (fwrite(&ct, sizeof(ct), 1, stdout) != 1 || + fwrite(ct.cvs, tsize, 1, stdout) != 1) { + fprintf(stderr, "output failure\n"); + exit(2); + } + exit(0); /* normal completion */ +} |
