diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2016-07-13 15:36:32 +0200 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2016-07-13 15:36:32 +0200 |
| commit | 196a1bb848dbd8f080d8ad6769f478c17c96d409 (patch) | |
| tree | 9f84757aeebad520c41153f7c3b20ee5deca461f /src/projects.h | |
| parent | b9b92997206fd4adef945240dff8cfe97fcfe12c (diff) | |
| download | PROJ-196a1bb848dbd8f080d8ad6769f478c17c96d409.tar.gz PROJ-196a1bb848dbd8f080d8ad6769f478c17c96d409.zip | |
Eliminated load time non-computable initializers in healpix
Diffstat (limited to 'src/projects.h')
| -rw-r--r-- | src/projects.h | 280 |
1 files changed, 145 insertions, 135 deletions
diff --git a/src/projects.h b/src/projects.h index 9aca7d95..ced5a4f0 100644 --- a/src/projects.h +++ b/src/projects.h @@ -54,15 +54,15 @@ extern "C" { #endif #ifndef NULL -# define NULL 0 +# define NULL 0 #endif #ifndef FALSE -# define FALSE 0 +# define FALSE 0 #endif #ifndef TRUE -# define TRUE 1 +# define TRUE 1 #endif #ifndef MAX @@ -74,11 +74,12 @@ extern "C" { # define ABS(x) ((x<0) ? (-1*(x)) : x) #endif - /* maximum path/filename */ +/* maximum path/filename */ #ifndef MAX_PATH_FILENAME #define MAX_PATH_FILENAME 1024 #endif - /* prototype hypot for systems where absent */ + +/* prototype hypot for systems where absent */ #ifndef _WIN32 extern double hypot(double, double); #endif @@ -97,15 +98,23 @@ extern double hypot(double, double); #define _USE_MATH_DEFINES #endif +/* If we still haven't got M_PI*, we rely on our own defines. + * For example, this is necessary when compiling with gcc and + * the -ansi flag. + */ +#ifndef M_PI +#define M_PI 3.14159265358979310 +#define M_PI_2 1.57079632679489660 +#define M_PI_4 0.78539816339744828 +#endif + /* some more useful math constants and aliases */ -#define M_FORTPI M_PI_4 /* pi/4 */ -#define M_HALFPI M_PI_2 /* pi/2 */ -/* M_PI pi */ -#define M_PI_HALFPI 4.71238898038468985769 /* 1.5*pi */ -#define M_TWOPI 6.28318530717958647693 /* 2*pi */ -#define M_TWO_D_PI M_2_PI /* 2/pi */ -#define M_TWOPI_HALFPI 7.85398163397448309616 /* 2.5*pi */ -/* M_SQRT2 sqrt(2) */ +#define M_FORTPI M_PI_4 /* pi/4 */ +#define M_HALFPI M_PI_2 /* pi/2 */ +#define M_PI_HALFPI 4.71238898038468985769 /* 1.5*pi */ +#define M_TWOPI 6.28318530717958647693 /* 2*pi */ +#define M_TWO_D_PI M_2_PI /* 2/pi */ +#define M_TWOPI_HALFPI 7.85398163397448309616 /* 2.5*pi */ /* maximum tag id length for +init and default files */ @@ -133,7 +142,7 @@ struct projFileAPI_t; /* proj thread context */ typedef struct { - int last_errno; + int last_errno; int debug_level; void (*logger)(void *, int, const char *); void *app_data; @@ -156,7 +165,7 @@ typedef struct { #define USE_PROJUV typedef struct { double u, v; } projUV; -typedef struct { double r, i; } COMPLEX; +typedef struct { double r, i; } COMPLEX; typedef struct { double u, v, w; } projUVW; #ifndef PJ_LIB__ @@ -175,39 +184,39 @@ typedef union { double f; int i; char *s; } PROJVALUE; struct PJconsts; struct PJ_LIST { - char *id; /* projection keyword */ - struct PJconsts *(*proj)(struct PJconsts*);/* projection entry point */ - char * const *descr; /* description text */ + char *id; /* projection keyword */ + struct PJconsts *(*proj)(struct PJconsts*); /* projection entry point */ + char * const *descr; /* description text */ }; /* Merging this into the PJ_LIST infrastructure is tempting, but may imply ABI breakage. Perhaps at next major version? */ struct PJ_SELFTEST_LIST { - char *id; /* projection keyword */ - int (* testfunc)(void); /* projection entry point */ + char *id; /* projection keyword */ + int (* testfunc)(void); /* projection entry point */ }; struct PJ_ELLPS { - char *id; /* ellipse keyword name */ - char *major; /* a= value */ - char *ell; /* elliptical parameter */ - char *name; /* comments */ + char *id; /* ellipse keyword name */ + char *major; /* a= value */ + char *ell; /* elliptical parameter */ + char *name; /* comments */ }; struct PJ_UNITS { - char *id; /* units keyword */ - char *to_meter; /* multiply by value to get meters */ - char *name; /* comments */ + char *id; /* units keyword */ + char *to_meter; /* multiply by value to get meters */ + char *name; /* comments */ }; struct PJ_DATUMS { - char *id; /* datum keyword */ - char *defn; /* ie. "to_wgs84=..." */ - char *ellipse_id; /* ie from ellipse table */ - char *comments; /* EPSG code, etc */ + char *id; /* datum keyword */ + char *defn; /* ie. "to_wgs84=..." */ + char *ellipse_id;/* ie from ellipse table */ + char *comments; /* EPSG code, etc */ }; struct PJ_PRIME_MERIDIANS { - char *id; /* prime meridian keyword */ - char *defn; /* offset from greenwich in DMS format. */ + char *id; /* prime meridian keyword */ + char *defn; /* offset from greenwich in DMS format. */ }; typedef struct { @@ -218,31 +227,32 @@ typedef struct { } PJ_Region; struct DERIVS { - double x_l, x_p; /* derivatives of x for lambda-phi */ - double y_l, y_p; /* derivatives of y for lambda-phi */ + double x_l, x_p; /* derivatives of x for lambda-phi */ + double y_l, y_p; /* derivatives of y for lambda-phi */ }; struct FACTORS { - struct DERIVS der; - double h, k; /* meridinal, parallel scales */ - double omega, thetap; /* angular distortion, theta prime */ - double conv; /* convergence */ - double s; /* areal scale factor */ - double a, b; /* max-min scale error */ - int code; /* info as to analytics, see following */ + struct DERIVS der; + double h, k; /* meridinal, parallel scales */ + double omega, thetap; /* angular distortion, theta prime */ + double conv; /* convergence */ + double s; /* areal scale factor */ + double a, b; /* max-min scale error */ + int code; /* info as to analytics, see following */ }; -#define IS_ANAL_XL_YL 01 /* derivatives of lon analytic */ -#define IS_ANAL_XP_YP 02 /* derivatives of lat analytic */ -#define IS_ANAL_HK 04 /* h and k analytic */ -#define IS_ANAL_CONV 010 /* convergence analytic */ - /* parameter list struct */ -typedef struct ARG_list { - struct ARG_list *next; - char used; - char param[1]; } paralist; - /* base projection data structure */ +#define IS_ANAL_XL_YL 01 /* derivatives of lon analytic */ +#define IS_ANAL_XP_YP 02 /* derivatives of lat analytic */ +#define IS_ANAL_HK 04 /* h and k analytic */ +#define IS_ANAL_CONV 010 /* convergence analytic */ + +/* parameter list struct */ +typedef struct ARG_list { + struct ARG_list *next; + char used; + char param[1]; } paralist; +/* base projection data structure */ #ifdef PJ_LIB__ /* we need this forward declaration in order to be able to add a pointer to struct opaque to the typedef struct PJconsts below */ @@ -251,60 +261,60 @@ typedef struct ARG_list { typedef struct PJconsts { projCtx_t *ctx; - XY (*fwd)(LP, struct PJconsts *); - LP (*inv)(XY, struct PJconsts *); - XYZ (*fwd3d)(LPZ, struct PJconsts *); - LPZ (*inv3d)(XYZ, struct PJconsts *); - void (*spc)(LP, struct PJconsts *, struct FACTORS *); - void (*pfree)(struct PJconsts *); - const char *descr; - paralist *params; /* parameter list */ - int over; /* over-range flag */ - int geoc; /* geocentric latitude flag */ - int is_latlong; /* proj=latlong ... not really a projection at all */ - int is_geocent; /* proj=geocent ... not really a projection at all */ - double - a, /* major axis or radius if es==0 */ - a_orig, /* major axis before any +proj related adjustment */ - es, /* e ^ 2 */ - es_orig, /* es before any +proj related adjustment */ - e, /* eccentricity */ - ra, /* 1/A */ - one_es, /* 1 - e^2 */ - rone_es, /* 1/one_es */ - lam0, phi0, /* central longitude, latitude */ - x0, y0, /* easting and northing */ - k0, /* general scaling factor */ - to_meter, fr_meter; /* cartesian scaling */ - - int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */ - double datum_params[7]; - struct _pj_gi **gridlist; - int gridlist_count; - - int has_geoid_vgrids; - struct _pj_gi **vgridlist_geoid; - int vgridlist_geoid_count; - double vto_meter, vfr_meter; - - double from_greenwich; /* prime meridian offset (in radians) */ - double long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/ - int is_long_wrap_set; - char axis[4]; - - /* New Datum Shift Grid Catalogs */ - char *catalog_name; - struct _PJ_GridCatalog *catalog; - - double datum_date; - - struct _pj_gi *last_before_grid; - PJ_Region last_before_region; - double last_before_date; - - struct _pj_gi *last_after_grid; - PJ_Region last_after_region; - double last_after_date; + XY (*fwd)(LP, struct PJconsts *); + LP (*inv)(XY, struct PJconsts *); + XYZ (*fwd3d)(LPZ, struct PJconsts *); + LPZ (*inv3d)(XYZ, struct PJconsts *); + void (*spc)(LP, struct PJconsts *, struct FACTORS *); + void (*pfree)(struct PJconsts *); + + const char *descr; + paralist *params; /* parameter list */ + int over; /* over-range flag */ + int geoc; /* geocentric latitude flag */ + int is_latlong; /* proj=latlong ... not really a projection at all */ + int is_geocent; /* proj=geocent ... not really a projection at all */ + double a; /* major axis or radius if es==0 */ + double a_orig; /* major axis before any +proj related adjustment */ + double es; /* e ^ 2 */ + double es_orig; /* es before any +proj related adjustment */ + double e; /* eccentricity */ + double ra; /* 1/A */ + double one_es; /* 1 - e^2 */ + double rone_es; /* 1/one_es */ + double lam0, phi0; /* central longitude, latitude */ + double x0, y0; /* easting and northing */ + double k0; /* general scaling factor */ + double to_meter, fr_meter; /* cartesian scaling */ + + int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */ + double datum_params[7]; + struct _pj_gi **gridlist; + int gridlist_count; + + int has_geoid_vgrids; + struct _pj_gi **vgridlist_geoid; + int vgridlist_geoid_count; + double vto_meter, vfr_meter; + + double from_greenwich; /* prime meridian offset (in radians) */ + double long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/ + int is_long_wrap_set; + char axis[4]; + + /* New Datum Shift Grid Catalogs */ + char *catalog_name; + struct _PJ_GridCatalog *catalog; + + double datum_date; + + struct _pj_gi *last_before_grid; + PJ_Region last_before_region; + double last_before_date; + + struct _pj_gi *last_after_grid; + PJ_Region last_after_region; + double last_after_date; #ifdef PJ_LIB__ struct pj_opaque *opaque; @@ -342,16 +352,16 @@ extern struct PJ_PRIME_MERIDIANS pj_prime_meridians[]; #endif #ifdef PJ_LIB__ - /* repetitive projection code */ +/* repetitive projection code */ #define PROJ_HEAD(id, name) static const char des_##id [] = name #define ENTRYA(name) \ - C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \ - C_NAMESPACE PJ *pj_##name(PJ *P) { if (!P) { \ - if( (P = (PJ*) pj_malloc(sizeof(PJ))) != NULL) { \ + C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \ + C_NAMESPACE PJ *pj_##name(PJ *P) { if (!P) { \ + if( (P = (PJ*) pj_malloc(sizeof(PJ))) != NULL) { \ memset( P, 0, sizeof(PJ) ); \ - P->pfree = freeup; P->fwd = 0; P->inv = 0; \ + P->pfree = freeup; P->fwd = 0; P->inv = 0; \ P->fwd3d = 0; P->inv3d = 0; \ - P->spc = 0; P->descr = des_##name; + P->spc = 0; P->descr = des_##name; #define ENTRYX } return P; } else { #define ENTRY0(name) ENTRYA(name) ENTRYX #define ENTRY1(name, a) ENTRYA(name) P->a = 0; ENTRYX @@ -413,22 +423,22 @@ typedef struct { float lam, phi; } FLP; typedef struct { int lam, phi; } ILP; struct CTABLE { - char id[MAX_TAB_ID]; /* ascii info */ - LP ll; /* lower left corner coordinates */ - LP del; /* size of cells */ - ILP lim; /* limits of conversion matrix */ - FLP *cvs; /* conversion matrix */ + char id[MAX_TAB_ID]; /* ascii info */ + LP ll; /* lower left corner coordinates */ + LP del; /* size of cells */ + ILP lim; /* limits of conversion matrix */ + FLP *cvs; /* conversion matrix */ }; typedef struct _pj_gi { - char *gridname; /* identifying name of grid, eg "conus" or ntv2_0.gsb */ - char *filename; /* full path to filename */ + char *gridname; /* identifying name of grid, eg "conus" or ntv2_0.gsb */ + char *filename; /* full path to filename */ const char *format; /* format of this grid, ie "ctable", "ntv1", "ntv2" or "missing". */ - int grid_offset; /* offset in file, for delayed loading */ - int must_swap; /* only for NTv2 */ + int grid_offset; /* offset in file, for delayed loading */ + int must_swap; /* only for NTv2 */ struct CTABLE *ct; @@ -438,18 +448,18 @@ typedef struct _pj_gi { typedef struct { PJ_Region region; - int priority; /* higher used before lower */ - double date; /* year.fraction */ - char *definition; /* usually the gridname */ + int priority; /* higher used before lower */ + double date; /* year.fraction */ + char *definition; /* usually the gridname */ PJ_GRIDINFO *gridinfo; - int available; /* 0=unknown, 1=true, -1=false */ + int available; /* 0=unknown, 1=true, -1=false */ } PJ_GridCatalogEntry; typedef struct _PJ_GridCatalog { char *catalog_name; - PJ_Region region; /* maximum extent of catalog data */ + PJ_Region region; /* maximum extent of catalog data */ int entry_count; PJ_GridCatalogEntry *entries; @@ -493,18 +503,18 @@ COMPLEX pj_zpolyd1(COMPLEX, COMPLEX *, int, COMPLEX *); int pj_deriv(LP, double, PJ *, struct DERIVS *); int pj_factors(LP, PJ *, double, struct FACTORS *); -struct PW_COEF {/* row coefficient structure */ - int m; /* number of c coefficients (=0 for none) */ - double *c; /* power coefficients */ +struct PW_COEF { /* row coefficient structure */ + int m; /* number of c coefficients (=0 for none) */ + double *c; /* power coefficients */ }; /* Approximation structures and procedures */ -typedef struct { /* Chebyshev or Power series structure */ - projUV a, b; /* power series range for evaluation */ - /* or Chebyshev argument shift/scaling */ - struct PW_COEF *cu, *cv; - int mu, mv; /* maximum cu and cv index (+1 for count) */ - int power; /* != 0 if power series, else Chebyshev */ +typedef struct { /* Chebyshev or Power series structure */ + projUV a, b; /* power series range for evaluation */ + /* or Chebyshev argument shift/scaling */ + struct PW_COEF *cu, *cv; + int mu, mv; /* maximum cu and cv index (+1 for count) */ + int power; /* != 0 if power series, else Chebyshev */ } Tseries; Tseries *mk_cheby(projUV, projUV, double, projUV *, projUV (*)(projUV), int, int, int); projUV bpseval(projUV, Tseries *); |
