Statistics
| Revision:

svn-gvsig-desktop / tags / v1_10_0_Build_1260 / libraries / libjni-proj4 / include / projects.h @ 33778

History | View | Annotate | Download (13.5 KB)

1
/******************************************************************************
2
 * $Id: projects.h,v 1.21 2004/10/28 16:08:13 fwarmerdam Exp $
3
 *
4
 * Project:  PROJ.4
5
 * Purpose:  Primary (private) include file for PROJ.4 library.
6
 * Author:   Gerald Evenden
7
 *
8
 ******************************************************************************
9
 * Copyright (c) 2000, Frank Warmerdam
10
 *
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:
17
 *
18
 * The above copyright notice and this permission notice shall be included
19
 * in all copies or substantial portions of the Software.
20
 *
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
 ******************************************************************************
29
 *
30
 * $Log: projects.h,v $
31
 * Revision 1.21  2004/10/28 16:08:13  fwarmerdam
32
 * added pj_get_*_ref() accessors
33
 *
34
 * Revision 1.20  2004/10/20 17:04:29  fwarmerdam
35
 * added geos, sterea and supporting gauss code from libproj4
36
 *
37
 * Revision 1.19  2004/08/31 22:57:11  warmerda
38
 * Don't re-declare hypot() on win32 as it will conflict with math.h as per
39
 * http://bugzilla.remotesensing.org/show_bug.cgi?id=495
40
 *
41
 * Revision 1.18  2004/04/15 13:56:45  warmerda
42
 * changed PJD_ERR_GEOCENTRIC to -45
43
 *
44
 * Revision 1.17  2003/03/17 18:56:34  warmerda
45
 * implement heirarchical NTv2 gridinfos
46
 *
47
 * Revision 1.16  2003/03/15 06:02:02  warmerda
48
 * preliminary NTv2 support, major restructure of datum shifting
49
 *
50
 * Revision 1.15  2002/12/14 20:35:15  warmerda
51
 * fix C_NAMESPACE warning issue with C_NAMESPACE_VAR for variables
52
 *
53
 * Revision 1.14  2002/12/14 20:16:21  warmerda
54
 * added geocentric support, and PJ_CVSID
55
 *
56
 * Revision 1.13  2002/12/09 16:01:02  warmerda
57
 * added prime meridian support
58
 *
59
 * Revision 1.12  2002/07/08 02:32:05  warmerda
60
 * ensure clean C++ builds
61
 *
62
 * Revision 1.11  2002/06/20 16:09:31  warmerda
63
 * removed strtod, reimplement non-GPL strtod cover within dmstor.c
64
 *
65
 * Revision 1.10  2002/06/13 14:06:49  warmerda
66
 * Removed incorrect labelling of 3PARAM and 7PARAM as Molodensky.
67
 *
68
 * Revision 1.9  2001/04/06 01:24:13  warmerda
69
 * Introduced proj_api.h as a public interface for PROJ.4
70
 *
71
 * Revision 1.8  2001/04/05 04:24:10  warmerda
72
 * added prototypes for new functions, and PJ_VERSION
73
 *
74
 * Revision 1.7  2001/02/07 17:55:05  warmerda
75
 * Cleaned up various warnings when compiled with -Wall.
76
 *
77
 * Revision 1.6  2000/11/30 03:37:22  warmerda
78
 * use proj_strtod() in dmstor()
79
 *
80
 * Revision 1.5  2000/07/06 23:36:47  warmerda
81
 * added lots of datum related stuff
82
 *
83
 */
