~ubuntu-branches/ubuntu/vivid/proj/vivid

« back to all changes in this revision

Viewing changes to src/projects.h

  • Committer: Bazaar Package Importer
  • Author(s): Peter S Galbraith
  • Date: 2002-01-11 10:27:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020111102712-ayi18r8y2eesv0y9
Tags: upstream-4.4.5
ImportĀ upstreamĀ versionĀ 4.4.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * $Id: projects.h,v 1.9 2001/04/06 01:24:13 warmerda 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.9  2001/04/06 01:24:13  warmerda
 
32
 * Introduced proj_api.h as a public interface for PROJ.4
 
33
 *
 
34
 * Revision 1.8  2001/04/05 04:24:10  warmerda
 
35
 * added prototypes for new functions, and PJ_VERSION
 
36
 *
 
37
 * Revision 1.7  2001/02/07 17:55:05  warmerda
 
38
 * Cleaned up various warnings when compiled with -Wall.
 
39
 *
 
40
 * Revision 1.6  2000/11/30 03:37:22  warmerda
 
41
 * use proj_strtod() in dmstor()
 
42
 *
 
43
 * Revision 1.5  2000/07/06 23:36:47  warmerda
 
44
 * added lots of datum related stuff
 
45
 *
 
46
 */
 
47
 
 
48
/* General projections header file */
 
49
#ifndef PROJECTS_H
 
50
#define PROJECTS_H
 
51
 
 
52
/* standard inclusions */
 
53
#include <math.h>
 
54
#include <stdio.h>
 
55
#include <stdlib.h>
 
56
 
 
57
#ifdef __cplusplus
 
58
extern "C" {
 
59
#endif
 
60
 
 
61
#ifndef NULL
 
62
#  define NULL  0
 
63
#endif
 
64
 
 
65
#ifndef FALSE
 
66
#  define FALSE 0
 
67
#endif
 
68
 
 
69
#ifndef TRUE
 
70
#  define TRUE  1
 
71
#endif
 
72
 
 
73
#ifndef MAX
 
74
#  define MIN(a,b)      ((a<b) ? a : b)
 
75
#  define MAX(a,b)      ((a>b) ? a : b)
 
76
#endif
 
77
 
 
78
#ifndef ABS
 
79
#  define ABS(x)        ((x<0) ? (-1*(x)) : x)
 
80
#endif
 
81
 
 
82
    /* maximum path/filename */
 
83
#ifndef MAX_PATH_FILENAME
 
84
#define MAX_PATH_FILENAME 1024
 
85
#endif
 
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
 
93
 
 
94
/* environment parameter name */
 
95
#ifndef PROJ_LIB
 
96
#define PROJ_LIB "PROJ_LIB"
 
97
#endif
 
98
/* maximum tag id length for +init and default files */
 
99
#ifndef ID_TAG_MAX
 
100
#define ID_TAG_MAX 50
 
101
#endif
 
102
 
 
103
/* directory delimiter for DOS support */
 
104
#ifdef DOS
 
105
#define DIR_CHAR '\\'
 
106
#else
 
107
#define DIR_CHAR '/'
 
108
#endif
 
109
 
 
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) */
 
116
 
 
117
/* datum system errors */
 
118
#define PJD_ERR_GEOCENTRIC 100
 
119
 
 
120
#define USE_PROJUV 
 
121
 
 
122
typedef struct { double u, v; } projUV;
 
123
typedef struct { double r, i; } COMPLEX;
 
124
 
 
125
#ifndef PJ_LIB__
 
126
#define XY projUV
 
127
#define LP projUV
 
128
#else
 
129
typedef struct { double x, y; }     XY;
 
130
typedef struct { double lam, phi; } LP;
 
131
#endif
 
132
 
 
133
typedef union { double  f; int  i; char *s; } PVALUE;
 
134
 
 
135
struct PJ_LIST {
 
136
        char    *id;            /* projection keyword */
 
137
        void    *(*proj)();     /* projection entry point */
 
138
        char    * const *descr; /* description text */
 
139
};
 
