GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
gprojects.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * MODULE: gproj library
4  * AUTHOR(S): Original Author unknown, probably Soil Conservation Service
5  * Paul Kelly
6  * PURPOSE: Include file for GRASS modules that use the PROJ.4
7  * wrapper functions
8  * COPYRIGHT: (C) 2003 by the GRASS Development Team
9  *
10  * This program is free software under the GNU General Public
11  * License (>=v2). Read the file COPYING that comes with GRASS
12  * for details.
13  *
14  *****************************************************************************/
15 
16 #ifndef GRASS_GPROJECTS_H
17 #define GRASS_GPROJECTS_H
18 
19 #include <grass/config.h>
20 /* TODO: clean up support for PROJ 5+ */
21 #ifdef HAVE_PROJ_H
22 #include <proj.h>
23 #define RAD_TO_DEG 57.295779513082321
24 #define DEG_TO_RAD .017453292519943296
25 
26 /* adapted from gdal_version.h */
27 #ifndef PROJ_COMPUTE_VERSION
28 #define PROJ_COMPUTE_VERSION(maj, min, rev) \
29  ((maj) * 1000000 + (min) * 10000 + (rev) * 100)
30 #endif
31 
32 /* just in case PROJ introduces PROJ_VERSION_NUM in a future version */
33 #ifdef PROJ_VERSION_NUM
34 #undef PROJ_VERSION_NUM
35 #endif
36 #define PROJ_VERSION_NUM \
37  (PROJ_COMPUTE_VERSION(PROJ_VERSION_MAJOR, PROJ_VERSION_MINOR, \
38  PROJ_VERSION_PATCH))
39 
40 #ifndef PJ_WKT2_LATEST
41 /* update if new PROJ versions support new WKT2 standards */
42 #if PROJ_VERSION_NUM < 6030000
43 #define PJ_WKT2_LATEST PJ_WKT2_2018
44 #else
45 #define PJ_WKT2_LATEST PJ_WKT2_2019
46 #endif
47 #endif
48 
49 #else
50 #include <proj_api.h>
51 #define PJ_FWD 1
52 #define PJ_INV -1
53 /* PROJ_VERSION_MAJOR is not set in the old PROJ API */
54 #define PROJ_VERSION_MAJOR 4
55 #endif
56 #ifdef HAVE_OGR
57 #include <ogr_srs_api.h>
58 #if PROJ_VERSION_MAJOR >= 6 && GDAL_VERSION_MAJOR < 3
59 #error "PROJ 6+ requires GDAL 3+"
60 #endif
61 #endif
62 
63 /* Data Files */
64 #define ELLIPSOIDTABLE "/etc/proj/ellipse.table"
65 #define DATUMTABLE "/etc/proj/datum.table"
66 #define DATUMTRANSFORMTABLE "/etc/proj/datumtransform.table"
67 /* GRASS relative location of datum conversion lookup tables */
68 #define GRIDDIR "/etc/proj/nad"
69 
70 /* TODO: rename pj_ to gpj_ to avoid symbol clash with PROJ lib */
71 struct pj_info {
72 #ifdef HAVE_PROJ_H
73  PJ *pj;
74 #else
75  projPJ pj;
76 #endif
77  double meters;
78  int zone;
79  char proj[100];
80  char *def;
81  char *srid;
82  char *wkt;
83 };
84 
85 struct gpj_datum {
86  char *name, *longname, *ellps;
87  double dx, dy, dz;
88 };
89 
90 /* no longer needed with PROJ6+ */
92 
93  int count; /**< Transform Number (ordered list) */
94 
95  char *params; /**< PROJ.4-style datum transform parameters */
96 
97  char *where_used; /**< Comment text describing where (geographically)
98  * the transform is valid */
99 
100  char *comment; /**< Additional Comments */
101 
103  *next; /**< Pointer to next set of
104  * transform parameters in linked list */
105 };
106 
107 struct gpj_ellps {
108  char *name, *longname;
109  double a, es, rf;
110 };
111 
112 #ifndef HAVE_PROJ_H
113 /* PROJ.4's private datastructures copied from projects.h as removed
114  from upstream; pending better solution. see:
115  https://trac.osgeo.org/proj/ticket/98 */
116 
117 /* In PROJ 5, the 'struct FACTORS' is back in as 'struct P5_FACTORS',
118  * and old 'struct LP' is now back in as 'PJ_UV' */
119 
120 typedef struct {
121  double u, v;
122 } LP;
123 
124 struct DERIVS {
125  double x_l, x_p; /* derivatives of x for lambda-phi */
126  double y_l, y_p; /* derivatives of y for lambda-phi */
127 };
128 
129 struct FACTORS {
130  struct DERIVS der;
131  double h, k; /* meridinal, parallel scales */
132  double omega, thetap; /* angular distortion, theta prime */
133  double conv; /* convergence */
134  double s; /* areal scale factor */
135  double a, b; /* max-min scale error */
136  int code; /* info as to analytics, see following */
137 };
138 
139 /* end of copy */
140 #endif
141 
142 #include <grass/defs/gprojects.h>
143 
144 #endif
double b
Definition: r_raster.c:39
struct gpj_datum_transform_list * next
Definition: gprojects.h:102
double dz
Definition: gprojects.h:87
char * longname
Definition: gprojects.h:86
double dy
Definition: gprojects.h:87
char * ellps
Definition: gprojects.h:86
double dx
Definition: gprojects.h:87
char * name
Definition: gprojects.h:86
double es
Definition: gprojects.h:109
char * name
Definition: gprojects.h:108
double a
Definition: gprojects.h:109
double rf
Definition: gprojects.h:109
char * longname
Definition: gprojects.h:108
char proj[100]
Definition: gprojects.h:79
int zone
Definition: gprojects.h:78
char * def
Definition: gprojects.h:80
PJ * pj
Definition: gprojects.h:73
char * srid
Definition: gprojects.h:81
char * wkt
Definition: gprojects.h:82
double meters
Definition: gprojects.h:77