diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2019-01-19 08:35:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-19 08:35:10 +0100 |
| commit | 14bc57241da2756073ca7c0bd44c61386d45c38f (patch) | |
| tree | 690ce807e17e35dbe7756ed116988d262c78b429 /src | |
| parent | d75f2efbba70ccdf1a9630d7cb8bc705ec151a8c (diff) | |
| parent | c6ab83f5742bc5ac6f9cb9a8b2a4f1ea241b6f63 (diff) | |
| download | PROJ-14bc57241da2756073ca7c0bd44c61386d45c38f.tar.gz PROJ-14bc57241da2756073ca7c0bd44c61386d45c38f.zip | |
Merge pull request #1226 from kbevers/remove-chebyshev
Remove Chebyshev polynomials from proj
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.am | 4 | ||||
| -rw-r--r-- | src/apps/gen_cheb.cpp | 107 | ||||
| -rw-r--r-- | src/apps/p_series.cpp | 43 | ||||
| -rw-r--r-- | src/apps/proj.cpp | 36 | ||||
| -rw-r--r-- | src/bin_cs2cs.cmake | 2 | ||||
| -rw-r--r-- | src/bin_proj.cmake | 4 |
6 files changed, 7 insertions, 189 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 3b23a044..fabea4bf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,9 +18,9 @@ EXTRA_DIST = bin_cct.cmake bin_gie.cmake bin_cs2cs.cmake \ lib_proj.cmake CMakeLists.txt bin_geodtest.cmake tests/geodtest.cpp \ wkt1_grammar.y wkt2_grammar.y apps/emess.h -proj_SOURCES = apps/proj.cpp apps/gen_cheb.cpp apps/p_series.cpp apps/emess.cpp +proj_SOURCES = apps/proj.cpp apps/emess.cpp projinfo_SOURCES = apps/projinfo.cpp -cs2cs_SOURCES = apps/cs2cs.cpp apps/gen_cheb.cpp apps/p_series.cpp apps/emess.cpp +cs2cs_SOURCES = apps/cs2cs.cpp apps/emess.cpp cct_SOURCES = apps/cct.cpp apps/proj_strtod.cpp apps/proj_strtod.h apps/optargpm.h nad2bin_SOURCES = apps/nad2bin.cpp geod_SOURCES = apps/geod.cpp apps/geod_set.cpp apps/geod_interface.cpp apps/geod_interface.h apps/emess.cpp diff --git a/src/apps/gen_cheb.cpp b/src/apps/gen_cheb.cpp deleted file mode 100644 index 23285314..00000000 --- a/src/apps/gen_cheb.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* generates 'T' option output */ -#define PJ_LIB__ -#include "proj.h" -#include "proj_internal.h" -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include "emess.h" -#ifndef COEF_LINE_MAX -#define COEF_LINE_MAX 50 -#endif - -static double strtod_type_safe(const char *s, const char ** endptr) -{ - char* l_endptr = nullptr; - double ret= strtod(s, &l_endptr); - if( endptr ) - *endptr = static_cast<const char*>(l_endptr); - return ret; -} - -static double dmstor_type_safe(const char *s, const char ** endptr) -{ - char* l_endptr = nullptr; - double ret= dmstor(s, &l_endptr); - if( endptr ) - *endptr = static_cast<const char*>(l_endptr); - return ret; -} - -static long strtol_type_safe(const char *s, const char ** endptr, int base) -{ - char* l_endptr = nullptr; - long ret = strtol(s, &l_endptr, base); - if( endptr ) - *endptr = static_cast<const char*>(l_endptr); - return ret; -} - - -/* FIXME: put the declaration in a header. Also used in proj.c */ -void gen_cheb(int inverse, PJ_UV (*proj)(PJ_UV), const char *s, PJ *P, - int iargc, char **iargv); -extern void p_series(Tseries *, FILE *, char *); - -void gen_cheb(int inverse, PJ_UV (*proj)(PJ_UV), const char *s, PJ *P, - int iargc, char **iargv) { - long NU = 15, NV = 15; - int errin = 0, pwr; - long res = -1; - char *arg, fmt[32]; - PJ_UV low, upp, resid; - Tseries *F; - double (*input)(const char *, const char **); - - input = inverse ? strtod_type_safe : dmstor_type_safe; - if (*s) low.u = input(s, &s); else { low.u = 0; ++errin; } - if (*s == ',') upp.u = input(s+1, &s); else { upp.u = 0; ++errin; } - if (*s == ',') low.v = input(s+1, &s); else { low.v = 0; ++errin; } - if (*s == ',') upp.v = input(s+1, &s); else { upp.v = 0; ++errin; } - if (errin) - emess(16,"null or absent -T parameters"); - if (*s == ',') if (*++s != ',') res = strtol_type_safe(s, &s, 10); - if (*s == ',') if (*++s != ',') NU = strtol_type_safe(s, &s, 10); - if (*s == ',') if (*++s != ',') NV = strtol_type_safe(s, &s, 10); - pwr = s && *s && !strcmp(s, ",P"); - (void)printf("#proj_%s\n# run-line:\n", - pwr ? "Power" : "Chebyshev"); - if (iargc > 0) { /* proj execution audit trail */ - int n = 0, L; - - for ( ; iargc ; --iargc) { - arg = *iargv++; - if (*arg != '+') { - if (!n) { putchar('#'); ++n; } - (void)printf(" %s%n",arg, &L); - if ((n += L) > COEF_LINE_MAX) { putchar('\n'); n = 0; } - } - } - if (n) putchar('\n'); - } - (void)printf("# projection parameters\n"); - pj_pr_list(P); - if (low.u == upp.u || low.v >= upp.v) - emess(16,"approx. argument range error"); - if (low.u > upp.u) - low.u -= M_TWOPI; - if (NU < 2 || NV < 2 || NU > INT_MAX || NV > INT_MAX) - emess(16,"approx. work dimensions (%ld %ld) too small or large",NU,NV); - if (!(F = mk_cheby(low, upp, pow(10., (double)res)*.5, &resid, proj, - (int)NU, (int)NV, pwr))) - emess(16,"generation of approx failed\nreason: %s\n", - pj_strerrno(errno)); - (void)printf("%c,%.12g,%.12g,%.12g,%.12g,%.12g\n",inverse?'I':'F', - P->lam0*RAD_TO_DEG, - low.u*(inverse?1.:RAD_TO_DEG),upp.u*(inverse?1.:RAD_TO_DEG), - low.v*(inverse?1.:RAD_TO_DEG),upp.v*(inverse?1.:RAD_TO_DEG)); - if (pwr) - strcpy(fmt, "%.15g"); - else if (res <= 0) - (void)sprintf(fmt,"%%.%ldf",-res+1); - else - (void)strcpy(fmt,"%.0f"); - p_series(F, stdout, fmt); - (void)printf("# |u,v| sums %g %g\n#end_proj_%s\n", - resid.u, resid.v, pwr ? "Power" : "Chebyshev"); -} diff --git a/src/apps/p_series.cpp b/src/apps/p_series.cpp deleted file mode 100644 index 2f668ce0..00000000 --- a/src/apps/p_series.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* print row coefficients of Tseries structure */ -#include "proj.h" -#include "proj_internal.h" -#include <stdio.h> -#include <string.h> -#define NF 20 /* length of final format string */ -#define CUT 60 /* check length of line */ - -/* FIXME: put the declaration in a header. Also used in gen_cheb.c */ -void p_series(Tseries *T, FILE *file, char *fmt); - -void p_series(Tseries *T, FILE *file, char *fmt) { - int i, j, n, L; - char format[NF+1]; - - *format = ' '; - strncpy(format + 1, fmt, NF - 3); - strcat(format, "%n"); - fprintf(file, "u: %d\n", T->mu+1); - for (i = 0; i <= T->mu; ++i) - if (T->cu[i].m) { - fprintf(file, "%d %d%n", i, T->cu[i].m, &L); - n = 0; - for (j = 0; j < T->cu[i].m; ++j) { - if ((L += n) > CUT) - fprintf(file, "\n %n", &L); - fprintf(file, format, T->cu[i].c[j], &n); - } - fputc('\n', file); - } - fprintf(file, "v: %d\n", T->mv+1); - for (i = 0; i <= T->mv; ++i) - if (T->cv[i].m) { - fprintf(file, "%d %d%n", i, T->cv[i].m, &L); - n = 0; - for (j = 0; j < T->cv[i].m; ++j) { - if ((L += n) > 60) - fprintf(file, "\n %n", &L); - fprintf(file, format, T->cv[i].c[j], &n); - } - fputc('\n', file); - } -} diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp index c8cd20a1..298a44e8 100644 --- a/src/apps/proj.cpp +++ b/src/apps/proj.cpp @@ -20,8 +20,6 @@ #define MAX_PARGS 100 #define PJ_INVERS(P) (P->inv ? 1 : 0) -extern void gen_cheb(int, PJ_UV(*)(PJ_UV), const char *, PJ *, int, char **); - static PJ *Proj; static union { PJ_UV (*generic)(PJ_UV, PJ *); @@ -43,7 +41,6 @@ static int postscale = 0; static const char - *cheby_str, /* string controlling Chebychev evaluation */ *oform = nullptr; /* output format for x-y or decimal degrees */ static char oform_buffer[16]; /* Buffer for oform when using -d */ @@ -56,22 +53,6 @@ static PJ_FACTORS facs; static double (*informat)(const char *, char **), /* input data deformatter function */ fscale = 0.; /* cartesian scale factor */ -static PJ_UV int_proj(PJ_UV data) { - if (prescale) { - data.u *= fscale; - data.v *= fscale; - } - - data = (*proj.generic)(data, Proj); - - if (postscale && data.u != HUGE_VAL) { - data.u *= fscale; - data.v *= fscale; - } - - return data; -} - /* file processing function */ static void process(FILE *fid) { char line[MAX_LINE+3], *s = nullptr, pline[40]; @@ -309,10 +290,10 @@ static void vprocess(FILE *fid) { } int main(int argc, char **argv) { - char *arg, *pargv[MAX_PARGS], **iargv = argv; + char *arg, *pargv[MAX_PARGS]; char **eargv = argv; FILE *fid; - int pargc = 0, iargc = argc, eargc = 0, mon = 0; + int pargc = 0, eargc = 0, mon = 0; if ( (emess_dat.Prog_name = strrchr(*argv,DIR_CHAR)) != nullptr) ++emess_dat.Prog_name; @@ -425,10 +406,6 @@ int main(int argc, char **argv) { emess(1,"missing argument for -%c",*arg); oterr = *++argv; continue; - case 'T': /* generate Chebyshev coefficients */ - if (--argc <= 0) goto noargument; - cheby_str = *++argv; - continue; case 'm': /* cartesian multiplier */ if (--argc <= 0) goto noargument; postscale = 1; @@ -482,10 +459,9 @@ int main(int argc, char **argv) { } else /* assumed to be input file name(s) */ eargv[eargc++] = *argv; } - if (eargc == 0 && !cheby_str) /* if no specific files force sysin */ + if (eargc == 0) /* if no specific files force sysin */ eargv[eargc++] = const_cast<char*>("-"); - else if (eargc > 0 && cheby_str) /* warning */ - emess(4, "data files when generating Chebychev prohibited"); + /* done with parameter and control input */ if (inverse && postscale) { prescale = 1; @@ -512,10 +488,6 @@ int main(int argc, char **argv) { proj.inv = pj_inv; } else proj.fwd = pj_fwd; - if (cheby_str) { - gen_cheb(inverse, int_proj, cheby_str, Proj, iargc, iargv); - exit(0); - } /* set input formatting control */ if (mon) { diff --git a/src/bin_cs2cs.cmake b/src/bin_cs2cs.cmake index c9543e89..d520192c 100644 --- a/src/bin_cs2cs.cmake +++ b/src/bin_cs2cs.cmake @@ -1,6 +1,4 @@ set(CS2CS_SRC apps/cs2cs.cpp - apps/gen_cheb.cpp - apps/p_series.cpp apps/emess.cpp ) diff --git a/src/bin_proj.cmake b/src/bin_proj.cmake index 4bd690ff..76e2ae9f 100644 --- a/src/bin_proj.cmake +++ b/src/bin_proj.cmake @@ -1,6 +1,4 @@ -set(PROJ_SRC apps/proj.cpp - apps/gen_cheb.cpp - apps/p_series.cpp +set(PROJ_SRC apps/proj.cpp apps/emess.cpp ) |
