MobilityDB 1.3
Loading...
Searching...
No Matches
postgis_ext_defs.in.h
Go to the documentation of this file.
1#ifndef _LIBLWGEOM_H
2#define _LIBLWGEOM_H
3
4/******************************************************************/
5
12#define LWFLAG_Z 0x01
13#define LWFLAG_M 0x02
14#define LWFLAG_BBOX 0x04
15#define LWFLAG_GEODETIC 0x08
16#define LWFLAG_READONLY 0x10
17#define LWFLAG_SOLID 0x20
18
19#define FLAGS_GET_Z(flags) ((flags) & LWFLAG_Z)
20#define FLAGS_GET_M(flags) (((flags) & LWFLAG_M)>>1)
21#define FLAGS_GET_BBOX(flags) (((flags) & LWFLAG_BBOX)>>2)
22#define FLAGS_GET_GEODETIC(flags) (((flags) & LWFLAG_GEODETIC)>>3)
23#define FLAGS_GET_READONLY(flags) (((flags) & LWFLAG_READONLY)>>4)
24#define FLAGS_GET_SOLID(flags) (((flags) & LWFLAG_SOLID)>>5)
25
26#define FLAGS_SET_Z(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_Z) : ((flags) & ~LWFLAG_Z))
27#define FLAGS_SET_M(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_M) : ((flags) & ~LWFLAG_M))
28#define FLAGS_SET_BBOX(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_BBOX) : ((flags) & ~LWFLAG_BBOX))
29#define FLAGS_SET_GEODETIC(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_GEODETIC) : ((flags) & ~LWFLAG_GEODETIC))
30#define FLAGS_SET_READONLY(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_READONLY) : ((flags) & ~LWFLAG_READONLY))
31#define FLAGS_SET_SOLID(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_SOLID) : ((flags) & ~LWFLAG_SOLID))
32
33#define FLAGS_NDIMS(flags) (2 + FLAGS_GET_Z(flags) + FLAGS_GET_M(flags))
34#define FLAGS_GET_ZM(flags) (FLAGS_GET_M(flags) + FLAGS_GET_Z(flags) * 2)
35#define FLAGS_NDIMS_BOX(flags) (FLAGS_GET_GEODETIC(flags) ? 3 : FLAGS_NDIMS(flags))
36
37/*
38** Variants available for WKB and WKT output types
39*/
40
41#define WKB_ISO 0x01
42#define WKB_SFSQL 0x02
43#define WKB_EXTENDED 0x04
44#define WKB_NDR 0x08
45#define WKB_XDR 0x10
46#define WKB_HEX 0x20
47#define WKB_NO_NPOINTS 0x40 /* Internal use only */
48#define WKB_NO_SRID 0x80 /* Internal use only */
49
50#define WKT_ISO 0x01
51#define WKT_SFSQL 0x02
52#define WKT_EXTENDED 0x04
53
54typedef uint16_t lwflags_t;
55
56/******************************************************************/
57
58typedef struct {
59 double afac, bfac, cfac, dfac, efac, ffac, gfac, hfac, ifac, xoff, yoff, zoff;
60} AFFINE;
61
62/******************************************************************/
63
64typedef struct
65{
66 double xmin, ymin, zmin;
67 double xmax, ymax, zmax;
68 int32_t srid;
69}
70BOX3D;
71
72/******************************************************************
73* GBOX structure.
74* We include the flags (information about dimensionality),
75* so we don't have to constantly pass them
76* into functions that use the GBOX.
77*/
78typedef struct
79{
81 double xmin;
82 double xmax;
83 double ymin;
84 double ymax;
85 double zmin;
86 double zmax;
87 double mmin;
88 double mmax;
89} GBOX;
90
91
92/******************************************************************
93* SPHEROID
94*
95* Standard definition of an ellipsoid (what wkt calls a spheroid)
96* f = (a-b)/a
97* e_sq = (a*a - b*b)/(a*a)
98* b = a - fa
99*/
100typedef struct
101{
102 double a; /* semimajor axis */
103 double b; /* semiminor axis b = (a - fa) */
104 double f; /* flattening f = (a-b)/a */
105 double e; /* eccentricity (first) */
106 double e_sq; /* eccentricity squared (first) e_sq = (a*a-b*b)/(a*a) */
107 double radius; /* spherical average radius = (2*a+b)/3 */
108 char name[20]; /* name of ellipse */
109}
111
112/******************************************************************
113* POINT2D, POINT3D, POINT3DM, POINT4D
114*/
115typedef struct
116{
117 double x, y;
118}
119POINT2D;
120
121typedef struct
122{
123 double x, y, z;
124}
126
127typedef struct
128{
129 double x, y, z;
130}
131POINT3D;
132
133typedef struct
134{
135 double x, y, m;
136}
138
139typedef struct
140{
141 double x, y, z, m;
142}
143POINT4D;
144
145/******************************************************************
146* POINTARRAY
147* Point array abstracts a lot of the complexity of points and point lists.
148* It handles 2d/3d translation
149* (2d points converted to 3d will have z=0 or NaN)
150* DO NOT MIX 2D and 3D POINTS! EVERYTHING* is either one or the other
151*/
152typedef struct
153{
154 uint32_t npoints; /* how many points we are currently storing */
155 uint32_t maxpoints; /* how many points we have space for in serialized_pointlist */
156
157 /* Use FLAGS_* macros to handle */
159
160 /* Array of POINT 2D, 3D or 4D, possibly misaligned. */
162}
164
165/******************************************************************
166* GSERIALIZED
167*/
168
169typedef struct
170{
171 uint32_t size; /* For PgSQL use only, use VAR* macros to manipulate. */
172 uint8_t srid[3]; /* 24 bits of SRID */
173 uint8_t gflags; /* HasZ, HasM, HasBBox, IsGeodetic */
174 uint8_t data[1]; /* See gserialized.txt */
176
177/******************************************************************
178* LWGEOM (any geometry type)
179*
180* Abstract type, note that 'type', 'bbox' and 'srid' are available in
181* all geometry variants.
182*/
183typedef struct
184{
186 void *data;
187 int32_t srid;
189 uint8_t type;
190 char pad[1]; /* Padding to 24 bytes (unused) */
191}
192LWGEOM;
193
194/* POINTYPE */
195typedef struct
196{
198 POINTARRAY *point; /* hide 2d/3d (this will be an array of 1 point) */
199 int32_t srid;
201 uint8_t type; /* POINTTYPE */
202 char pad[1]; /* Padding to 24 bytes (unused) */
203}
204LWPOINT; /* "light-weight point" */
205
206/* LINETYPE */
207typedef struct
208{
210 POINTARRAY *points; /* array of POINT3D */
211 int32_t srid;
213 uint8_t type; /* LINETYPE */
214 char pad[1]; /* Padding to 24 bytes (unused) */
215}
216LWLINE; /* "light-weight line" */
217
218/* TRIANGLE */
219typedef struct
220{
223 int32_t srid;
225 uint8_t type;
226 char pad[1]; /* Padding to 24 bytes (unused) */
227}
229
230/* CIRCSTRINGTYPE */
231typedef struct
232{
234 POINTARRAY *points; /* array of POINT(3D/3DM) */
235 int32_t srid;
237 uint8_t type; /* CIRCSTRINGTYPE */
238 char pad[1]; /* Padding to 24 bytes (unused) */
239}
240LWCIRCSTRING; /* "light-weight circularstring" */
241
242/* POLYGONTYPE */
243typedef struct
244{
246 POINTARRAY **rings; /* list of rings (list of points) */
247 int32_t srid;
249 uint8_t type; /* POLYGONTYPE */
250 char pad[1]; /* Padding to 24 bytes (unused) */
251 uint32_t nrings; /* how many rings we are currently storing */
252 uint32_t maxrings; /* how many rings we have space for in **rings */
253}
254LWPOLY; /* "light-weight polygon" */
255
256/* MULTIPOINTTYPE */
257typedef struct
258{
261 int32_t srid;
263 uint8_t type; /* MULTYPOINTTYPE */
264 char pad[1]; /* Padding to 24 bytes (unused) */
265 uint32_t ngeoms; /* how many geometries we are currently storing */
266 uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
267}
269
270/* MULTILINETYPE */
271typedef struct
272{
275 int32_t srid;
277 uint8_t type; /* MULTILINETYPE */
278 char pad[1]; /* Padding to 24 bytes (unused) */
279 uint32_t ngeoms; /* how many geometries we are currently storing */
280 uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
281}
282LWMLINE;
283
284/* MULTIPOLYGONTYPE */
285typedef struct
286{
289 int32_t srid;
291 uint8_t type; /* MULTIPOLYGONTYPE */
292 char pad[1]; /* Padding to 24 bytes (unused) */
293 uint32_t ngeoms; /* how many geometries we are currently storing */
294 uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
295}
296LWMPOLY;
297
298/* COLLECTIONTYPE */
299typedef struct
300{
303 int32_t srid;
305 uint8_t type; /* COLLECTIONTYPE */
306 char pad[1]; /* Padding to 24 bytes (unused) */
307 uint32_t ngeoms; /* how many geometries we are currently storing */
308 uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
309}
311
312/* COMPOUNDTYPE */
313typedef struct
314{
317 int32_t srid;
319 uint8_t type; /* COLLECTIONTYPE */
320 char pad[1]; /* Padding to 24 bytes (unused) */
321 uint32_t ngeoms; /* how many geometries we are currently storing */
322 uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
323}
324LWCOMPOUND; /* "light-weight compound line" */
325
326/* CURVEPOLYTYPE */
327typedef struct
328{
331 int32_t srid;
333 uint8_t type; /* CURVEPOLYTYPE */
334 char pad[1]; /* Padding to 24 bytes (unused) */
335 uint32_t nrings; /* how many rings we are currently storing */
336 uint32_t maxrings; /* how many rings we have space for in **rings */
337}
338LWCURVEPOLY; /* "light-weight polygon" */
339
340/* MULTICURVE */
341typedef struct
342{
345 int32_t srid;
347 uint8_t type; /* MULTICURVE */
348 char pad[1]; /* Padding to 24 bytes (unused) */
349 uint32_t ngeoms; /* how many geometries we are currently storing */
350 uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
351}
353
354/* MULTISURFACETYPE */
355typedef struct
356{
359 int32_t srid;
361 uint8_t type; /* MULTISURFACETYPE */
362 char pad[1]; /* Padding to 24 bytes (unused) */
363 uint32_t ngeoms; /* how many geometries we are currently storing */
364 uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
365}
367
368/* POLYHEDRALSURFACETYPE */
369typedef struct
370{
373 int32_t srid;
375 uint8_t type; /* POLYHEDRALSURFACETYPE */
376 char pad[1]; /* Padding to 24 bytes (unused) */
377 uint32_t ngeoms; /* how many geometries we are currently storing */
378 uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
379}
381
382/* TINTYPE */
383typedef struct
384{
387 int32_t srid;
389 uint8_t type; /* TINTYPE */
390 char pad[1]; /* Padding to 24 bytes (unused) */
391 uint32_t ngeoms; /* how many geometries we are currently storing */
392 uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
393}
394LWTIN;
395
396/* Functions */
397
399
400/* PROJ */
401
402struct PJconsts;
403typedef struct PJconsts PJ;
404
405typedef struct LWPROJ
406{
408
409 /* for pipeline transforms, whether to do a forward or inverse */
411
412 /* Source crs is geographic: Used in geography calls (source srid == dst srid) */
414 /* Source ellipsoid parameters */
418
419
420#endif /* _LIBLWGEOM_H */
uint16_t lwflags_t
Definition: postgis_ext_defs.in.h:54
int32 geo_get_srid(const GSERIALIZED *g)
struct PJconsts PJ
Definition: postgis_ext_defs.in.h:403
signed int int32
Definition: postgres_ext_defs.in.h:11
double afac
Definition: postgis_ext_defs.in.h:59
Definition: postgis_ext_defs.in.h:58
double xmax
Definition: postgis_ext_defs.in.h:67
double xmin
Definition: postgis_ext_defs.in.h:66
int32_t srid
Definition: postgis_ext_defs.in.h:68
Definition: postgis_ext_defs.in.h:65
double ymax
Definition: postgis_ext_defs.in.h:84
double zmax
Definition: postgis_ext_defs.in.h:86
double xmax
Definition: postgis_ext_defs.in.h:82
double zmin
Definition: postgis_ext_defs.in.h:85
double mmax
Definition: postgis_ext_defs.in.h:88
double ymin
Definition: postgis_ext_defs.in.h:83
double xmin
Definition: postgis_ext_defs.in.h:81
double mmin
Definition: postgis_ext_defs.in.h:87
lwflags_t flags
Definition: postgis_ext_defs.in.h:80
Definition: postgis_ext_defs.in.h:79
uint32_t size
Definition: postgis_ext_defs.in.h:171
uint8_t gflags
Definition: postgis_ext_defs.in.h:173
Definition: postgis_ext_defs.in.h:170
uint8_t type
Definition: postgis_ext_defs.in.h:237
int32_t srid
Definition: postgis_ext_defs.in.h:235
lwflags_t flags
Definition: postgis_ext_defs.in.h:236
POINTARRAY * points
Definition: postgis_ext_defs.in.h:234
GBOX * bbox
Definition: postgis_ext_defs.in.h:233
Definition: postgis_ext_defs.in.h:232
lwflags_t flags
Definition: postgis_ext_defs.in.h:304
uint32_t ngeoms
Definition: postgis_ext_defs.in.h:307
uint32_t maxgeoms
Definition: postgis_ext_defs.in.h:308
uint8_t type
Definition: postgis_ext_defs.in.h:305
GBOX * bbox
Definition: postgis_ext_defs.in.h:301
LWGEOM ** geoms
Definition: postgis_ext_defs.in.h:302
int32_t srid
Definition: postgis_ext_defs.in.h:303
Definition: postgis_ext_defs.in.h:300
uint32_t maxgeoms
Definition: postgis_ext_defs.in.h:322
lwflags_t flags
Definition: postgis_ext_defs.in.h:318
int32_t srid
Definition: postgis_ext_defs.in.h:317
GBOX * bbox
Definition: postgis_ext_defs.in.h:315
uint32_t ngeoms
Definition: postgis_ext_defs.in.h:321
uint8_t type
Definition: postgis_ext_defs.in.h:319
LWGEOM ** geoms
Definition: postgis_ext_defs.in.h:316
Definition: postgis_ext_defs.in.h:314
int32_t srid
Definition: postgis_ext_defs.in.h:331
GBOX * bbox
Definition: postgis_ext_defs.in.h:329
uint8_t type
Definition: postgis_ext_defs.in.h:333
LWGEOM ** rings
Definition: postgis_ext_defs.in.h:330
lwflags_t flags
Definition: postgis_ext_defs.in.h:332
uint32_t nrings
Definition: postgis_ext_defs.in.h:335
uint32_t maxrings
Definition: postgis_ext_defs.in.h:336
Definition: postgis_ext_defs.in.h:328
void * data
Definition: postgis_ext_defs.in.h:186
uint8_t type
Definition: postgis_ext_defs.in.h:189
GBOX * bbox
Definition: postgis_ext_defs.in.h:185
int32_t srid
Definition: postgis_ext_defs.in.h:187
lwflags_t flags
Definition: postgis_ext_defs.in.h:188
Definition: postgis_ext_defs.in.h:184
lwflags_t flags
Definition: postgis_ext_defs.in.h:212
GBOX * bbox
Definition: postgis_ext_defs.in.h:209
POINTARRAY * points
Definition: postgis_ext_defs.in.h:210
uint8_t type
Definition: postgis_ext_defs.in.h:213
int32_t srid
Definition: postgis_ext_defs.in.h:211
Definition: postgis_ext_defs.in.h:208
uint32_t maxgeoms
Definition: postgis_ext_defs.in.h:350
LWGEOM ** geoms
Definition: postgis_ext_defs.in.h:344
GBOX * bbox
Definition: postgis_ext_defs.in.h:343
lwflags_t flags
Definition: postgis_ext_defs.in.h:346
uint32_t ngeoms
Definition: postgis_ext_defs.in.h:349
int32_t srid
Definition: postgis_ext_defs.in.h:345
uint8_t type
Definition: postgis_ext_defs.in.h:347
Definition: postgis_ext_defs.in.h:342
uint32_t maxgeoms
Definition: postgis_ext_defs.in.h:280
lwflags_t flags
Definition: postgis_ext_defs.in.h:276
GBOX * bbox
Definition: postgis_ext_defs.in.h:273
int32_t srid
Definition: postgis_ext_defs.in.h:275
LWLINE ** geoms
Definition: postgis_ext_defs.in.h:274
uint8_t type
Definition: postgis_ext_defs.in.h:277
uint32_t ngeoms
Definition: postgis_ext_defs.in.h:279
Definition: postgis_ext_defs.in.h:272
uint32_t maxgeoms
Definition: postgis_ext_defs.in.h:266
int32_t srid
Definition: postgis_ext_defs.in.h:261
GBOX * bbox
Definition: postgis_ext_defs.in.h:259
lwflags_t flags
Definition: postgis_ext_defs.in.h:262
uint32_t ngeoms
Definition: postgis_ext_defs.in.h:265
LWPOINT ** geoms
Definition: postgis_ext_defs.in.h:260
uint8_t type
Definition: postgis_ext_defs.in.h:263
Definition: postgis_ext_defs.in.h:258
uint8_t type
Definition: postgis_ext_defs.in.h:291
GBOX * bbox
Definition: postgis_ext_defs.in.h:287
uint32_t maxgeoms
Definition: postgis_ext_defs.in.h:294
uint32_t ngeoms
Definition: postgis_ext_defs.in.h:293
LWPOLY ** geoms
Definition: postgis_ext_defs.in.h:288
lwflags_t flags
Definition: postgis_ext_defs.in.h:290
int32_t srid
Definition: postgis_ext_defs.in.h:289
Definition: postgis_ext_defs.in.h:286
uint8_t type
Definition: postgis_ext_defs.in.h:361
int32_t srid
Definition: postgis_ext_defs.in.h:359
uint32_t maxgeoms
Definition: postgis_ext_defs.in.h:364
GBOX * bbox
Definition: postgis_ext_defs.in.h:357
uint32_t ngeoms
Definition: postgis_ext_defs.in.h:363
lwflags_t flags
Definition: postgis_ext_defs.in.h:360
LWGEOM ** geoms
Definition: postgis_ext_defs.in.h:358
Definition: postgis_ext_defs.in.h:356
POINTARRAY * point
Definition: postgis_ext_defs.in.h:198
uint8_t type
Definition: postgis_ext_defs.in.h:201
lwflags_t flags
Definition: postgis_ext_defs.in.h:200
GBOX * bbox
Definition: postgis_ext_defs.in.h:197
int32_t srid
Definition: postgis_ext_defs.in.h:199
Definition: postgis_ext_defs.in.h:196
POINTARRAY ** rings
Definition: postgis_ext_defs.in.h:246
uint8_t type
Definition: postgis_ext_defs.in.h:249
uint32_t maxrings
Definition: postgis_ext_defs.in.h:252
uint32_t nrings
Definition: postgis_ext_defs.in.h:251
GBOX * bbox
Definition: postgis_ext_defs.in.h:245
lwflags_t flags
Definition: postgis_ext_defs.in.h:248
int32_t srid
Definition: postgis_ext_defs.in.h:247
Definition: postgis_ext_defs.in.h:244
bool pipeline_is_forward
Definition: postgis_ext_defs.in.h:410
uint8_t source_is_latlong
Definition: postgis_ext_defs.in.h:413
double source_semi_major_metre
Definition: postgis_ext_defs.in.h:415
double source_semi_minor_metre
Definition: postgis_ext_defs.in.h:416
PJ * pj
Definition: postgis_ext_defs.in.h:407
Definition: postgis_ext_defs.in.h:406
lwflags_t flags
Definition: postgis_ext_defs.in.h:374
uint32_t maxgeoms
Definition: postgis_ext_defs.in.h:378
LWPOLY ** geoms
Definition: postgis_ext_defs.in.h:372
uint32_t ngeoms
Definition: postgis_ext_defs.in.h:377
uint8_t type
Definition: postgis_ext_defs.in.h:375
int32_t srid
Definition: postgis_ext_defs.in.h:373
GBOX * bbox
Definition: postgis_ext_defs.in.h:371
Definition: postgis_ext_defs.in.h:370
uint32_t ngeoms
Definition: postgis_ext_defs.in.h:391
int32_t srid
Definition: postgis_ext_defs.in.h:387
uint8_t type
Definition: postgis_ext_defs.in.h:389
lwflags_t flags
Definition: postgis_ext_defs.in.h:388
LWTRIANGLE ** geoms
Definition: postgis_ext_defs.in.h:386
uint32_t maxgeoms
Definition: postgis_ext_defs.in.h:392
GBOX * bbox
Definition: postgis_ext_defs.in.h:385
Definition: postgis_ext_defs.in.h:384
int32_t srid
Definition: postgis_ext_defs.in.h:223
uint8_t type
Definition: postgis_ext_defs.in.h:225
GBOX * bbox
Definition: postgis_ext_defs.in.h:221
lwflags_t flags
Definition: postgis_ext_defs.in.h:224
POINTARRAY * points
Definition: postgis_ext_defs.in.h:222
Definition: postgis_ext_defs.in.h:220
double x
Definition: postgis_ext_defs.in.h:117
Definition: postgis_ext_defs.in.h:116
double m
Definition: postgis_ext_defs.in.h:135
Definition: postgis_ext_defs.in.h:134
double x
Definition: postgis_ext_defs.in.h:123
Definition: postgis_ext_defs.in.h:122
double x
Definition: postgis_ext_defs.in.h:129
Definition: postgis_ext_defs.in.h:128
double m
Definition: postgis_ext_defs.in.h:141
Definition: postgis_ext_defs.in.h:140
lwflags_t flags
Definition: postgis_ext_defs.in.h:158
uint32_t maxpoints
Definition: postgis_ext_defs.in.h:155
uint32_t npoints
Definition: postgis_ext_defs.in.h:154
uint8_t * serialized_pointlist
Definition: postgis_ext_defs.in.h:161
Definition: postgis_ext_defs.in.h:153
double e_sq
Definition: postgis_ext_defs.in.h:106
double e
Definition: postgis_ext_defs.in.h:105
double radius
Definition: postgis_ext_defs.in.h:107
double a
Definition: postgis_ext_defs.in.h:102
double b
Definition: postgis_ext_defs.in.h:103
double f
Definition: postgis_ext_defs.in.h:104
Definition: postgis_ext_defs.in.h:101