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