OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
gctp.h
Go to the documentation of this file.
1 #ifndef GCTP_H
2 #define GCTP_H
3 
4 /* Projection codes
5  0 = Geographic
6  1 = Universal Transverse Mercator (UTM)
7  2 = State Plane Coordinates
8  3 = Albers Conical Equal Area
9  4 = Lambert Conformal Conic
10  5 = Mercator
11  6 = Polar Stereographic
12  7 = Polyconic
13  8 = Equidistant Conic
14  9 = Transverse Mercator
15  10 = Stereographic
16  11 = Lambert Azimuthal Equal Area
17  12 = Azimuthal Equidistant
18  13 = Gnomonic
19  14 = Orthographic
20  15 = General Vertical Near-Side Perspective
21  16 = Sinusiodal
22  17 = Equirectangular
23  18 = Miller Cylindrical
24  19 = Van der Grinten
25  20 = (Hotine) Oblique Mercator
26  21 = Robinson
27  22 = Space Oblique Mercator (SOM)
28  23 = Alaska Conformal
29  24 = Interrupted Goode Homolosine
30  25 = Mollweide
31  26 = Interrupted Mollweide
32  27 = Hammer
33  28 = Wagner IV
34  29 = Wagner VII
35  30 = Oblated Equal Area
36  31 = Integerized Sinusiodal
37  99 = User defined
38 */
39 
40 /* Define projection codes */
41 #define GEO 0
42 #define UTM 1
43 #define SPCS 2
44 #define ALBERS 3
45 #define LAMCC 4
46 #define MERCAT 5
47 #define PS 6
48 #define POLYC 7
49 #define EQUIDC 8
50 #define TM 9
51 #define STEREO 10
52 #define LAMAZ 11
53 #define AZMEQD 12
54 #define GNOMON 13
55 #define ORTHO 14
56 #define GVNSP 15
57 #define SNSOID 16
58 #define EQRECT 17
59 #define MILLER 18
60 #define VGRINT 19
61 #define HOM 20
62 #define ROBIN 21
63 #define SOM 22
64 #define ALASKA 23
65 #define GOOD 24
66 #define MOLL 25
67 #define IMOLL 26
68 #define HAMMER 27
69 #define WAGIV 28
70 #define WAGVII 29
71 #define OBEQA 30
72 #define ISIN 31
73 #define USDEF 99
74 
75 #define MAXPROJ 31 /* largest supported projection number */
76 
77 /* Define the number of projection parameters */
78 #define GCTP_PROJECTION_PARAMETER_COUNT 15
79 
80 /* Define the return values for error and success */
81 #define GCTP_ERROR -1
82 #define GCTP_SUCCESS 0
83 
84 /* Define the return value for a coordinate that is in a "break" area of an
85  interrupted projection like Goode's */
86 #define GCTP_IN_BREAK -2
87 
88 /* Define the unit codes */
89 #define RADIAN 0
90 #define FEET 1
91 #define METER 2
92 #define SECOND 3
93 #define DEGREE 4
94 #define DMS 5
95 
96 /* Define a structure to hold the information that defines a projection */
97 typedef struct gctp_projection
98 {
99  int proj_code; /* Projection code */
100  int zone; /* Projection zone number - only has meaning for
101  projections like UTM and stateplane */
102  int units; /* Units of coordinates */
103  int spheroid; /* Spheroid code for the projection */
105  /* Array of projection parameters */
106 
107 } GCTP_PROJECTION;
108 
109 /* Forward declaration of the GCTP_TRANSFORMATION type. This is done to
110  prevent users of the library from seeing the details of what is stored in
111  the structure. */
112 typedef struct gctp_transformation GCTP_TRANSFORMATION;
113 
114 /* Routine to create a transformation between the input and output projections
115  provided. A pointer to the transformation is returned (NULL if an error
116  occurs). gctp_destroy_transformation should be called to clean up the
117  transformation when it is no longer needed. */
118 GCTP_TRANSFORMATION *gctp_create_transformation
119 (
120  const GCTP_PROJECTION *input_projection, /* I: starting projection */
121  const GCTP_PROJECTION *output_projection /* I: ending projection */
122 );
123 
124 /* Routine to free any resources allocated in the creation of the
125  transformation. */
127 (
128  GCTP_TRANSFORMATION *trans
129 );
130 
131 /* Routine to transform coordinates using a transformation set up by
132  gctp_create_transformation. */
133 int gctp_transform
134 (
135  const GCTP_TRANSFORMATION *trans, /* I: transformation to use */
136  const double *in_coor, /* I: array of (lon, lat) or (x, y) */
137  double * out_coor /* O: array of (x, y) or (lon, lat) */
138 );
139 
141 {
145 } GCTP_MESSAGE_TYPE_ENUM;
146 
147 /* Define the type for a callback print routine to allow the library user
148  to deal with output messages. */
149 typedef void (*GCTP_CALLBACK_PRINT_FUNC)
150 (
151  GCTP_MESSAGE_TYPE_ENUM message_type, /* I: message type */
152  const char *filename, /* I: source code file name for input */
153  int line_number, /* I: source code line number for input */
154  const char *format, ... /* I: format string for message */
155 );
157 
158 /* Routine to print information about the transformation (such as the input
159  and output projection parameters) */
161 (
162  const GCTP_TRANSFORMATION *trans
163 );
164 
165 /* Routine to return the input projection defined in a transformation */
166 const GCTP_PROJECTION *gctp_get_input_proj
167 (
168  const GCTP_TRANSFORMATION *trans
169 );
170 
171 /* Routine to return the output projection defined in a transformation */
172 const GCTP_PROJECTION *gctp_get_output_proj
173 (
174  const GCTP_TRANSFORMATION *trans
175 );
176 
178 (
179  double lon /* I: longitude (in degrees) */
180 );
181 
183 
184 void gctp(const double *,const long *,const long *,const double *,long *, const long *,double *,
185  const long *, const long *, const double *, long *, const long *, long *);
186 
187 #endif
void gctp_set_message_callback(GCTP_CALLBACK_PRINT_FUNC callback)
@ GCTP_MESSAGE_TYPE_COUNT
Definition: gctp.h:144
@ GCTP_INFO_MESSAGE
Definition: gctp.h:142
void gctp(const double *, const long *, const long *, const double *, long *, const long *, double *, const long *, const long *, const double *, long *, const long *, long *)
Definition: gctp.c:36
const GCTP_PROJECTION * gctp_get_output_proj(const GCTP_TRANSFORMATION *trans)
Definition: gctp_utility.c:68
int proj_code
Definition: gctp.h:99
void gctp_only_allow_threadsafe_transforms()
const GCTP_PROJECTION * gctp_get_input_proj(const GCTP_TRANSFORMATION *trans)
Definition: gctp_utility.c:51
void gctp_destroy_transformation(GCTP_TRANSFORMATION *trans)
void gctp_print_transformation_info(const GCTP_TRANSFORMATION *trans)
Definition: gctp_utility.c:25
int spheroid
Definition: gctp.h:103
int gctp_calc_utm_zone(double lon)
Definition: gctp_utility.c:85
char filename[FILENAME_MAX]
Definition: atrem_corl1.h:122
void(* GCTP_CALLBACK_PRINT_FUNC)(GCTP_MESSAGE_TYPE_ENUM message_type, const char *filename, int line_number, const char *format,...)
Definition: gctp.h:150
#define GCTP_PROJECTION_PARAMETER_COUNT
Definition: gctp.h:78
GCTP_TRANSFORMATION * gctp_create_transformation(const GCTP_PROJECTION *input_projection, const GCTP_PROJECTION *output_projection)
int gctp_transform(const GCTP_TRANSFORMATION *trans, const double *in_coor, double *out_coor)
double parameters[GCTP_PROJECTION_PARAMETER_COUNT]
Definition: gctp.h:104
@ GCTP_ERROR_MESSAGE
Definition: gctp.h:143
float * lon
gctp_message_type_enum
Definition: gctp.h:140