84

    
85
/* General projections header file */
86
#ifndef PROJECTS_H
87
#define PROJECTS_H
88

    
89
/* standard inclusions */
90
#include <math.h>
91
#include <stdio.h>
92
#include <stdlib.h>
93

    
94
#ifdef __cplusplus
95
#define C_NAMESPACE extern "C"
96
#define C_NAMESPACE_VAR extern "C"
97
extern "C" {
98
#else    
99
#define C_NAMESPACE extern
100
#define C_NAMESPACE_VAR
101
#endif
102

    
103
#ifndef NULL
104
#  define NULL        0
105
#endif
106

    
107
#ifndef FALSE
108
#  define FALSE        0
109
#endif
110

    
111
#ifndef TRUE
112
#  define TRUE        1
113
#endif
114

    
115
#ifndef MAX
116
#  define MIN(a,b)      ((a<b) ? a : b)
117
#  define MAX(a,b)      ((a>b) ? a : b)
118
#endif
119

    
120
#ifndef ABS
121
#  define ABS(x)        ((x<0) ? (-1*(x)) : x)
122
#endif
123

    
124
    /* maximum path/filename */
125
#ifndef MAX_PATH_FILENAME
126
#define MAX_PATH_FILENAME 1024
127
#endif
128
        /* prototype hypot for systems where absent */
129
#ifndef _WIN32
130
extern double hypot(double, double);
131
#endif
132

    
133
        /* some useful constants */
134
#define HALFPI                1.5707963267948966
135
#define FORTPI                0.78539816339744833
136
#define PI                3.14159265358979323846
137
#define TWOPI                6.2831853071795864769
138

    
139
/* environment parameter name */
140
#ifndef PROJ_LIB
141
#define PROJ_LIB "PROJ_LIB"
142
#endif
143
/* maximum tag id length for +init and default files */
144
#ifndef ID_TAG_MAX
145
#define ID_TAG_MAX 50
146
#endif
147

    
148
/* directory delimiter for DOS support */
149
#ifdef DOS
150
#define DIR_CHAR '\\'
151
#else
152
#define DIR_CHAR '/'
153
#endif
154

    
155
/* datum_type values */
156
#define PJD_UNKNOWN   0
157
#define PJD_3PARAM    1   
158
#define PJD_7PARAM    2   
159
#define PJD_GRIDSHIFT 3
160
#define PJD_WGS84     4   /* WGS84 (or anything considered equivelent) */
161

    
162
/* datum system errors */
163
#define PJD_ERR_GEOCENTRIC -45
164

    
165
#define USE_PROJUV 
166

    
167
typedef struct { double u, v; } projUV;
168
typedef struct { double r, i; }        COMPLEX;
169

    
170
#ifndef PJ_LIB__
171
#define XY projUV
172
#define LP projUV
173
#else
174
typedef struct { double x, y; }     XY;
175
typedef struct { double lam, phi; } LP;
176
#endif
177

    
178
typedef union { double  f; int  i; char *s; } PVALUE;
179
struct PJconsts;
180
    
181
struct PJ_LIST {
182
        char        *id;                /* projection keyword */
183
        struct PJconsts        *(*proj)(struct PJconsts*);/* projection entry point */
184
        char         * const *descr;        /* description text */
185
};
186
struct PJ_ELLPS {
187
        char        *id;        /* ellipse keyword name */
188
        char        *major;        /* a= value */
189
        char        *ell;        /* elliptical parameter */
190
        char        *name;        /* comments */
191
};
192
struct PJ_UNITS {
193
        char        *id;        /* units keyword */
194
        char        *to_meter;        /* multiply by value to get meters */
195
        char        *name;        /* comments */
196
};
197

    
198
struct PJ_DATUMS {
199
    char    *id;     /* datum keyword */
200
    char    *defn;   /* ie. "to_wgs84=..." */
201
    char    *ellipse_id; /* ie from ellipse table */
202
    char    *comments; /* EPSG code, etc */
203
};
204

    
205
struct PJ_PRIME_MERIDIANS {
206
    char    *id;     /* prime meridian keyword */
207
    char    *defn;   /* offset from greenwich in DMS format. */
208
};
209

    
210
struct DERIVS {
211
    double x_l, x_p; /* derivatives of x for lambda-phi */
212
    double y_l, y_p; /* derivatives of y for lambda-phi */
213
};
214
    
215
struct FACTORS {
216
        struct DERIVS der;
217
        double h, k;        /* meridinal, parallel scales */
218
        double omega, thetap;        /* angular distortion, theta prime */
219
        double conv;        /* convergence */
220
        double s;                /* areal scale factor */
221
        double a, b;        /* max-min scale error */
222
        int code;                /* info as to analytics, see following */
223
};
224
#define IS_ANAL_XL_YL 01        /* derivatives of lon analytic */
225
#define IS_ANAL_XP_YP 02        /* derivatives of lat analytic */
226
#define IS_ANAL_HK        04                /* h and k analytic */
227
#define IS_ANAL_CONV 010        /* convergence analytic */
228
    /* parameter list struct */
229
typedef struct ARG_list {
230
        struct ARG_list *next;
231
        char used;
232
        char param[1]; } paralist;
233
        /* base projection data structure */
234

    
235

    
236
typedef struct PJconsts {
237
        XY  (*fwd)(LP, struct PJconsts *);
238
        LP  (*inv)(XY, struct PJconsts *);
239
        void (*spc)(LP, struct PJconsts *, struct FACTORS *);
240
        void (*pfree)(struct PJconsts *);
241
        const char *descr;
242
        paralist *params;   /* parameter list */
243
        int over;   /* over-range flag */
244
        int geoc;   /* geocentric latitude flag */
245
        int is_latlong; /* proj=latlong ... not really a projection at all */
246
        int is_geocent; /* proj=geocent ... not really a projection at all */
247
        double
248
                a,  /* major axis or radius if es==0 */
249
                e,  /* eccentricity */
250
                es, /* e ^ 2 */
251
                ra, /* 1/A */
252
                one_es, /* 1 - e^2 */
253
                rone_es, /* 1/one_es */
254
                lam0, phi0, /* central longitude, latitude */
255
                x0, y0, /* easting and northing */
256
                k0,        /* general scaling factor */
257
                to_meter, fr_meter; /* cartesian scaling */
258

    
259
        int     datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
260
        double  datum_params[7];
261
        double  from_greenwich; /* prime meridian offset (in radians) */
262
        
263
#ifdef PROJ_PARMS__
264
PROJ_PARMS__
265
#endif /* end of optional extensions */
266
} PJ;
267

    
268
/* public API */
269
#include "proj_api.h"
270

    
271
/* Generate pj_list external or make list from include file */
272
#ifndef PJ_LIST_H
273
extern struct PJ_LIST pj_list[];
274
#else
275
#define PROJ_HEAD(id, name) \
276
    struct PJconsts *pj_##id(struct PJconsts*); extern char * const pj_s_##id;
277
    
278
#ifndef lint
279
#define DO_PJ_LIST_ID
280
#endif
281
#include PJ_LIST_H
282
#ifndef lint
283
#undef DO_PJ_LIST_ID
284
#endif
285
#undef PROJ_HEAD
286
#define PROJ_HEAD(id, name) {#id, pj_##id, &pj_s_##id},
287
        struct PJ_LIST
288
pj_list[] = {
289
#include PJ_LIST_H
290
                {0,     0,  0},
291
        };
292
#undef PROJ_HEAD
293
#endif
294

    
295
#ifndef PJ_ELLPS__
296
extern struct PJ_ELLPS pj_ellps[];
297
#endif
298

    
299
#ifndef PJ_UNITS__
300
extern struct PJ_UNITS pj_units[];
301
#endif
302

    
303
#ifndef PJ_DATUMS__
304
extern struct PJ_DATUMS pj_datums[];
305
extern struct PJ_PRIME_MERIDIANS pj_prime_meridians[];
306
#endif
307

    
308
#ifdef PJ_LIB__
309
    /* repeatative projection code */
310
#define PROJ_HEAD(id, name) static const char des_##id [] = name
311
#define ENTRYA(name) \
312
        C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \
313
        C_NAMESPACE PJ *pj_##name(PJ *P) { if (!P) { \
314
        if( (P = (PJ*) pj_malloc(sizeof(PJ))) != NULL) { \
315
        P->pfree = freeup; P->fwd = 0; P->inv = 0; \
316
        P->spc = 0; P->descr = des_##name;
317
#define ENTRYX } return P; } else {
318
#define ENTRY0(name) ENTRYA(name) ENTRYX
319
#define ENTRY1(name, a) ENTRYA(name) P->a = 0; ENTRYX
320
#define ENTRY2(name, a, b) ENTRYA(name) P->a = 0; P->b = 0; ENTRYX
321
#define ENDENTRY(p) } return (p); }
322
#define E_ERROR(err) { pj_errno = err; freeup(P); return(0); }
323
#define E_ERROR_0 { freeup(P); return(0); }
324
#define F_ERROR { pj_errno = -20; return(xy); }
325
#define I_ERROR { pj_errno = -20; return(lp); }
326
#define FORWARD(name) static XY name(LP lp, PJ *P) { XY xy = {0.0,0.0}
327
#define INVERSE(name) static LP name(XY xy, PJ *P) { LP lp = {0.0,0.0}
328
#define FREEUP static void freeup(PJ *P) {
329
#define SPECIAL(name) static void name(LP lp, PJ *P, struct FACTORS *fac)
330
#endif
331
#define MAX_TAB_ID 80
332
typedef struct { float lam, phi; } FLP;
333
typedef struct { int lam, phi; } ILP;
334

    
335
struct CTABLE {
336
        char id[MAX_TAB_ID]; /* ascii info */
337
        LP ll;      /* lower left corner coordinates */
338
        LP del;     /* size of cells */
339
        ILP lim;    /* limits of conversion matrix */
340
        FLP *cvs;   /* conversion matrix */
341
};
342

    
343
typedef struct _pj_gi {
344
    char *gridname;   /* identifying name of grid, eg "conus" or ntv2_0.gsb */
345
    char *filename;   /* full path to filename */
346
    
347
    const char *format; /* format of this grid, ie "ctable", "ntv1", 
348
                           "ntv2" or "missing". */
349

    
350
    int   grid_offset; /* offset in file, for delayed loading */
351

    
352
    struct CTABLE *ct;
353

    
354
    struct _pj_gi *next;
355
    struct _pj_gi *child;
356
} PJ_GRIDINFO;
357

    
358
/* procedure prototypes */
359
double dmstor(const char *, char **);
360
void set_rtodms(int, int);
361
char *rtodms(char *, double, int, int);
362
double adjlon(double);
363
double aacos(double), aasin(double), asqrt(double), aatan2(double, double);
364
PVALUE pj_param(paralist *, char *);
365
paralist *pj_mkparam(char *);
366
int pj_ell_set(paralist *, double *, double *);
367
int pj_datum_set(paralist *, PJ *);
368
int pj_prime_meridian_set(paralist *, PJ *);
369
int pj_angular_units_set(paralist *, PJ *);
370
double *pj_enfn(double);
371
double pj_mlfn(double, double, double, double *);
372
double pj_inv_mlfn(double, double, double *);
373
double pj_qsfn(double, double, double);
374
double pj_tsfn(double, double, double);
375
double pj_msfn(double, double, double);
376
double pj_phi2(double, double);
377
double pj_qsfn_(double, PJ *);
378
double *pj_authset(double);
379
double pj_authlat(double, double *);
380
COMPLEX pj_zpoly1(COMPLEX, COMPLEX *, int);
381
COMPLEX pj_zpolyd1(COMPLEX, COMPLEX *, int, COMPLEX *);
382
FILE *pj_open_lib(char *, char *);
383

    
384
int pj_deriv(LP, double, PJ *, struct DERIVS *);
385
int pj_factors(LP, PJ *, double, struct FACTORS *);
386

    
387
struct PW_COEF {/* row coefficient structure */
388
    int m;                /* number of c coefficients (=0 for none) */
389
    double *c;        /* power coefficients */
390
};
391
 
392
/* Approximation structures and procedures */
393
typedef struct {        /* Chebyshev or Power series structure */
394
        projUV a, b;                /* power series range for evaluation */
395
                                        /* or Chebyshev argument shift/scaling */
396
        struct PW_COEF *cu, *cv;
397
        int mu, mv;                /* maximum cu and cv index (+1 for count) */
398
        int power;                /* != 0 if power series, else Chebyshev */
399
} Tseries;
400
Tseries *mk_cheby(projUV, projUV, double, projUV *, projUV (*)(projUV), int, int, int);
401
projUV bpseval(projUV, Tseries *);
402
projUV bcheval(projUV, Tseries *);
403
projUV biveval(projUV, Tseries *);
404
void *vector1(int, int);
405
void **vector2(int, int, int);
406
void freev2(void **v, int nrows);
407
int bchgen(projUV, projUV, int, int, projUV **, projUV(*)(projUV));
408
int bch2bps(projUV, projUV, projUV **, int, int);
409
/* nadcon related protos */
410
LP nad_intr(LP, struct CTABLE *);
411
LP nad_cvt(LP, int, struct CTABLE *);
412
struct CTABLE *nad_init(char *);
413
struct CTABLE *nad_ctable_init( FILE * fid );
414
int nad_ctable_load( struct CTABLE *, FILE * fid );
415
void nad_free(struct CTABLE *);
416

    
417
/* higher level handling of datum grid shift files */
418

    
419
PJ_GRIDINFO **pj_gridlist_from_nadgrids( const char *, int * );
420
void pj_deallocate_grids();
421

    
422
PJ_GRIDINFO *pj_gridinfo_init( const char * );
423
int pj_gridinfo_load( PJ_GRIDINFO * );
424
void pj_gridinfo_free( PJ_GRIDINFO * );
425

    
426
void *pj_gauss_ini(double, double, double *,double *);
427
LP pj_gauss(LP, const void *);
428
LP pj_inv_gauss(LP, const void *);
429

    
430
extern char const pj_release[];
431

    
432
struct PJ_ELLPS *pj_get_ellps_ref( void );
433
struct PJ_DATUMS *pj_get_datums_ref( void );
434
struct PJ_UNITS *pj_get_units_ref( void );
435
struct PJ_LIST  *pj_get_list_ref( void );
436
struct PJ_PRIME_MERIDIANS  *pj_get_prime_meridians_ref( void );
437
 
438
#ifndef DISABLE_CVSID
439
#  define PJ_CVSID(string)     static char pj_cvsid[] = string; \
440
static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : pj_cvsid ); }
441
#else
442
#  define PJ_CVSID(string)
443
#endif
444

    
445
#ifdef __cplusplus
446
}
447
#endif
448

    
449
#endif /* end of basic projections header */