140
struct PJ_ELLPS {
 
141
        char    *id;    /* ellipse keyword name */
 
142
        char    *major; /* a= value */
 
143
        char    *ell;   /* elliptical parameter */
 
144
        char    *name;  /* comments */
 
145
};
 
146
struct PJ_UNITS {
 
147
        char    *id;    /* units keyword */
 
148
        char    *to_meter;      /* multiply by value to get meters */
 
149
        char    *name;  /* comments */
 
150
};
 
151
 
 
152
struct PJ_DATUMS {
 
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 */
 
157
};
 
158
 
 
159
struct FACTORS {
 
160
        struct DERIVS {
 
161
                double x_l, x_p; /* derivatives of x for lambda-phi */
 
162
                double y_l, y_p; /* derivatives of y for lambda-phi */
 
163
        } der;
 
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 */
 
170
};
 
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;
 
178
        char used;
 
179
        char param[1]; } paralist;
 
180
        /* base projection data structure */
 
181
 
 
182
 
 
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 *);
 
188
        const char *descr;
 
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 */
 
193
        double
 
194
                a,  /* major axis or radius if es==0 */
 
195
                e,  /* eccentricity */
 
196
                es, /* e ^ 2 */
 
197
                ra, /* 1/A */
 
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 */
 
204
 
 
205
        int     datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
 
206
        double  datum_params[7];
 
207
        
 
208
#ifdef PROJ_PARMS__
 
209
PROJ_PARMS__
 
210
#endif /* end of optional extensions */
 
211
} PJ;
 
212
 
 
213
/* public API */
 
214
#include "proj_api.h"
 
215
 
 
216
/* Generate pj_list external or make list from include file */
 
217
#ifndef PJ_LIST_H
 
218
extern struct PJ_LIST pj_list[];
 
219
#else
 
220
#define PROJ_HEAD(id, name) \
 
221
        extern void *pj_##id(); extern char * const pj_s_##id;
 
222
#ifndef lint
 
223
#define DO_PJ_LIST_ID
 
224
#endif
 
225
#include PJ_LIST_H
 
226
#ifndef lint
 
227
#undef DO_PJ_LIST_ID
 
228
#endif
 
229
#undef PROJ_HEAD
 
230
#define PROJ_HEAD(id, name) {#id, pj_##id, &pj_s_##id},
 
231
        struct PJ_LIST
 
232
pj_list[] = {
 
233
#include PJ_LIST_H
 
234
                {0,     0,  0},
 
235
        };
 
236
#undef PROJ_HEAD
 
237
#endif
 
238
 
 
239
#ifndef PJ_ELLPS__
 
240
extern struct PJ_ELLPS pj_ellps[];
 
241
#endif
 
242
 
 
243
#ifndef PJ_UNITS__
 
244
extern struct PJ_UNITS pj_units[];
 
245
#endif
 
246
 
 
247
#ifndef PJ_DATUMS__
 
248
extern struct PJ_DATUMS pj_datums[];
 
249
#endif
 
250
 
 
251
#ifdef PJ_LIB__
 
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)
 
272
#endif
 
273
#define MAX_TAB_ID 80
 
274
typedef struct { float lam, phi; } FLP;
 
275
typedef struct { int lam, phi; } ILP;
 
276
struct CTABLE {
 
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 */
 
282
};
 
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 *);
 
307
 
 
308
int pj_deriv(LP, double, PJ *, struct DERIVS *);
 
309
int pj_factors(LP, PJ *, double, struct FACTORS *);
 
310
 
 
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 */
 
318
        } *cu, *cv;
 
319
        int mu, mv;             /* maximum cu and cv index (+1 for count) */
 
320
        int power;              /* != 0 if power series, else Chebyshev */
 
321
} Tseries;
 
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[];
 
336
 
 
337
#ifdef __cplusplus
 
338
}
 
339
#endif
 
340
 
 
341
#endif /* end of basic projections header */