1
/******************************************************************************
2
* $Id: projects.h,v 1.9 2001/04/06 01:24:13 warmerda Exp $
5
* Purpose: Primary (private) include file for PROJ.4 library.
6
* Author: Gerald Evenden
8
******************************************************************************
9
* Copyright (c) 2000, Frank Warmerdam
11
* Permission is hereby granted, free of charge, to any person obtaining a
12
* copy of this software and associated documentation files (the "Software"),
13
* to deal in the Software without restriction, including without limitation
14
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
15
* and/or sell copies of the Software, and to permit persons to whom the
16
* Software is furnished to do so, subject to the following conditions:
18
* The above copyright notice and this permission notice shall be included
19
* in all copies or substantial portions of the Software.
21
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
* DEALINGS IN THE SOFTWARE.
28
******************************************************************************
30
* $Log: projects.h,v $
31
* Revision 1.9 2001/04/06 01:24:13 warmerda
32
* Introduced proj_api.h as a public interface for PROJ.4
34
* Revision 1.8 2001/04/05 04:24:10 warmerda
35
* added prototypes for new functions, and PJ_VERSION
37
* Revision 1.7 2001/02/07 17:55:05 warmerda
38
* Cleaned up various warnings when compiled with -Wall.
40
* Revision 1.6 2000/11/30 03:37:22 warmerda
41
* use proj_strtod() in dmstor()
43
* Revision 1.5 2000/07/06 23:36:47 warmerda
44
* added lots of datum related stuff
48
/* General projections header file */
52
/* standard inclusions */
74
# define MIN(a,b) ((a<b) ? a : b)
75
# define MAX(a,b) ((a>b) ? a : b)
79
# define ABS(x) ((x<0) ? (-1*(x)) : x)
82
/* maximum path/filename */
83
#ifndef MAX_PATH_FILENAME
84
#define MAX_PATH_FILENAME 1024
86
/* prototype hypot for systems where absent */
87
extern double hypot(double, double);
88
/* some useful constants */
89
#define HALFPI 1.5707963267948966
90
#define FORTPI 0.78539816339744833
91
#define PI 3.14159265358979323846
92
#define TWOPI 6.2831853071795864769
94
/* environment parameter name */
96
#define PROJ_LIB "PROJ_LIB"
98
/* maximum tag id length for +init and default files */
100
#define ID_TAG_MAX 50
103
/* directory delimiter for DOS support */
105
#define DIR_CHAR '\\'
110
/* datum_type values */
111
#define PJD_UNKNOWN 0
112
#define PJD_3PARAM 1 /* Molodensky */
113
#define PJD_7PARAM 2 /* Molodensky */
114
#define PJD_GRIDSHIFT 3
115
#define PJD_WGS84 4 /* WGS84 (or anything considered equivelent) */
117
/* datum system errors */
118
#define PJD_ERR_GEOCENTRIC 100
122
typedef struct { double u, v; } projUV;
123
typedef struct { double r, i; } COMPLEX;
129
typedef struct { double x, y; } XY;
130
typedef struct { double lam, phi; } LP;
133
typedef union { double f; int i; char *s; } PVALUE;
136
char *id; /* projection keyword */
137
void *(*proj)(); /* projection entry point */
138
char * const *descr; /* description text */
141
char *id; /* ellipse keyword name */
142
char *major; /* a= value */
143
char *ell; /* elliptical parameter */
144
char *name; /* comments */
147
char *id; /* units keyword */
148
char *to_meter; /* multiply by value to get meters */
149
char *name; /* comments */
153
char *id; /* datum keyword */
154
char *defn; /* ie. "to_wgs84=..." */
155
char *ellipse_id; /* ie from ellipse table */
156
char *comments; /* EPSG code, etc */
161
double x_l, x_p; /* derivatives of x for lambda-phi */
162
double y_l, y_p; /* derivatives of y for lambda-phi */
164
double h, k; /* meridinal, parallel scales */
165
double omega, thetap; /* angular distortion, theta prime */
166
double conv; /* convergence */
167
double s; /* areal scale factor */
168
double a, b; /* max-min scale error */
169
int code; /* info as to analytics, see following */
171
#define IS_ANAL_XL_YL 01 /* derivatives of lon analytic */
172
#define IS_ANAL_XP_YP 02 /* derivatives of lat analytic */
173
#define IS_ANAL_HK 04 /* h and k analytic */
174
#define IS_ANAL_CONV 010 /* convergence analytic */
175
/* parameter list struct */
176
typedef struct ARG_list {
177
struct ARG_list *next;
179
char param[1]; } paralist;
180
/* base projection data structure */
183
typedef struct PJconsts {
184
XY (*fwd)(LP, struct PJconsts *);
185
LP (*inv)(XY, struct PJconsts *);
186
void (*spc)(LP, struct PJconsts *, struct FACTORS *);
187
void (*pfree)(struct PJconsts *);
189
paralist *params; /* parameter list */
190
int over; /* over-range flag */
191
int geoc; /* geocentric latitude flag */
192
int is_latlong; /* proj=latlong ... not really a projection at all */
194
a, /* major axis or radius if es==0 */
195
e, /* eccentricity */
198
one_es, /* 1 - e^2 */
199
rone_es, /* 1/one_es */
200
lam0, phi0, /* central longitude, latitude */
201
x0, y0, /* easting and northing */
202
k0, /* general scaling factor */
203
to_meter, fr_meter; /* cartesian scaling */
205
int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
206
double datum_params[7];
210
#endif /* end of optional extensions */
214
#include "proj_api.h"
216
/* Generate pj_list external or make list from include file */
218
extern struct PJ_LIST pj_list[];
220
#define PROJ_HEAD(id, name) \
221
extern void *pj_##id(); extern char * const pj_s_##id;
223
#define DO_PJ_LIST_ID
230
#define PROJ_HEAD(id, name) {#id, pj_##id, &pj_s_##id},
240
extern struct PJ_ELLPS pj_ellps[];
244
extern struct PJ_UNITS pj_units[];
248
extern struct PJ_DATUMS pj_datums[];
252
/* repeatative projection code */
253
#define PROJ_HEAD(id, name) static const char des_##id [] = name
254
#define ENTRYA(name) const char * const pj_s_##name = des_##name; \
255
PJ *pj_##name(PJ *P) { if (!P) { \
256
if( (P = pj_malloc(sizeof(PJ))) != NULL) { \
257
P->pfree = freeup; P->fwd = 0; P->inv = 0; \
258
P->spc = 0; P->descr = des_##name;
259
#define ENTRYX } return P; } else {
260
#define ENTRY0(name) ENTRYA(name) ENTRYX
261
#define ENTRY1(name, a) ENTRYA(name) P->a = 0; ENTRYX
262
#define ENTRY2(name, a, b) ENTRYA(name) P->a = 0; P->b = 0; ENTRYX
263
#define ENDENTRY(p) } return (p); }
264
#define E_ERROR(err) { pj_errno = err; freeup(P); return(0); }
265
#define E_ERROR_0 { freeup(P); return(0); }
266
#define F_ERROR { pj_errno = -20; return(xy); }
267
#define I_ERROR { pj_errno = -20; return(lp); }
268
#define FORWARD(name) static XY name(LP lp, PJ *P) { XY xy
269
#define INVERSE(name) static LP name(XY xy, PJ *P) { LP lp
270
#define FREEUP static void freeup(PJ *P) {
271
#define SPECIAL(name) static void name(LP lp, PJ *P, struct FACTORS *fac)
273
#define MAX_TAB_ID 80
274
typedef struct { float lam, phi; } FLP;
275
typedef struct { int lam, phi; } ILP;
277
char id[MAX_TAB_ID]; /* ascii info */
278
LP ll; /* lower left corner coordinates */
279
LP del; /* size of cells */
280
ILP lim; /* limits of conversion matrix */
281
FLP *cvs; /* conversion matrix */
283
/* procedure prototypes */
284
double dmstor(const char *, char **);
285
double proj_strtod( const char *, char ** );
286
void set_rtodms(int, int);
287
char *rtodms(char *, double, int, int);
288
double adjlon(double);
289
double aacos(double), aasin(double), asqrt(double), aatan2(double, double);
290
PVALUE pj_param(paralist *, char *);
291
paralist *pj_mkparam(char *);
292
int pj_ell_set(paralist *, double *, double *);
293
int pj_datum_set(paralist *, PJ *);
294
double *pj_enfn(double);
295
double pj_mlfn(double, double, double, double *);
296
double pj_inv_mlfn(double, double, double *);
297
double pj_qsfn(double, double, double);
298
double pj_tsfn(double, double, double);
299
double pj_msfn(double, double, double);
300
double pj_phi2(double, double);
301
double pj_qsfn_(double, PJ *);
302
double *pj_authset(double);
303
double pj_authlat(double, double *);
304
COMPLEX pj_zpoly1(COMPLEX, COMPLEX *, int);
305
COMPLEX pj_zpolyd1(COMPLEX, COMPLEX *, int, COMPLEX *);
306
FILE *pj_open_lib(char *, char *);
308
int pj_deriv(LP, double, PJ *, struct DERIVS *);
309
int pj_factors(LP, PJ *, double, struct FACTORS *);
311
/* Approximation structures and procedures */
312
typedef struct { /* Chebyshev or Power series structure */
313
projUV a, b; /* power series range for evaluation */
314
/* or Chebyshev argument shift/scaling */
315
struct PW_COEF {/* row coefficient structure */
316
int m; /* number of c coefficients (=0 for none) */
317
double *c; /* power coefficients */
319
int mu, mv; /* maximum cu and cv index (+1 for count) */
320
int power; /* != 0 if power series, else Chebyshev */
322
Tseries *mk_cheby(projUV, projUV, double, projUV *, projUV (*)(projUV), int, int, int);
323
projUV bpseval(projUV, Tseries *);
324
projUV bcheval(projUV, Tseries *);
325
projUV biveval(projUV, Tseries *);
326
void *vector1(int, int);
327
void **vector2(int, int, int);
328
int bchgen(projUV, projUV, int, int, projUV **, projUV(*)(projUV));
329
int bch2bps(projUV, projUV, projUV **, int, int);
330
/* nadcon related protos */
331
LP nad_intr(LP, struct CTABLE *);
332
LP nad_cvt(LP, int, struct CTABLE *);
333
struct CTABLE *nad_init(char *);
334
void nad_free(struct CTABLE *);
335
extern char const pj_release[];
341
#endif /* end of basic projections header */