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