PostGIS  3.4.0dev-r@@SVN_REVISION@@
liblwgeom.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * PostGIS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * PostGIS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
18  *
19  **********************************************************************
20  *
21  * Copyright 2011 Sandro Santilli <strk@kbt.io>
22  * Copyright 2011 Paul Ramsey <pramsey@cleverelephant.ca>
23  * Copyright 2007-2008 Mark Cave-Ayland
24  * Copyright 2001-2006 Refractions Research Inc.
25  *
26  **********************************************************************/
27 
28 
29 #ifndef _LIBLWGEOM_H
30 #define _LIBLWGEOM_H 1
31 
32 #include <stdarg.h>
33 #include <stdint.h>
34 #include <stdio.h>
35 #include <stdbool.h>
36 
37 #include "../postgis_config.h"
38 
39 #include "proj.h"
40 
41 /* For PROJ6 we cache several extra values to avoid calls to proj_get_source_crs
42  * or proj_get_target_crs since those are very costly
43  */
44 typedef struct LWPROJ
45 {
46  PJ* pj;
47 
48  /* for pipeline transforms, whether to do a forward or inverse */
50 
51  /* Source crs is geographic: Used in geography calls (source srid == dst srid) */
53  /* Source ellipsoid parameters */
57 
58 
59 
60 /* Enable new geodesic functions API */
61 #define PROJ_GEODESIC
62 
82 #define LIBLWGEOM_VERSION "3.4.0dev"
83 #define LIBLWGEOM_VERSION_MAJOR "3"
84 #define LIBLWGEOM_VERSION_MINOR "4"
85 #define LIBLWGEOM_GEOS_VERSION "31300"
86 
88 const char* lwgeom_version(void);
89 
93 #define LW_TRUE 1
94 #define LW_FALSE 0
95 #define LW_UNKNOWN 2
96 #define LW_FAILURE 0
97 #define LW_SUCCESS 1
98 
102 #define POINTTYPE 1
103 #define LINETYPE 2
104 #define POLYGONTYPE 3
105 #define MULTIPOINTTYPE 4
106 #define MULTILINETYPE 5
107 #define MULTIPOLYGONTYPE 6
108 #define COLLECTIONTYPE 7
109 #define CIRCSTRINGTYPE 8
110 #define COMPOUNDTYPE 9
111 #define CURVEPOLYTYPE 10
112 #define MULTICURVETYPE 11
113 #define MULTISURFACETYPE 12
114 #define POLYHEDRALSURFACETYPE 13
115 #define TRIANGLETYPE 14
116 #define TINTYPE 15
117 
118 #define NUMTYPES 16
119 
124 #define WKBZOFFSET 0x80000000
125 #define WKBMOFFSET 0x40000000
126 #define WKBSRIDFLAG 0x20000000
127 #define WKBBBOXFLAG 0x10000000
128 
130 typedef enum LWORD_T {
131  LWORD_X = 0,
132  LWORD_Y = 1,
133  LWORD_Z = 2,
134  LWORD_M = 3
136 
137 /**********************************************************************
138 ** Spherical radius.
139 ** Moritz, H. (1980). Geodetic Reference System 1980, by resolution of
140 ** the XVII General Assembly of the IUGG in Canberra.
141 ** http://en.wikipedia.org/wiki/Earth_radius
142 ** http://en.wikipedia.org/wiki/World_Geodetic_System
143 */
144 
145 #define WGS84_MAJOR_AXIS 6378137.0
146 #define WGS84_INVERSE_FLATTENING 298.257223563
147 #define WGS84_MINOR_AXIS (WGS84_MAJOR_AXIS - WGS84_MAJOR_AXIS / WGS84_INVERSE_FLATTENING)
148 #define WGS84_RADIUS ((2.0 * WGS84_MAJOR_AXIS + WGS84_MINOR_AXIS ) / 3.0)
149 #define WGS84_SRID 4326
150 
151 
158 #define LWFLAG_Z 0x01
159 #define LWFLAG_M 0x02
160 #define LWFLAG_BBOX 0x04
161 #define LWFLAG_GEODETIC 0x08
162 #define LWFLAG_READONLY 0x10
163 #define LWFLAG_SOLID 0x20
164 
165 #define FLAGS_GET_Z(flags) ((flags) & LWFLAG_Z)
166 #define FLAGS_GET_M(flags) (((flags) & LWFLAG_M)>>1)
167 #define FLAGS_GET_BBOX(flags) (((flags) & LWFLAG_BBOX)>>2)
168 #define FLAGS_GET_GEODETIC(flags) (((flags) & LWFLAG_GEODETIC)>>3)
169 #define FLAGS_GET_READONLY(flags) (((flags) & LWFLAG_READONLY)>>4)
170 #define FLAGS_GET_SOLID(flags) (((flags) & LWFLAG_SOLID)>>5)
171 
172 #define FLAGS_SET_Z(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_Z) : ((flags) & ~LWFLAG_Z))
173 #define FLAGS_SET_M(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_M) : ((flags) & ~LWFLAG_M))
174 #define FLAGS_SET_BBOX(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_BBOX) : ((flags) & ~LWFLAG_BBOX))
175 #define FLAGS_SET_GEODETIC(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_GEODETIC) : ((flags) & ~LWFLAG_GEODETIC))
176 #define FLAGS_SET_READONLY(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_READONLY) : ((flags) & ~LWFLAG_READONLY))
177 #define FLAGS_SET_SOLID(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_SOLID) : ((flags) & ~LWFLAG_SOLID))
178 
179 #define FLAGS_NDIMS(flags) (2 + FLAGS_GET_Z(flags) + FLAGS_GET_M(flags))
180 #define FLAGS_GET_ZM(flags) (FLAGS_GET_M(flags) + FLAGS_GET_Z(flags) * 2)
181 #define FLAGS_NDIMS_BOX(flags) (FLAGS_GET_GEODETIC(flags) ? 3 : FLAGS_NDIMS(flags))
182 
192 #define TYPMOD_GET_SRID(typmod) ((((typmod) & 0x0FFFFF00) - ((typmod) & 0x10000000)) >> 8)
193 #define TYPMOD_SET_SRID(typmod, srid) ((typmod) = (((typmod) & 0xE00000FF) | ((srid & 0x001FFFFF)<<8)))
194 #define TYPMOD_GET_TYPE(typmod) ((typmod & 0x000000FC)>>2)
195 #define TYPMOD_SET_TYPE(typmod, type) ((typmod) = (typmod & 0xFFFFFF03) | ((type & 0x0000003F)<<2))
196 #define TYPMOD_GET_Z(typmod) ((typmod & 0x00000002)>>1)
197 #define TYPMOD_SET_Z(typmod) ((typmod) = typmod | 0x00000002)
198 #define TYPMOD_GET_M(typmod) (typmod & 0x00000001)
199 #define TYPMOD_SET_M(typmod) ((typmod) = typmod | 0x00000001)
200 #define TYPMOD_GET_NDIMS(typmod) (2+TYPMOD_GET_Z(typmod)+TYPMOD_GET_M(typmod))
201 
206 #define SRID_MAXIMUM 999999
207 
212 #define SRID_USER_MAXIMUM 998999
213 
215 #define SRID_UNKNOWN 0
216 #define SRID_IS_UNKNOWN(x) ((int)x<=0)
217 
218 /* Invalid SRID value, for internal use */
219 #define SRID_INVALID (999999 + 2)
220 
221 /*
222 ** EPSG WGS84 geographics, OGC standard default SRS, better be in
223 ** the SPATIAL_REF_SYS table!
224 */
225 #define SRID_DEFAULT 4326
226 
227 #ifndef __GNUC__
228 # define __attribute__(x)
229 #endif
230 
237 extern int32_t clamp_srid(int32_t srid);
238 
242 typedef void* (*lwallocator)(size_t size);
243 typedef void* (*lwreallocator)(void *mem, size_t size);
244 typedef void (*lwfreeor)(void* mem);
245 typedef void (*lwreporter)(const char* fmt, va_list ap)
246  __attribute__ (( format(printf, 1, 0) ));
247 typedef void (*lwdebuglogger)(int level, const char* fmt, va_list ap)
248  __attribute__ (( format(printf, 2,0) ));
249 
256 extern void lwgeom_set_handlers(lwallocator allocator,
257  lwreallocator reallocator, lwfreeor freeor, lwreporter errorreporter,
258  lwreporter noticereporter);
259 
260 extern void lwgeom_set_debuglogger(lwdebuglogger debuglogger);
261 
274 extern void lwgeom_request_interrupt(void);
275 
279 extern void lwgeom_cancel_interrupt(void);
280 
291 typedef void (lwinterrupt_callback)();
293 
294 
295 /******************************************************************
296 * LWGEOM and GBOX both use LWFLAGS bit mask.
297 * Serializations (may) use different bit mask schemes.
298 */
299 typedef uint16_t lwflags_t;
300 
301 /******************************************************************
302 * LWGEOM varlena equivalent type that contains both the size and
303 * data(see Postgresql c.h)
304 */
305 typedef struct lwvarlena_t
306 {
307  uint32_t size; /* Do not touch this field directly! */
308  char data[]; /* Data content is here */
310 
311 #define LWVARHDRSZ ((int32_t) sizeof(int32_t))
312 
319 #ifdef WORDS_BIGENDIAN
320 #define LWSIZE_GET(varsize) ((varsize) & 0x3FFFFFFF)
321 #define LWSIZE_SET(varsize, len) ((varsize) = ((len) & 0x3FFFFFFF))
322 #define IS_BIG_ENDIAN 1
323 #else
324 #define LWSIZE_GET(varsize) (((varsize) >> 2) & 0x3FFFFFFF)
325 #define LWSIZE_SET(varsize, len) ((varsize) = (((uint32_t)(len)) << 2))
326 #define IS_BIG_ENDIAN 0
327 #endif
328 
329 /******************************************************************/
330 
331 typedef struct {
332  double afac, bfac, cfac, dfac, efac, ffac, gfac, hfac, ifac, xoff, yoff, zoff;
333 } AFFINE;
334 
335 /******************************************************************/
336 
337 typedef struct
338 {
339  double xmin, ymin, zmin;
340  double xmax, ymax, zmax;
341  int32_t srid;
342 }
343 BOX3D;
344 
345 /******************************************************************
346 * GBOX structure.
347 * We include the flags (information about dimensionality),
348 * so we don't have to constantly pass them
349 * into functions that use the GBOX.
350 */
351 typedef struct
352 {
354  double xmin;
355  double xmax;
356  double ymin;
357  double ymax;
358  double zmin;
359  double zmax;
360  double mmin;
361  double mmax;
362 } GBOX;
363 
364 
365 /******************************************************************
366 * SPHEROID
367 *
368 * Standard definition of an ellipsoid (what wkt calls a spheroid)
369 * f = (a-b)/a
370 * e_sq = (a*a - b*b)/(a*a)
371 * b = a - fa
372 */
373 typedef struct
374 {
375  double a; /* semimajor axis */
376  double b; /* semiminor axis b = (a - fa) */
377  double f; /* flattening f = (a-b)/a */
378  double e; /* eccentricity (first) */
379  double e_sq; /* eccentricity squared (first) e_sq = (a*a-b*b)/(a*a) */
380  double radius; /* spherical average radius = (2*a+b)/3 */
381  char name[20]; /* name of ellipse */
382 }
383 SPHEROID;
384 
385 /******************************************************************
386 * POINT2D, POINT3D, POINT3DM, POINT4D
387 */
388 typedef struct
389 {
390  double x, y;
391 }
392 POINT2D;
393 
394 typedef struct
395 {
396  double x, y, z;
397 }
398 POINT3DZ;
399 
400 typedef struct
401 {
402  double x, y, z;
403 }
404 POINT3D;
405 
406 typedef struct
407 {
408  double x, y, m;
409 }
410 POINT3DM;
411 
412 typedef struct
413 {
414  double x, y, z, m;
415 }
416 POINT4D;
417 
418 /******************************************************************
419 * POINTARRAY
420 * Point array abstracts a lot of the complexity of points and point lists.
421 * It handles 2d/3d translation
422 * (2d points converted to 3d will have z=0 or NaN)
423 * DO NOT MIX 2D and 3D POINTS! EVERYTHING* is either one or the other
424 */
425 typedef struct
426 {
427  uint32_t npoints; /* how many points we are currently storing */
428  uint32_t maxpoints; /* how many points we have space for in serialized_pointlist */
429 
430  /* Use FLAGS_* macros to handle */
432 
433  /* Array of POINT 2D, 3D or 4D, possibly misaligned. */
435 }
436 POINTARRAY;
437 
438 /******************************************************************
439 * GSERIALIZED
440 */
441 
442 typedef struct
443 {
444  uint32_t size; /* For PgSQL use only, use VAR* macros to manipulate. */
445  uint8_t srid[3]; /* 24 bits of SRID */
446  uint8_t gflags; /* HasZ, HasM, HasBBox, IsGeodetic */
447  uint8_t data[1]; /* See gserialized.txt */
448 } GSERIALIZED;
449 
450 /******************************************************************
451 * LWGEOM (any geometry type)
452 *
453 * Abstract type, note that 'type', 'bbox' and 'srid' are available in
454 * all geometry variants.
455 */
456 typedef struct
457 {
459  void *data;
460  int32_t srid;
462  uint8_t type;
463  char pad[1]; /* Padding to 24 bytes (unused) */
464 }
465 LWGEOM;
466 
467 /* POINTYPE */
468 typedef struct
469 {
471  POINTARRAY *point; /* hide 2d/3d (this will be an array of 1 point) */
472  int32_t srid;
474  uint8_t type; /* POINTTYPE */
475  char pad[1]; /* Padding to 24 bytes (unused) */
476 }
477 LWPOINT; /* "light-weight point" */
478 
479 /* LINETYPE */
480 typedef struct
481 {
483  POINTARRAY *points; /* array of POINT3D */
484  int32_t srid;
486  uint8_t type; /* LINETYPE */
487  char pad[1]; /* Padding to 24 bytes (unused) */
488 }
489 LWLINE; /* "light-weight line" */
490 
491 /* TRIANGLE */
492 typedef struct
493 {
496  int32_t srid;
498  uint8_t type;
499  char pad[1]; /* Padding to 24 bytes (unused) */
500 }
501 LWTRIANGLE;
502 
503 /* CIRCSTRINGTYPE */
504 typedef struct
505 {
507  POINTARRAY *points; /* array of POINT(3D/3DM) */
508  int32_t srid;
510  uint8_t type; /* CIRCSTRINGTYPE */
511  char pad[1]; /* Padding to 24 bytes (unused) */
512 }
513 LWCIRCSTRING; /* "light-weight circularstring" */
514 
515 /* POLYGONTYPE */
516 typedef struct
517 {
519  POINTARRAY **rings; /* list of rings (list of points) */
520  int32_t srid;
522  uint8_t type; /* POLYGONTYPE */
523  char pad[1]; /* Padding to 24 bytes (unused) */
524  uint32_t nrings; /* how many rings we are currently storing */
525  uint32_t maxrings; /* how many rings we have space for in **rings */
526 }
527 LWPOLY; /* "light-weight polygon" */
528 
529 /* MULTIPOINTTYPE */
530 typedef struct
531 {
534  int32_t srid;
536  uint8_t type; /* MULTYPOINTTYPE */
537  char pad[1]; /* Padding to 24 bytes (unused) */
538  uint32_t ngeoms; /* how many geometries we are currently storing */
539  uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
540 }
541 LWMPOINT;
542 
543 /* MULTILINETYPE */
544 typedef struct
545 {
548  int32_t srid;
550  uint8_t type; /* MULTILINETYPE */
551  char pad[1]; /* Padding to 24 bytes (unused) */
552  uint32_t ngeoms; /* how many geometries we are currently storing */
553  uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
554 }
555 LWMLINE;
556 
557 /* MULTIPOLYGONTYPE */
558 typedef struct
559 {
562  int32_t srid;
564  uint8_t type; /* MULTIPOLYGONTYPE */
565  char pad[1]; /* Padding to 24 bytes (unused) */
566  uint32_t ngeoms; /* how many geometries we are currently storing */
567  uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
568 }
569 LWMPOLY;
570 
571 /* COLLECTIONTYPE */
572 typedef struct
573 {
576  int32_t srid;
578  uint8_t type; /* COLLECTIONTYPE */
579  char pad[1]; /* Padding to 24 bytes (unused) */
580  uint32_t ngeoms; /* how many geometries we are currently storing */
581  uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
582 }
584 
585 /* COMPOUNDTYPE */
586 typedef struct
587 {
590  int32_t srid;
592  uint8_t type; /* COLLECTIONTYPE */
593  char pad[1]; /* Padding to 24 bytes (unused) */
594  uint32_t ngeoms; /* how many geometries we are currently storing */
595  uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
596 }
597 LWCOMPOUND; /* "light-weight compound line" */
598 
599 /* CURVEPOLYTYPE */
600 typedef struct
601 {
604  int32_t srid;
606  uint8_t type; /* CURVEPOLYTYPE */
607  char pad[1]; /* Padding to 24 bytes (unused) */
608  uint32_t nrings; /* how many rings we are currently storing */
609  uint32_t maxrings; /* how many rings we have space for in **rings */
610 }
611 LWCURVEPOLY; /* "light-weight polygon" */
612 
613 /* MULTICURVE */
614 typedef struct
615 {
618  int32_t srid;
620  uint8_t type; /* MULTICURVE */
621  char pad[1]; /* Padding to 24 bytes (unused) */
622  uint32_t ngeoms; /* how many geometries we are currently storing */
623  uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
624 }
625 LWMCURVE;
626 
627 /* MULTISURFACETYPE */
628 typedef struct
629 {
632  int32_t srid;
634  uint8_t type; /* MULTISURFACETYPE */
635  char pad[1]; /* Padding to 24 bytes (unused) */
636  uint32_t ngeoms; /* how many geometries we are currently storing */
637  uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
638 }
639 LWMSURFACE;
640 
641 /* POLYHEDRALSURFACETYPE */
642 typedef struct
643 {
646  int32_t srid;
648  uint8_t type; /* POLYHEDRALSURFACETYPE */
649  char pad[1]; /* Padding to 24 bytes (unused) */
650  uint32_t ngeoms; /* how many geometries we are currently storing */
651  uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
652 }
653 LWPSURFACE;
654 
655 /* TINTYPE */
656 typedef struct
657 {
660  int32_t srid;
662  uint8_t type; /* TINTYPE */
663  char pad[1]; /* Padding to 24 bytes (unused) */
664  uint32_t ngeoms; /* how many geometries we are currently storing */
665  uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
666 }
667 LWTIN;
668 
669 /* Casts LWGEOM->LW* (return NULL if cast is illegal) */
670 extern LWMPOLY *lwgeom_as_lwmpoly(const LWGEOM *lwgeom);
671 extern LWMLINE *lwgeom_as_lwmline(const LWGEOM *lwgeom);
672 extern LWMPOINT *lwgeom_as_lwmpoint(const LWGEOM *lwgeom);
673 extern LWCOLLECTION *lwgeom_as_lwcollection(const LWGEOM *lwgeom);
674 extern LWPOLY *lwgeom_as_lwpoly(const LWGEOM *lwgeom);
675 extern LWLINE *lwgeom_as_lwline(const LWGEOM *lwgeom);
676 
677 extern LWCIRCSTRING *lwgeom_as_lwcircstring(const LWGEOM *lwgeom);
678 extern LWCURVEPOLY *lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom);
679 extern LWCOMPOUND *lwgeom_as_lwcompound(const LWGEOM *lwgeom);
680 extern LWPSURFACE *lwgeom_as_lwpsurface(const LWGEOM *lwgeom);
681 extern LWTRIANGLE *lwgeom_as_lwtriangle(const LWGEOM *lwgeom);
682 extern LWTIN *lwgeom_as_lwtin(const LWGEOM *lwgeom);
683 extern LWGEOM *lwgeom_as_multi(const LWGEOM *lwgeom);
684 extern LWGEOM *lwgeom_as_curve(const LWGEOM *lwgeom);
685 
686 /* Casts LW*->LWGEOM (always cast) */
687 extern LWGEOM *lwtin_as_lwgeom(const LWTIN *obj);
688 extern LWGEOM *lwtriangle_as_lwgeom(const LWTRIANGLE *obj);
689 extern LWGEOM *lwpsurface_as_lwgeom(const LWPSURFACE *obj);
690 extern LWGEOM *lwmpoly_as_lwgeom(const LWMPOLY *obj);
691 extern LWGEOM *lwmline_as_lwgeom(const LWMLINE *obj);
692 extern LWGEOM *lwmpoint_as_lwgeom(const LWMPOINT *obj);
693 extern LWGEOM *lwcollection_as_lwgeom(const LWCOLLECTION *obj);
694 extern LWGEOM *lwcircstring_as_lwgeom(const LWCIRCSTRING *obj);
695 extern LWGEOM *lwcompound_as_lwgeom(const LWCOMPOUND *obj);
696 extern LWGEOM *lwcurvepoly_as_lwgeom(const LWCURVEPOLY *obj);
697 extern LWGEOM *lwpoly_as_lwgeom(const LWPOLY *obj);
698 extern LWGEOM *lwline_as_lwgeom(const LWLINE *obj);
699 extern LWGEOM *lwpoint_as_lwgeom(const LWPOINT *obj);
700 
701 
702 extern LWCOLLECTION* lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom);
703 extern LWMPOINT* lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj);
704 extern LWMLINE* lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj);
705 extern LWMPOLY* lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj);
706 extern LWPSURFACE* lwpsurface_add_lwpoly(LWPSURFACE *mobj, const LWPOLY *obj);
707 extern LWTIN* lwtin_add_lwtriangle(LWTIN *mobj, const LWTRIANGLE *obj);
708 
710 
714 extern lwflags_t lwflags(int hasz, int hasm, int geodetic);
715 
716 
717 
718 /***********************************************************************
719 ** GSERIALIZED API
720 */
721 
726 
731 extern const float * gserialized_get_float_box_p(const GSERIALIZED *g, size_t *ndims);
732 
737 extern uint32_t gserialized_get_type(const GSERIALIZED *g);
738 
743 extern uint32_t gserialized_max_header_size(void);
744 
750 extern int32_t gserialized_hash(const GSERIALIZED *g);
751 
756 extern int32_t gserialized_get_srid(const GSERIALIZED *g);
757 
762 extern void gserialized_set_srid(GSERIALIZED *g, int32_t srid);
763 
770 extern int gserialized_is_empty(const GSERIALIZED *g);
771 
775 extern int gserialized_has_bbox(const GSERIALIZED *gser);
776 
780 extern int gserialized_has_z(const GSERIALIZED *gser);
781 
785 extern int gserialized_has_m(const GSERIALIZED *gser);
786 
790 extern int gserialized_is_geodetic(const GSERIALIZED *gser);
791 
795 extern int gserialized_ndims(const GSERIALIZED *gser);
796 
806 extern int gserialized_cmp(const GSERIALIZED *g1, const GSERIALIZED *g2);
807 
815 extern GSERIALIZED* gserialized_from_lwgeom(LWGEOM *geom, size_t *size);
816 
821 extern LWGEOM* lwgeom_from_gserialized(const GSERIALIZED *g);
822 
828 extern int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *box);
829 
834 extern int gserialized_fast_gbox_p(const GSERIALIZED *g, GBOX *box);
835 
842 
848 
852 extern uint32_t gserialized_get_version(const GSERIALIZED *g);
853 
857 extern int gserialized_peek_first_point(const GSERIALIZED *g, POINT4D *out_point);
858 
859 /*****************************************************************************/
860 
861 
868 extern void lwgeom_drop_bbox(LWGEOM *lwgeom);
869 extern void lwgeom_drop_srid(LWGEOM *lwgeom);
870 
877 extern void lwgeom_add_bbox(LWGEOM *lwgeom);
881 extern void lwgeom_refresh_bbox(LWGEOM *lwgeom);
885 extern void lwgeom_add_bbox_deep(LWGEOM *lwgeom, GBOX *gbox);
886 
894 extern const GBOX *lwgeom_get_bbox(const LWGEOM *lwgeom);
895 
899 extern int lwgeom_is_collection(const LWGEOM *lwgeom);
900 
904 extern int lwgeom_isfinite(const LWGEOM *lwgeom);
905 
906 
907 /******************************************************************/
908 /* Functions that work on type numbers */
909 
913 extern int lwtype_is_collection(uint8_t type);
914 
918 extern uint32_t lwtype_get_collectiontype(uint8_t type);
919 
924 extern const char *lwtype_name(uint8_t type);
925 extern uint8_t lwtype_multitype(uint8_t type);
926 
927 /******************************************************************/
928 
929 /*
930  * copies a point from the point array into the parameter point
931  * will set point's z=0 (or NaN) if pa is 2d
932  * will set point's m=0 (or NaN) if pa is 3d or 2d
933  * NOTE: point is a real POINT3D *not* a pointer
934  */
935 extern POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n);
936 
937 /*
938  * copies a point from the point array into the parameter point
939  * will set point's z=0 (or NaN) if pa is 2d
940  * will set point's m=0 (or NaN) if pa is 3d or 2d
941  * NOTE: this will modify the point4d pointed to by 'point'.
942  */
943 extern int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point);
944 
945 /*
946  * copies a point from the point array into the parameter point
947  * will set point's z=0 (or NaN) if pa is 2d
948  * NOTE: point is a real POINT3D *not* a pointer
949  */
950 extern POINT3DZ getPoint3dz(const POINTARRAY *pa, uint32_t n);
951 extern POINT3DM getPoint3dm(const POINTARRAY *pa, uint32_t n);
952 
953 /*
954  * copies a point from the point array into the parameter point
955  * will set point's z=0 (or NaN) if pa is 2d
956  * NOTE: this will modify the point3d pointed to by 'point'.
957  */
958 extern int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point);
959 extern int getPoint3dm_p(const POINTARRAY *pa, uint32_t n, POINT3DM *point);
960 
961 
962 /*
963  * copies a point from the point array into the parameter point
964  * z value (if present is not returned)
965  * NOTE: point is a real POINT3D *not* a pointer
966  */
967 extern POINT2D getPoint2d(const POINTARRAY *pa, uint32_t n);
968 
969 /*
970  * copies a point from the point array into the parameter point
971  * z value (if present is not returned)
972  * NOTE: this will modify the point2d pointed to by 'point'.
973  */
974 extern int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point);
975 
976 /*
977  * set point N to the given value
978  * NOTE that the pointarray can be of any
979  * dimension, the appropriate ordinate values
980  * will be extracted from it
981  *
982  * N must be a valid point index
983  */
984 extern void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d);
985 
991 extern POINTARRAY* ptarray_construct(char hasz, char hasm, uint32_t npoints);
992 
996 extern POINTARRAY* ptarray_construct_copy_data(char hasz, char hasm, uint32_t npoints, const uint8_t *ptlist);
997 
1001 extern POINTARRAY* ptarray_construct_reference_data(char hasz, char hasm, uint32_t npoints, uint8_t *ptlist);
1002 
1008 extern POINTARRAY* ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints);
1009 
1015 extern int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates);
1016 
1028 extern int ptarray_append_ptarray(POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance);
1029 
1034 extern int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where);
1035 
1040 extern int ptarray_remove_point(POINTARRAY *pa, uint32_t where);
1041 
1053 extern POINTARRAY *ptarray_addPoint(const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where);
1054 
1060 extern POINTARRAY *ptarray_removePoint(POINTARRAY *pa, uint32_t where);
1061 
1068 extern POINTARRAY *ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2);
1069 
1070 extern int ptarray_is_closed(const POINTARRAY *pa);
1071 extern int ptarray_is_closed_2d(const POINTARRAY *pa);
1072 extern int ptarray_is_closed_3d(const POINTARRAY *pa);
1073 extern int ptarray_is_closed_z(const POINTARRAY *pa);
1075 
1081 extern POINTARRAY *ptarray_substring(POINTARRAY *pa, double d1, double d2,
1082  double tolerance);
1083 
1089 extern int ptarray_closest_vertex_2d(const POINTARRAY *pa,
1090  const POINT2D *qp, double *dist);
1091 
1099 extern int ptarray_closest_segment_2d(const POINTARRAY *pa,
1100  const POINT2D *qp, double *dist);
1101 
1102 
1103 
1107 extern LWGEOM* lwgeom_force_2d(const LWGEOM *geom);
1108 extern LWGEOM* lwgeom_force_3dz(const LWGEOM *geom, double zval);
1109 extern LWGEOM* lwgeom_force_3dm(const LWGEOM *geom, double mval);
1110 extern LWGEOM* lwgeom_force_4d(const LWGEOM *geom, double zval, double mval);
1111 
1112 extern LWGEOM* lwgeom_set_effective_area(const LWGEOM *igeom, int set_area, double area);
1113 extern LWGEOM* lwgeom_chaikin(const LWGEOM *igeom, int n_iterations, int preserve_endpoint);
1114 extern LWGEOM* lwgeom_filter_m(LWGEOM *geom, double min, double max, int returnm);
1115 
1116 /*
1117  * Force to use SFS 1.1 geometry type
1118  * (rather than SFS 1.2 and/or SQL/MM)
1119  */
1120 extern LWGEOM* lwgeom_force_sfs(LWGEOM *geom, int version);
1121 
1122 
1123 /*--------------------------------------------------------
1124  * all the base types (point/line/polygon) will have a
1125  * basic constructor, basic de-serializer, basic serializer,
1126  * bounding box finder and (TODO) serialized form size finder.
1127  *--------------------------------------------------------*/
1128 
1129 /*
1130  * convenience functions to hide the POINTARRAY
1131  */
1132 extern int lwpoint_getPoint2d_p(const LWPOINT *point, POINT2D *out);
1133 extern int lwpoint_getPoint3dz_p(const LWPOINT *point, POINT3DZ *out);
1134 extern int lwpoint_getPoint3dm_p(const LWPOINT *point, POINT3DM *out);
1135 extern int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out);
1136 
1137 /******************************************************************
1138  * LWLINE functions
1139  ******************************************************************/
1140 
1144 extern int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, uint32_t where);
1145 
1149 extern POINTARRAY* lwline_interpolate_points(const LWLINE *line, double length_fraction, char repeat);
1150 
1154 extern LWPOINT* lwline_interpolate_point_3d(const LWLINE *line, double distance);
1155 
1159 extern LWLINE* lwline_extend(const LWLINE *line, double distance_forward, double distance_backward);
1160 
1161 /******************************************************************
1162  * LWPOLY functions
1163  ******************************************************************/
1164 
1169 extern int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa);
1170 
1175 extern int lwcurvepoly_add_ring(LWCURVEPOLY *poly, LWGEOM *ring);
1176 
1181 extern int lwcompound_add_lwgeom(LWCOMPOUND *comp, LWGEOM *geom);
1182 
1187 extern LWCOMPOUND* lwcompound_construct_from_lwline(const LWLINE *lwpoly);
1188 
1194 
1195 
1196 /******************************************************************
1197  * LWGEOM functions
1198  ******************************************************************/
1199 
1200 extern int lwcollection_ngeoms(const LWCOLLECTION *col);
1201 
1202 /* Given a generic geometry/collection, return the "simplest" form.
1203  * The elements of the homogenized collection are deeply cloned
1204  * */
1205 extern LWGEOM *lwgeom_homogenize(const LWGEOM *geom);
1206 
1207 
1208 /******************************************************************
1209  * LWMULTIx and LWCOLLECTION functions
1210  ******************************************************************/
1211 
1213 LWCOLLECTION* lwcollection_extract(const LWCOLLECTION *col, uint32_t type);
1214 
1215 
1216 /******************************************************************
1217  * SERIALIZED FORM functions
1218  ******************************************************************/
1219 
1225 extern void lwgeom_set_srid(LWGEOM *geom, int32_t srid);
1226 
1227 /*------------------------------------------------------
1228  * other stuff
1229  *
1230  * handle the double-to-float conversion. The results of this
1231  * will usually be a slightly bigger box because of the difference
1232  * between float8 and float4 representations.
1233  */
1234 
1235 extern BOX3D* box3d_from_gbox(const GBOX *gbox);
1236 extern GBOX* box3d_to_gbox(const BOX3D *b3d);
1237 
1238 void expand_box3d(BOX3D *box, double d);
1239 
1240 
1241 /****************************************************************
1242  * MEMORY MANAGEMENT
1243  ****************************************************************/
1244 
1245 /*
1246 * The *_free family of functions frees *all* memory associated
1247 * with the pointer. When the recursion gets to the level of the
1248 * POINTARRAY, the POINTARRAY is only freed if it is not flagged
1249 * as "read only". LWGEOMs constructed on top of GSERIALIZED
1250 * from PgSQL use read only point arrays.
1251 */
1252 
1253 extern void ptarray_free(POINTARRAY *pa);
1254 extern void lwpoint_free(LWPOINT *pt);
1255 extern void lwline_free(LWLINE *line);
1256 extern void lwpoly_free(LWPOLY *poly);
1257 extern void lwtriangle_free(LWTRIANGLE *triangle);
1258 extern void lwmpoint_free(LWMPOINT *mpt);
1259 extern void lwmline_free(LWMLINE *mline);
1260 extern void lwmpoly_free(LWMPOLY *mpoly);
1261 extern void lwpsurface_free(LWPSURFACE *psurf);
1262 extern void lwtin_free(LWTIN *tin);
1263 extern void lwcollection_free(LWCOLLECTION *col);
1264 extern void lwcircstring_free(LWCIRCSTRING *curve);
1265 extern void lwgeom_free(LWGEOM *geom);
1266 
1267 /*
1268 * The *_release family of functions frees the LWGEOM structures
1269 * surrounding the POINTARRAYs but leaves the POINTARRAYs
1270 * intact. Useful when re-shaping geometries between types,
1271 * or splicing geometries together.
1272 */
1273 
1274 extern void lwpoint_release(LWPOINT *lwpoint);
1275 extern void lwline_release(LWLINE *lwline);
1276 extern void lwpoly_release(LWPOLY *lwpoly);
1277 extern void lwtriangle_release(LWTRIANGLE *lwtriangle);
1278 extern void lwcircstring_release(LWCIRCSTRING *lwcirc);
1279 extern void lwmpoint_release(LWMPOINT *lwpoint);
1280 extern void lwmline_release(LWMLINE *lwline);
1281 extern void lwmpoly_release(LWMPOLY *lwpoly);
1282 extern void lwpsurface_release(LWPSURFACE *lwpsurface);
1283 extern void lwtin_release(LWTIN *lwtin);
1284 extern void lwcollection_release(LWCOLLECTION *lwcollection);
1285 extern void lwgeom_release(LWGEOM *lwgeom);
1286 
1287 
1288 /****************************************************************
1289 * Utility
1290 ****************************************************************/
1291 
1292 extern void printBOX3D(BOX3D *b);
1293 extern void printPA(POINTARRAY *pa);
1294 extern void printLWPOINT(LWPOINT *point);
1295 extern void printLWLINE(LWLINE *line);
1296 extern void printLWPOLY(LWPOLY *poly);
1297 extern void printLWTRIANGLE(LWTRIANGLE *triangle);
1298 extern void printLWPSURFACE(LWPSURFACE *psurf);
1299 extern void printLWTIN(LWTIN *tin);
1300 
1301 extern float next_float_down(double d);
1302 extern float next_float_up(double d);
1303 
1304 /* general utilities 2D */
1305 extern double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2);
1306 extern double distance2d_sqr_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B);
1307 extern LWGEOM* lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2);
1308 extern LWGEOM* lwgeom_furthest_line(const LWGEOM *lw1, const LWGEOM *lw2);
1309 extern LWGEOM* lwgeom_closest_point(const LWGEOM *lw1, const LWGEOM *lw2);
1310 extern LWGEOM* lwgeom_furthest_point(const LWGEOM *lw1, const LWGEOM *lw2);
1311 extern double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2);
1312 extern double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance);
1313 extern double lwgeom_maxdistance2d(const LWGEOM *lw1, const LWGEOM *lw2);
1314 extern double lwgeom_maxdistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance);
1315 
1316 /* 3D */
1317 extern double distance3d_pt_pt(const POINT3D *p1, const POINT3D *p2);
1318 extern double distance3d_pt_seg(const POINT3D *p, const POINT3D *A, const POINT3D *B);
1319 
1320 extern LWGEOM* lwgeom_furthest_line_3d(LWGEOM *lw1, LWGEOM *lw2);
1321 extern LWGEOM* lwgeom_closest_line_3d(const LWGEOM *lw1, const LWGEOM *lw2);
1322 extern LWGEOM* lwgeom_closest_point_3d(const LWGEOM *lw1, const LWGEOM *lw2);
1323 
1324 
1325 extern double lwgeom_mindistance3d(const LWGEOM *lw1, const LWGEOM *lw2);
1326 extern double lwgeom_mindistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance);
1327 extern double lwgeom_maxdistance3d(const LWGEOM *lw1, const LWGEOM *lw2);
1328 extern double lwgeom_maxdistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance);
1329 
1330 extern double lwgeom_area(const LWGEOM *geom);
1331 extern double lwgeom_length(const LWGEOM *geom);
1332 extern double lwgeom_length_2d(const LWGEOM *geom);
1333 extern double lwgeom_perimeter(const LWGEOM *geom);
1334 extern double lwgeom_perimeter_2d(const LWGEOM *geom);
1335 extern int lwgeom_dimension(const LWGEOM *geom);
1336 
1337 extern LWPOINT* lwline_get_lwpoint(const LWLINE *line, uint32_t where);
1338 extern LWPOINT* lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, uint32_t where);
1339 
1340 extern LWPOINT* lwcompound_get_startpoint(const LWCOMPOUND *lwcmp);
1341 extern LWPOINT* lwcompound_get_endpoint(const LWCOMPOUND *lwcmp);
1342 extern LWPOINT* lwcompound_get_lwpoint(const LWCOMPOUND *lwcmp, uint32_t where);
1343 
1344 extern double ptarray_length_2d(const POINTARRAY *pts);
1345 extern int pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring);
1346 extern int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret);
1347 extern LWPOINT* lwpoint_project_lwpoint(const LWPOINT* lwpoint1, const LWPOINT* lwpoint2, double distance);
1348 extern LWPOINT* lwpoint_project(const LWPOINT* lwpoint1, double distance, double azimuth);
1349 extern int lwpoint_inside_circle(const LWPOINT *p, double cx, double cy, double rad);
1350 
1351 extern LWGEOM* lwgeom_reverse(const LWGEOM *lwgeom);
1352 extern char* lwgeom_summary(const LWGEOM *lwgeom, int offset);
1353 extern char* lwpoint_to_latlon(const LWPOINT *p, const char *format);
1354 extern int lwgeom_startpoint(const LWGEOM* lwgeom, POINT4D* pt);
1355 
1356 extern void interpolate_point4d(const POINT4D *A, const POINT4D *B, POINT4D *I, double F);
1357 
1362 extern int lwgeom_is_clockwise(LWGEOM *lwgeom);
1363 
1364 
1368 extern LWGEOM* lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed);
1369 extern LWGEOM* lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance);
1370 
1374 typedef struct gridspec_t
1375 {
1376  double ipx;
1377  double ipy;
1378  double ipz;
1379  double ipm;
1380  double xsize;
1381  double ysize;
1382  double zsize;
1383  double msize;
1384 }
1386 
1387 extern LWGEOM* lwgeom_grid(const LWGEOM *lwgeom, const gridspec *grid);
1388 extern void lwgeom_grid_in_place(LWGEOM *lwgeom, const gridspec *grid);
1389 
1390 
1391 /****************************************************************
1392 * READ/WRITE FUNCTIONS
1393 *
1394 * Coordinate writing functions, which will alter the coordinates
1395 * and potentially the structure of the input geometry. When
1396 * called from within PostGIS, the LWGEOM argument should be built
1397 * on top of a gserialized copy, created using
1398 * PG_GETARG_GSERIALIZED_P_COPY()
1399 ****************************************************************/
1400 
1401 extern void lwgeom_reverse_in_place(LWGEOM *lwgeom);
1402 extern void lwgeom_force_clockwise(LWGEOM *lwgeom);
1403 extern void lwgeom_longitude_shift(LWGEOM *lwgeom);
1404 extern int lwgeom_simplify_in_place(LWGEOM *igeom, double dist, int preserve_collapsed);
1405 extern void lwgeom_affine(LWGEOM *geom, const AFFINE *affine);
1406 extern void lwgeom_scale(LWGEOM *geom, const POINT4D *factors);
1407 extern int lwgeom_remove_repeated_points_in_place(LWGEOM *in, double tolerance);
1408 
1409 
1422 LWGEOM *lwgeom_wrapx(const LWGEOM *lwgeom, double cutx, double amount);
1423 
1424 
1434 extern int lwgeom_needs_bbox(const LWGEOM *geom);
1435 
1439 extern uint32_t lwgeom_count_vertices(const LWGEOM *geom);
1440 
1445 extern uint32_t lwgeom_count_rings(const LWGEOM *geom);
1446 
1451 extern int lwgeom_has_srid(const LWGEOM *geom);
1452 
1457 extern int lwgeom_is_closed(const LWGEOM *geom);
1458 
1462 extern int lwgeom_dimensionality(const LWGEOM *geom);
1463 
1464 /* Is lwgeom1 geometrically equal to lwgeom2 ? */
1465 extern char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2);
1466 
1467 
1475 extern LWGEOM *lwgeom_clone(const LWGEOM *lwgeom);
1476 
1480 extern LWGEOM *lwgeom_clone_deep(const LWGEOM *lwgeom);
1481 extern POINTARRAY *ptarray_clone_deep(const POINTARRAY *ptarray);
1482 
1483 
1484 /*
1485 * Geometry constructors. These constructors to not copy the point arrays
1486 * passed to them, they just take references, so do not free them out
1487 * from underneath the geometries.
1488 */
1489 extern LWPOINT* lwpoint_construct(int32_t srid, GBOX *bbox, POINTARRAY *point);
1490 extern LWMPOINT *lwmpoint_construct(int32_t srid, const POINTARRAY *pa);
1491 extern LWLINE* lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points);
1492 extern LWCIRCSTRING* lwcircstring_construct(int32_t srid, GBOX *bbox, POINTARRAY *points);
1493 extern LWPOLY* lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points);
1494 extern LWCURVEPOLY* lwcurvepoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, LWGEOM **geoms);
1495 extern LWTRIANGLE* lwtriangle_construct(int32_t srid, GBOX *bbox, POINTARRAY *points);
1496 extern LWCOLLECTION* lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms);
1497 /*
1498 * Empty geometry constructors.
1499 */
1500 extern LWGEOM* lwgeom_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm);
1501 extern LWPOINT* lwpoint_construct_empty(int32_t srid, char hasz, char hasm);
1502 extern LWLINE* lwline_construct_empty(int32_t srid, char hasz, char hasm);
1503 extern LWPOLY* lwpoly_construct_empty(int32_t srid, char hasz, char hasm);
1504 extern LWCURVEPOLY* lwcurvepoly_construct_empty(int32_t srid, char hasz, char hasm);
1505 extern LWCIRCSTRING* lwcircstring_construct_empty(int32_t srid, char hasz, char hasm);
1506 extern LWCOMPOUND* lwcompound_construct_empty(int32_t srid, char hasz, char hasm);
1507 extern LWTRIANGLE* lwtriangle_construct_empty(int32_t srid, char hasz, char hasm);
1508 extern LWMPOINT* lwmpoint_construct_empty(int32_t srid, char hasz, char hasm);
1509 extern LWMLINE* lwmline_construct_empty(int32_t srid, char hasz, char hasm);
1510 extern LWMPOLY* lwmpoly_construct_empty(int32_t srid, char hasz, char hasm);
1511 extern LWCOLLECTION* lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm);
1512 
1513 
1514 /* Other constructors */
1515 extern LWPOINT *lwpoint_make2d(int32_t srid, double x, double y);
1516 extern LWPOINT *lwpoint_make3dz(int32_t srid, double x, double y, double z);
1517 extern LWPOINT *lwpoint_make3dm(int32_t srid, double x, double y, double m);
1518 extern LWPOINT *lwpoint_make4d(int32_t srid, double x, double y, double z, double m);
1519 extern LWPOINT *lwpoint_make(int32_t srid, int hasz, int hasm, const POINT4D *p);
1520 extern LWLINE *lwline_from_lwgeom_array(int32_t srid, uint32_t ngeoms, LWGEOM **geoms);
1521 extern LWLINE *lwline_from_ptarray(int32_t srid, uint32_t npoints, LWPOINT **points); /* TODO: deprecate */
1522 extern LWLINE *lwline_from_lwmpoint(int32_t srid, const LWMPOINT *mpoint);
1523 extern LWLINE *lwline_addpoint(LWLINE *line, LWPOINT *point, uint32_t where);
1524 extern LWLINE *lwline_removepoint(LWLINE *line, uint32_t which);
1525 extern void lwline_setPoint4d(LWLINE *line, uint32_t which, POINT4D *newpoint);
1526 extern LWPOLY *lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes);
1527 extern LWPOLY *lwpoly_construct_rectangle(char hasz, char hasm, POINT4D *p1, POINT4D *p2, POINT4D *p3, POINT4D *p4);
1528 extern LWPOLY *lwpoly_construct_envelope(int32_t srid, double x1, double y1, double x2, double y2);
1529 extern LWPOLY *lwpoly_construct_circle(int32_t srid, double x, double y, double radius, uint32_t segments_per_quarter, char exterior);
1530 extern LWTRIANGLE *lwtriangle_from_lwline(const LWLINE *shell);
1531 extern LWMPOINT *lwmpoint_from_lwgeom(const LWGEOM *g); /* Extract the coordinates of an LWGEOM into an LWMPOINT */
1532 
1533 /* Some point accessors */
1534 extern double lwpoint_get_x(const LWPOINT *point);
1535 extern double lwpoint_get_y(const LWPOINT *point);
1536 extern double lwpoint_get_z(const LWPOINT *point);
1537 extern double lwpoint_get_m(const LWPOINT *point);
1538 
1542 extern int32_t lwgeom_get_srid(const LWGEOM *geom);
1543 
1547 extern int lwgeom_has_z(const LWGEOM *geom);
1548 
1552 extern int lwgeom_has_m(const LWGEOM *geom);
1553 
1557 extern int lwgeom_is_solid(const LWGEOM *geom);
1558 
1562 extern int lwgeom_ndims(const LWGEOM *geom);
1563 
1564 /*
1565  * Given a point, returns the location of closest point on pointarray
1566  * as a fraction of total length (0: first point -- 1: last point).
1567  *
1568  * If not-null, the third argument will be set to the actual distance
1569  * of the point from the pointarray.
1570  */
1571 extern double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located);
1572 
1577 extern LWLINE *lwline_measured_from_lwline(const LWLINE *lwline, double m_start, double m_end);
1578 extern LWMLINE* lwmline_measured_from_lwmline(const LWMLINE *lwmline, double m_start, double m_end);
1579 
1584 extern LWGEOM* lwgeom_locate_along(const LWGEOM *lwin, double m, double offset);
1585 
1591 extern LWCOLLECTION* lwgeom_locate_between(const LWGEOM *lwin, double from, double to, double offset);
1592 
1596 extern double lwgeom_interpolate_point(const LWGEOM *lwin, const LWPOINT *lwpt);
1597 
1608 extern double lwgeom_tcpa(const LWGEOM *g1, const LWGEOM *g2, double *mindist);
1609 
1615 extern int lwgeom_cpa_within(const LWGEOM *g1, const LWGEOM *g2, double maxdist);
1616 
1621 extern int lwgeom_is_trajectory(const LWGEOM *geom);
1622 extern int lwline_is_trajectory(const LWLINE *geom);
1623 
1624 /*
1625  * Ensure every segment is at most 'dist' long.
1626  * Returned LWGEOM might is unchanged if a POINT.
1627  */
1628 extern LWGEOM *lwgeom_segmentize2d(const LWGEOM *line, double dist);
1629 extern POINTARRAY *ptarray_segmentize2d(const POINTARRAY *ipa, double dist);
1630 extern LWLINE *lwline_segmentize2d(const LWLINE *line, double dist);
1631 extern LWPOLY *lwpoly_segmentize2d(const LWPOLY *line, double dist);
1632 extern LWCOLLECTION *lwcollection_segmentize2d(const LWCOLLECTION *coll, double dist);
1633 
1634 /*
1635  * Point density functions
1636  */
1637 extern LWMPOINT *lwpoly_to_points(const LWPOLY *poly, uint32_t npoints, int32_t seed);
1638 extern LWMPOINT *lwmpoly_to_points(const LWMPOLY *mpoly, uint32_t npoints, int32_t seed);
1639 extern LWMPOINT *lwgeom_to_points(const LWGEOM *lwgeom, uint32_t npoints, int32_t seed);
1640 
1641 /*
1642  * Geometric median
1643  */
1644 extern LWPOINT* lwgeom_median(const LWGEOM *g, double tol, uint32_t maxiter, char fail_if_not_converged);
1645 extern LWPOINT* lwmpoint_median(const LWMPOINT *g, double tol, uint32_t maxiter, char fail_if_not_converged);
1646 
1650 lwvarlena_t *lwgeom_geohash(const LWGEOM *lwgeom, int precision);
1651 unsigned int geohash_point_as_int(POINT2D *pt);
1652 
1653 
1665 };
1666 
1670 int lwline_crossing_direction(const LWLINE *l1, const LWLINE *l2);
1671 
1675 LWCOLLECTION* lwgeom_clip_to_ordinate_range(const LWGEOM *lwin, char ordinate, double from, double to, double offset);
1676 
1682 #define LW_GML_IS_DIMS (1<<0)
1684 #define LW_GML_IS_DEGREE (1<<1)
1686 #define LW_GML_SHORTLINE (1<<2)
1688 #define LW_GML_EXTENT (1<<4)
1689 
1690 
1691 #define IS_DIMS(x) ((x) & LW_GML_IS_DIMS)
1692 #define IS_DEGREE(x) ((x) & LW_GML_IS_DEGREE)
1700 #define LW_X3D_FLIP_XY (1<<0)
1701 #define LW_X3D_USE_GEOCOORDS (1<<1)
1702 #define X3D_USE_GEOCOORDS(x) ((x) & LW_X3D_USE_GEOCOORDS)
1703 
1704 
1705 
1706 extern lwvarlena_t* lwgeom_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix);
1707 extern lwvarlena_t* lwgeom_extent_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix);
1711 extern lwvarlena_t* lwgeom_extent_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix);
1712 extern lwvarlena_t* lwgeom_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix, const char *id);
1713 extern lwvarlena_t* lwgeom_to_kml2(const LWGEOM *geom, int precision, const char *prefix);
1714 extern lwvarlena_t* lwgeom_to_geojson(const LWGEOM *geo, const char *srs, int precision, int has_bbox);
1715 extern lwvarlena_t* lwgeom_to_x3d3(const LWGEOM *geom, int precision, int opts, const char *defid);
1716 extern lwvarlena_t* lwgeom_to_svg(const LWGEOM *geom, int precision, int relative);
1717 extern lwvarlena_t* lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision);
1718 
1728 extern LWGEOM* lwgeom_from_geojson(const char *geojson, char **srs);
1729 
1735 extern LWGEOM* lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision);
1736 
1740 extern void spheroid_init(SPHEROID *s, double a, double b);
1741 
1747 extern double lwgeom_distance_spheroid(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2, const SPHEROID *spheroid, double tolerance);
1748 
1752 extern LWPOINT* lwgeom_project_spheroid(const LWPOINT *r, const SPHEROID *spheroid, double distance, double azimuth);
1753 
1757 extern LWPOINT* lwgeom_project_spheroid_lwpoint(const LWPOINT *from, const LWPOINT *to, const SPHEROID *spheroid, double distance);
1758 
1763 extern LWGEOM* lwgeom_segmentize_sphere(const LWGEOM *lwg_in, double max_seg_length);
1764 
1768 extern double lwgeom_azumith_spheroid(const LWPOINT *r, const LWPOINT *s, const SPHEROID *spheroid);
1769 
1774 extern double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid);
1775 
1780 extern double lwgeom_area_spheroid(const LWGEOM *lwgeom, const SPHEROID *spheroid);
1781 
1786 extern double lwgeom_length_spheroid(const LWGEOM *geom, const SPHEROID *s);
1787 
1792 extern int lwgeom_covers_lwgeom_sphere(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2);
1793 
1794 
1795 extern LWGEOM * geography_substring(const LWLINE *line,
1796  const SPHEROID *s,
1797  double from, double to,
1798  double tolerance);
1799 
1801  const LWLINE *line,
1802  double length_fraction,
1803  const SPHEROID *s, char repeat);
1804 
1805 extern double
1807  const POINTARRAY *pa,
1808  const POINT4D *p4d,
1809  const SPHEROID *s,
1810  double tolerance,
1811  double *mindistout,
1812  POINT4D *proj4d);
1813 
1814 
1815 typedef struct {
1817  double radius;
1819 
1821 
1822 /* Calculates the minimum circle that encloses all of the points in g, using a
1823  * two-dimensional implementation of the algorithm proposed in:
1824  *
1825  * Welzl, Emo (1991), "Smallest enclosing disks (balls and elipsoids)."
1826  * New Results and Trends in Computer Science (H. Maurer, Ed.), Lecture Notes
1827  * in Computer Science, 555 (1991) 359-370.
1828  *
1829  * Available online at the time of this writing at
1830  * https://www.inf.ethz.ch/personal/emo/PublFiles/SmallEnclDisk_LNCS555_91.pdf
1831  *
1832  * Returns NULL if the circle could not be calculated.
1833  */
1834 extern LWBOUNDINGCIRCLE* lwgeom_calculate_mbc(const LWGEOM* g);
1835 
1848 extern void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2);
1849 
1850 
1851 struct LWPOINTITERATOR;
1852 typedef struct LWPOINTITERATOR LWPOINTITERATOR;
1853 
1858 
1864 
1869 
1874 
1880 extern int lwpointiterator_modify_next(LWPOINTITERATOR* s, const POINT4D* p);
1881 
1889 
1895 
1896 
1900 extern uint8_t parse_hex(char *str);
1901 
1905 extern void deparse_hex(uint8_t str, char *result);
1906 
1907 
1908 
1909 /***********************************************************************
1910 ** Functions for managing serialized forms and bounding boxes.
1911 */
1912 
1916 extern int lwgeom_check_geodetic(const LWGEOM *geom);
1917 
1921 extern int lwgeom_nudge_geodetic(LWGEOM *geom);
1922 
1926 extern int lwgeom_force_geodetic(LWGEOM *geom);
1927 
1931 extern void lwgeom_set_geodetic(LWGEOM *geom, int value);
1932 
1939 extern int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox);
1940 
1946 extern int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox);
1947 
1952 extern int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox);
1953 
1957 extern int ptarray_calculate_gbox_geodetic(const POINTARRAY *pa, GBOX *gbox);
1958 
1962 extern int ptarray_calculate_gbox_cartesian(const POINTARRAY *pa, GBOX *gbox );
1963 
1967 int gbox_pt_outside(const GBOX *gbox, POINT2D *pt_outside);
1968 
1973 extern GBOX* gbox_new(lwflags_t flags);
1974 
1979 extern void gbox_init(GBOX *gbox);
1980 
1984 extern int gbox_merge(const GBOX *new_box, GBOX *merged_box);
1985 
1989 extern int gbox_union(const GBOX *g1, const GBOX *g2, GBOX *gout);
1990 
1994 extern void gbox_expand(GBOX *g, double d);
1995 
1999 extern void gbox_expand_xyzm(GBOX *g, double dx, double dy, double dz, double dm);
2000 
2004 extern int gbox_init_point3d(const POINT3D *p, GBOX *gbox);
2005 
2009 extern int gbox_merge_point3d(const POINT3D *p, GBOX *gbox);
2010 
2014 extern int gbox_contains_point3d(const GBOX *gbox, const POINT3D *pt);
2015 
2019 extern char* gbox_to_string(const GBOX *gbox);
2020 
2024 extern GBOX* gbox_copy(const GBOX *gbox);
2025 
2029 extern GBOX* gbox_from_string(const char *str);
2030 
2034 extern int gbox_overlaps(const GBOX *g1, const GBOX *g2);
2035 
2039 extern int gbox_overlaps_2d(const GBOX *g1, const GBOX *g2);
2040 
2044 extern int gbox_contains_2d(const GBOX *g1, const GBOX *g2);
2045 
2049 extern void gbox_duplicate(const GBOX *original, GBOX *duplicate);
2050 
2055 extern size_t gbox_serialized_size(lwflags_t flags);
2056 
2060 extern int gbox_same(const GBOX *g1, const GBOX *g2);
2061 
2065 extern int gbox_same_2d(const GBOX *g1, const GBOX *g2);
2066 
2071 extern int gbox_same_2d_float(const GBOX *g1, const GBOX *g2);
2072 
2079 extern void gbox_float_round(GBOX *gbox);
2080 
2084 extern int gbox_is_valid(const GBOX *gbox);
2085 
2089 extern uint64_t gbox_get_sortable_hash(const GBOX *g, const int32_t srid);
2090 
2094 extern uint64_t gserialized_get_sortable_hash(const GSERIALIZED *g);
2095 
2100 extern int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m);
2101 
2109 #define LW_PARSER_CHECK_MINPOINTS 1
2110 #define LW_PARSER_CHECK_ODD 2
2111 #define LW_PARSER_CHECK_CLOSURE 4
2112 #define LW_PARSER_CHECK_ZCLOSURE 8
2113 
2114 #define LW_PARSER_CHECK_NONE 0
2115 #define LW_PARSER_CHECK_ALL (LW_PARSER_CHECK_MINPOINTS | LW_PARSER_CHECK_ODD | LW_PARSER_CHECK_CLOSURE)
2116 
2122 {
2123  const char *wkinput; /* Copy of pointer to input WKT/WKB */
2124  uint8_t *serialized_lwgeom; /* Pointer to serialized LWGEOM */
2125  size_t size; /* Size of serialized LWGEOM in bytes */
2126  LWGEOM *geom; /* Pointer to LWGEOM struct */
2127  const char *message; /* Error/warning message */
2128  int errcode; /* Error/warning number */
2129  int errlocation; /* Location of error */
2130  int parser_check_flags; /* Bitmask of validity checks run during this parse */
2131 }
2133 
2134 /*
2135  * Parser error messages (these must match the message array in lwgparse.c)
2136  */
2137 #define PARSER_ERROR_MOREPOINTS 1
2138 #define PARSER_ERROR_ODDPOINTS 2
2139 #define PARSER_ERROR_UNCLOSED 3
2140 #define PARSER_ERROR_MIXDIMS 4
2141 #define PARSER_ERROR_INVALIDGEOM 5
2142 #define PARSER_ERROR_INVALIDWKBTYPE 6
2143 #define PARSER_ERROR_INCONTINUOUS 7
2144 #define PARSER_ERROR_TRIANGLEPOINTS 8
2145 #define PARSER_ERROR_LESSPOINTS 9
2146 #define PARSER_ERROR_OTHER 10
2147 
2148 
2149 
2150 /*
2151  * Unparser result structure: returns the result of attempting to convert LWGEOM to (E)WKT/(E)WKB
2152  */
2154 {
2155  uint8_t *serialized_lwgeom; /* Copy of pointer to input serialized LWGEOM */
2156  char *wkoutput; /* Pointer to WKT or WKB output */
2157  size_t size; /* Size of serialized LWGEOM in bytes */
2158  const char *message; /* Error/warning message */
2159  int errlocation; /* Location of error */
2160 }
2162 
2163 /*
2164  * Unparser error messages (these must match the message array in lwgunparse.c)
2165  */
2166 #define UNPARSER_ERROR_MOREPOINTS 1
2167 #define UNPARSER_ERROR_ODDPOINTS 2
2168 #define UNPARSER_ERROR_UNCLOSED 3
2169 
2170 
2171 /*
2172 ** Variants available for WKB and WKT output types
2173 */
2174 
2175 #define WKB_ISO 0x01
2176 #define WKB_SFSQL 0x02
2177 #define WKB_EXTENDED 0x04
2178 #define WKB_NDR 0x08
2179 #define WKB_XDR 0x10
2180 #define WKB_HEX 0x20
2181 #define WKB_NO_NPOINTS 0x40 /* Internal use only */
2182 #define WKB_NO_SRID 0x80 /* Internal use only */
2183 
2184 #define WKT_ISO 0x01
2185 #define WKT_SFSQL 0x02
2186 #define WKT_EXTENDED 0x04
2187 
2188 
2189 /*
2190 ** Variants available for TWKB
2191 */
2192 #define TWKB_BBOX 0x01 /* User wants bboxes */
2193 #define TWKB_SIZE 0x02 /* User wants sizes */
2194 #define TWKB_ID 0x04 /* User wants id */
2195 #define TWKB_NO_TYPE 0x10 /* No type because it is a sub geometry */
2196 #define TWKB_NO_ID 0x20 /* No ID because it is a subgeometry */
2197 #define TWKB_DEFAULT_PRECISION 0 /* Aim for 1m (or ft) rounding by default */
2198 
2199 /*
2200 ** New parsing and unparsing functions.
2201 */
2202 
2209 extern char* lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out);
2210 
2216 extern lwvarlena_t* lwgeom_to_wkt_varlena(const LWGEOM *geom, uint8_t variant, int precision);
2217 
2223 extern uint8_t* lwgeom_to_wkb_buffer(const LWGEOM *geom, uint8_t variant);
2224 extern lwvarlena_t* lwgeom_to_wkb_varlena(const LWGEOM *geom, uint8_t variant);
2225 
2232 extern char* lwgeom_to_hexwkb_buffer(const LWGEOM *geom, uint8_t variant);
2233 extern lwvarlena_t* lwgeom_to_hexwkb_varlena(const LWGEOM *geom, uint8_t variant);
2234 
2238 extern char *lwgeom_to_ewkt(const LWGEOM *lwgeom);
2239 
2245 extern LWGEOM* lwgeom_from_wkb(const uint8_t *wkb, const size_t wkb_size, const char check);
2246 
2251 extern LWGEOM* lwgeom_from_wkt(const char *wkt, const char check);
2252 
2256 extern LWGEOM* lwgeom_from_hexwkb(const char *hexwkb, const char check);
2257 
2258 extern uint8_t* bytes_from_hexbytes(const char *hexbuf, size_t hexsize);
2259 
2260 extern char* hexbytes_from_bytes(const uint8_t *bytes, size_t size);
2261 
2262 /*
2263 * WKT detailed parsing support
2264 */
2265 extern int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags);
2266 void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result);
2267 void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result);
2268 
2269 
2270 /* Memory management */
2271 extern void *lwalloc(size_t size);
2272 extern void *lwrealloc(void *mem, size_t size);
2273 extern void lwfree(void *mem);
2274 
2275 /* Utilities */
2276 extern char *lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection);
2277 
2278 /*
2279 * TWKB functions
2280 */
2281 
2287 extern LWGEOM* lwgeom_from_twkb(const uint8_t *twkb, size_t twkb_size, char check);
2288 
2294 extern lwvarlena_t* lwgeom_to_twkb(const LWGEOM *geom, uint8_t variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m);
2295 
2296 extern lwvarlena_t* lwgeom_to_twkb_with_idlist(const LWGEOM *geom, int64_t *idlist, uint8_t variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m);
2297 
2310 extern void lwgeom_trim_bits_in_place(LWGEOM *geom, int32_t prec_x, int32_t prec_y, int32_t prec_z, int32_t prec_m);
2311 
2312 extern LWGEOM* lwgeom_boundary(LWGEOM* lwgeom);
2313 
2314 /*******************************************************************************
2315  * SQLMM internal functions
2316  ******************************************************************************/
2317 
2321 int lwgeom_has_arc(const LWGEOM *geom);
2327 int lwgeom_type_arc(const LWGEOM *geom);
2331 LWGEOM *lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad);
2336 LWGEOM *lwgeom_unstroke(const LWGEOM *geom);
2337 
2342 typedef enum {
2365 
2366 typedef enum {
2373 
2394 
2403 extern LWGEOM* lwcurve_linearize(const LWGEOM *geom, double tol, LW_LINEARIZE_TOLERANCE_TYPE type, int flags);
2404 
2405 /*******************************************************************************
2406  * GEOS proxy functions on LWGEOM
2407  ******************************************************************************/
2408 
2410 const char* lwgeom_geos_version(void);
2411 const char* lwgeom_geos_compiled_version(void);
2412 
2414 LWGEOM* lwgeom_geos_noop(const LWGEOM *geom) ;
2415 
2416 LWGEOM *lwgeom_normalize(const LWGEOM *geom);
2417 LWGEOM *lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2);
2418 LWGEOM *lwgeom_intersection_prec(const LWGEOM *geom1, const LWGEOM *geom2, double gridSize);
2419 LWGEOM *lwgeom_difference(const LWGEOM *geom1, const LWGEOM *geom2);
2420 LWGEOM *lwgeom_difference_prec(const LWGEOM *geom1, const LWGEOM *geom2, double gridSize);
2421 LWGEOM *lwgeom_symdifference(const LWGEOM* geom1, const LWGEOM* geom2);
2422 LWGEOM *lwgeom_symdifference_prec(const LWGEOM* geom1, const LWGEOM* geom2, double gridSize);
2423 LWGEOM *lwgeom_pointonsurface(const LWGEOM* geom);
2424 LWGEOM *lwgeom_reduceprecision(const LWGEOM* geom, double gridSize);
2425 LWGEOM *lwgeom_centroid(const LWGEOM* geom);
2426 LWGEOM *lwgeom_union(const LWGEOM *geom1, const LWGEOM *geom2);
2427 LWGEOM *lwgeom_union_prec(const LWGEOM *geom1, const LWGEOM *geom2, double gridSize);
2428 LWGEOM *lwgeom_linemerge(const LWGEOM *geom1);
2429 LWGEOM *lwgeom_linemerge_directed(const LWGEOM *geom1, int directed);
2430 LWGEOM *lwgeom_unaryunion(const LWGEOM *geom1);
2431 LWGEOM *lwgeom_unaryunion_prec(const LWGEOM *geom1, double gridSize);
2432 LWGEOM *lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1);
2433 LWCOLLECTION *lwgeom_subdivide(const LWGEOM *geom, uint32_t maxvertices);
2434 LWCOLLECTION *lwgeom_subdivide_prec(const LWGEOM *geom, uint32_t maxvertices, double gridSize);
2435 
2443 LWGEOM* lwgeom_snap(const LWGEOM* geom1, const LWGEOM* geom2, double tolerance);
2444 
2445 /*
2446  * Return the set of paths shared between two linear geometries,
2447  * and their direction (same or opposite).
2448  *
2449  * @param geom1 a lineal geometry
2450  * @param geom2 another lineal geometry
2451  */
2452 LWGEOM* lwgeom_sharedpaths(const LWGEOM* geom1, const LWGEOM* geom2);
2453 
2454 /*
2455  * An offset curve against the input line.
2456  *
2457  * @param geom a lineal geometry or collection of them
2458  * @param size offset distance. Offset left if negative and right if positive
2459  * @param quadsegs number of quadrature segments in curves (try 8)
2460  * @param joinStyle (1 = round, 2 = mitre, 3 = bevel)
2461  * @param mitreLimit (try 5.0)
2462  * @return derived geometry (linestring or multilinestring)
2463  *
2464  */
2465 LWGEOM* lwgeom_offsetcurve(const LWGEOM *geom, double size, int quadsegs, int joinStyle, double mitreLimit);
2466 
2467 /*
2468  * Return true if the input geometry is "simple" as per OGC defn.
2469  *
2470  * @return 1 if simple, 0 if non-simple, -1 on exception (lwerror is called
2471  * in that case)
2472  */
2473 int lwgeom_is_simple(const LWGEOM *lwgeom);
2474 
2475 
2476 /*******************************************************************************
2477  * PROJ4-dependent extra functions on LWGEOM
2478  ******************************************************************************/
2479 
2480 int lwgeom_transform_from_str(LWGEOM *geom, const char* instr, const char* outstr);
2486 int lwgeom_transform(LWGEOM *geom, LWPROJ* pj);
2487 int ptarray_transform(POINTARRAY *pa, LWPROJ* pj);
2488 int box3d_transform(GBOX *box, LWPROJ *pj);
2489 
2495 LWPROJ *lwproj_from_str(const char* str_in, const char* str_out);
2496 
2507 int lwgeom_transform_pipeline(LWGEOM *geom, const char* pipeline, bool is_forward);
2508 
2520 LWPROJ *lwproj_from_str_pipeline(const char* str_pipeline, bool is_forward);
2521 
2522 
2523 /*******************************************************************************
2524  * GEOS-dependent extra functions on LWGEOM
2525  ******************************************************************************/
2526 
2534 LWGEOM* lwgeom_buildarea(const LWGEOM *geom) ;
2535 
2540 LWGEOM* lwgeom_make_valid_params(LWGEOM* geom, char *make_valid_params);
2541 
2542 /*
2543  * Split (multi)polygon by line; (multi)line by (multi)line,
2544  * (multi)point or (multi)polygon boundary.
2545  *
2546  * Collections are accepted as first argument.
2547  * Returns all obtained pieces as a collection.
2548  */
2549 LWGEOM* lwgeom_split(const LWGEOM* lwgeom_in, const LWGEOM* blade_in);
2550 
2551 /*
2552  * Fully node a set of linestrings, using the least nodes preserving
2553  * all the input ones.
2554  */
2555 LWGEOM* lwgeom_node(const LWGEOM* lwgeom_in);
2556 
2566 LWGEOM* lwgeom_delaunay_triangulation(const LWGEOM *geom, double tolerance, int32_t edgeOnly);
2567 
2568 
2578 LWGEOM* lwgeom_voronoi_diagram(const LWGEOM* g, const GBOX* env, double tolerance, int output_edges);
2579 
2580 #if POSTGIS_GEOS_VERSION >= 31100
2591 LWGEOM* lwgeom_concavehull(const LWGEOM* geom, double ratio, uint32_t allow_holes);
2592 
2603 LWGEOM*
2604 lwgeom_simplify_polygonal(const LWGEOM* geom, double vertex_fraction, uint32_t is_outer);
2605 
2613 
2614 #endif
2615 
2625 int * lwgeom_cluster_kmeans(const LWGEOM **geoms, uint32_t n, uint32_t k, double max_radius);
2626 
2627 #include "lwinline.h"
2628 
2629 #endif /* !defined _LIBLWGEOM_H */
2630 
static uint8_t variant
Definition: cu_in_twkb.c:26
static uint8_t precision
Definition: cu_in_twkb.c:25
char * s
Definition: cu_in_wkt.c:23
char * r
Definition: cu_in_wkt.c:24
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
LWPOINT * lwpoint_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwpoint.c:151
void deparse_hex(uint8_t str, char *result)
Convert a char into a human readable hex digit.
Definition: lwgeom_api.c:617
LWPOLY * lwpoly_construct_circle(int32_t srid, double x, double y, double radius, uint32_t segments_per_quarter, char exterior)
Definition: lwpoly.c:120
int lwgeom_is_closed(const LWGEOM *geom)
Return true or false depending on whether a geometry is a linear feature that closes on itself.
Definition: lwgeom.c:1053
POINTARRAY * ptarray_construct_reference_data(char hasz, char hasm, uint32_t npoints, uint8_t *ptlist)
Construct a new POINTARRAY, referencing to the data from ptlist.
Definition: ptarray.c:283
int ptarray_remove_point(POINTARRAY *pa, uint32_t where)
Remove a point from an existing POINTARRAY.
Definition: ptarray.c:251
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
Definition: lwgeom.c:707
LW_LINEARIZE_TOLERANCE_TYPE
Semantic of the tolerance argument passed to lwcurve_linearize.
Definition: liblwgeom.h:2342
@ LW_LINEARIZE_TOLERANCE_TYPE_MAX_ANGLE
Tolerance expresses the maximum angle between the radii generating approximation line vertices,...
Definition: liblwgeom.h:2363
@ LW_LINEARIZE_TOLERANCE_TYPE_SEGS_PER_QUAD
Tolerance expresses the number of segments to use for each quarter of circle (quadrant).
Definition: liblwgeom.h:2348
@ LW_LINEARIZE_TOLERANCE_TYPE_MAX_DEVIATION
Tolerance expresses the maximum distance between an arbitrary point on the curve and the closest poin...
Definition: liblwgeom.h:2355
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
Definition: lwpoint.c:57
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:179
LWGEOM * lwcompound_as_lwgeom(const LWCOMPOUND *obj)
Definition: lwgeom.c:324
LWPOINT * lwline_interpolate_point_3d(const LWLINE *line, double distance)
Interpolate one point along a line in 3D.
Definition: lwline.c:605
LWPOINT * lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, uint32_t where)
Definition: lwcircstring.c:286
LWCURVEPOLY * lwcurvepoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, LWGEOM **geoms)
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
Definition: lwgeom.c:964
POINTARRAY * ptarray_construct_copy_data(char hasz, char hasm, uint32_t npoints, const uint8_t *ptlist)
Construct a new POINTARRAY, copying in the data from ptlist.
Definition: ptarray.c:297
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
Definition: lwgeom_api.c:108
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:339
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
Simplification.
Definition: lwgeom.c:1870
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
Definition: lwgeom.c:591
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
Definition: gbox.c:164
int gbox_union(const GBOX *g1, const GBOX *g2, GBOX *gout)
Update the output GBOX to be large enough to include both inputs.
Definition: gbox.c:135
LWGEOM * lwgeom_centroid(const LWGEOM *geom)
void lwgeom_request_interrupt(void)
Request interruption of any running code.
Definition: lwgeom_api.c:663
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:309
int lwgeom_ndims(const LWGEOM *geom)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: lwgeom.c:955
uint32_t lwtype_get_collectiontype(uint8_t type)
Given an lwtype number, what homogeneous collection can hold it?
Definition: lwgeom.c:1131
LWORD_T
Ordinate names.
Definition: liblwgeom.h:130
@ LWORD_Z
Definition: liblwgeom.h:133
@ LWORD_M
Definition: liblwgeom.h:134
@ LWORD_Y
Definition: liblwgeom.h:132
@ LWORD_X
Definition: liblwgeom.h:131
void lwgeom_cancel_interrupt(void)
Cancel any interruption request.
Definition: lwgeom_api.c:667
void(*) typedef void(*) voi lwgeom_set_handlers)(lwallocator allocator, lwreallocator reallocator, lwfreeor freeor, lwreporter errorreporter, lwreporter noticereporter)
Install custom memory management and error handling functions you want your application to use.
size_t gbox_serialized_size(lwflags_t flags)
Return the number of bytes necessary to hold a GBOX of this dimension in serialized form.
Definition: gbox.c:440
LWGEOM * lwgeom_make_valid_params(LWGEOM *geom, char *make_valid_params)
void lwmpoly_release(LWMPOLY *lwpoly)
Definition: lwmpoly.c:34
int ptarray_closest_segment_2d(const POINTARRAY *pa, const POINT2D *qp, double *dist)
Definition: ptarray.c:1320
lwvarlena_t * lwgeom_to_kml2(const LWGEOM *geom, int precision, const char *prefix)
Definition: lwout_kml.c:44
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
Definition: lwgeom.c:927
LWGEOM * lwgeom_geos_noop(const LWGEOM *geom)
Convert an LWGEOM to a GEOS Geometry and convert back – for debug only.
void(*) typedef void(* lwdebuglogger)(int level, const char *fmt, va_list ap) __attribute__((format(printf
Definition: liblwgeom.h:247
void gbox_duplicate(const GBOX *original, GBOX *duplicate)
Copy the values of original GBOX into duplicate.
Definition: gbox.c:433
LWPOINT * lwpoint_make4d(int32_t srid, double x, double y, double z, double m)
Definition: lwpoint.c:195
LWGEOM * lwgeom_from_geojson(const char *geojson, char **srs)
Create an LWGEOM object from a GeoJSON representation.
Definition: lwin_geojson.c:411
LWGEOM * lwgeom_locate_along(const LWGEOM *lwin, double m, double offset)
Determine the location(s) along a measured line where m occurs and return as a multipoint.
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
Definition: measures.c:2398
double ptarray_locate_point_spheroid(const POINTARRAY *pa, const POINT4D *p4d, const SPHEROID *s, double tolerance, double *mindistout, POINT4D *proj4d)
Locate a point along the point array defining a geographic line.
int lwgeom_simplify_in_place(LWGEOM *igeom, double dist, int preserve_collapsed)
Definition: lwgeom.c:1737
LWGEOM * geography_interpolate_points(const LWLINE *line, double length_fraction, const SPHEROID *s, char repeat)
Interpolate a point along a geographic line.
LWGEOM * lwgeom_delaunay_triangulation(const LWGEOM *geom, double tolerance, int32_t edgeOnly)
Take vertices of a geometry and build a delaunay triangulation on them.
LWGEOM * lwgeom_closest_point(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures.c:52
GBOX * gbox_copy(const GBOX *gbox)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: gbox.c:426
double lwgeom_maxdistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing max distance calculation.
Definition: measures.c:165
int gbox_same_2d(const GBOX *g1, const GBOX *g2)
Check if 2 given GBOX are the same in x and y.
Definition: gbox.c:179
int lwgeom_startpoint(const LWGEOM *lwgeom, POINT4D *pt)
Definition: lwgeom.c:2135
int ptarray_is_closed(const POINTARRAY *pa)
Check for ring closure using whatever dimensionality is declared on the pointarray.
Definition: ptarray.c:700
int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret)
Compute the azimuth of segment AB in radians.
Definition: measures.c:2462
GBOX * box3d_to_gbox(const BOX3D *b3d)
Definition: gbox.c:80
LWPOINT * lwgeom_project_spheroid(const LWPOINT *r, const SPHEROID *spheroid, double distance, double azimuth)
Calculate the location of a point on a spheroid, give a start point, bearing and distance.
Definition: lwgeodetic.c:2105
void() lwinterrupt_callback()
Install a callback to be called periodically during algorithm execution.
Definition: liblwgeom.h:291
LWGEOM * lwgeom_node(const LWGEOM *lwgeom_in)
LWPOINT * lwpoint_make2d(int32_t srid, double x, double y)
Definition: lwpoint.c:163
void lwmpoint_free(LWMPOINT *mpt)
Definition: lwmpoint.c:72
struct struct_lwgeom_unparser_result LWGEOM_UNPARSER_RESULT
void gbox_expand(GBOX *g, double d)
Move the box minimums down and the maximums up by the distance provided.
Definition: gbox.c:97
LWGEOM * lwgeom_symdifference(const LWGEOM *geom1, const LWGEOM *geom2)
LWGEOM * lwgeom_segmentize_sphere(const LWGEOM *lwg_in, double max_seg_length)
Derive a new geometry with vertices added to ensure no vertex is more than max_seg_length (in radians...
Definition: lwgeodetic.c:1749
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
Definition: lwiterator.c:242
int ptarray_append_ptarray(POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance)
Append a POINTARRAY, pa2 to the end of an existing POINTARRAY, pa1.
Definition: ptarray.c:177
int gbox_contains_point3d(const GBOX *gbox, const POINT3D *pt)
Return true if the point is inside the gbox.
Definition: gbox.c:247
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
Definition: lwin_wkb.c:858
int ptarray_transform(POINTARRAY *pa, LWPROJ *pj)
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: gserialized.c:126
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:242
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
Definition: lwgeom.c:1547
lwvarlena_t * lwgeom_to_svg(const LWGEOM *geom, int precision, int relative)
Takes a GEOMETRY and returns a SVG representation.
Definition: lwout_svg.c:559
double lwpoint_get_m(const LWPOINT *point)
Definition: lwpoint.c:107
void lwgeom_trim_bits_in_place(LWGEOM *geom, int32_t prec_x, int32_t prec_y, int32_t prec_z, int32_t prec_m)
Trim the bits of an LWGEOM in place, to optimize it for compression.
Definition: lwgeom.c:2539
LWLINE * lwline_segmentize2d(const LWLINE *line, double dist)
Definition: lwline.c:132
LWLINE * lwline_from_ptarray(int32_t srid, uint32_t npoints, LWPOINT **points)
Definition: lwline.c:228
void lwpoint_free(LWPOINT *pt)
Definition: lwpoint.c:213
void lwgeom_longitude_shift(LWGEOM *lwgeom)
Definition: lwgeom.c:1008
double lwgeom_distance_spheroid(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2, const SPHEROID *spheroid, double tolerance)
Calculate the geodetic distance from lwgeom1 to lwgeom2 on the spheroid.
Definition: lwgeodetic.c:2204
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
Definition: gbox.c:774
POINTARRAY * ptarray_substring(POINTARRAY *pa, double d1, double d2, double tolerance)
@d1 start location (distance from start / total distance) @d2 end location (distance from start / tot...
Definition: ptarray.c:1079
LWCOLLECTION * lwcollection_segmentize2d(const LWCOLLECTION *coll, double dist)
Definition: lwcollection.c:251
double distance3d_pt_seg(const POINT3D *p, const POINT3D *A, const POINT3D *B)
void lwpoint_release(LWPOINT *lwpoint)
Definition: lwpoint.c:256
int ptarray_closest_vertex_2d(const POINTARRAY *pa, const POINT2D *qp, double *dist)
Definition: ptarray.c:1353
int lwgeom_transform(LWGEOM *geom, LWPROJ *pj)
Transform (reproject) a geometry in-place.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
int ptarray_is_closed_3d(const POINTARRAY *pa)
Definition: ptarray.c:727
LWGEOM * lwgeom_concavehull(const LWGEOM *geom, double ratio, uint32_t allow_holes)
Take a geometry and build the concave hull.
LWGEOM * lwcurve_linearize(const LWGEOM *geom, double tol, LW_LINEARIZE_TOLERANCE_TYPE type, int flags)
Definition: lwstroke.c:838
char * hexbytes_from_bytes(const uint8_t *bytes, size_t size)
Definition: lwout_wkb.c:40
double lwgeom_maxdistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling 3d max distance calculations and dfullywithin calculations.
Definition: measures3d.c:310
LWGEOM * lwgeom_split(const LWGEOM *lwgeom_in, const LWGEOM *blade_in)
int gbox_pt_outside(const GBOX *gbox, POINT2D *pt_outside)
Calculate a spherical point that falls outside the geocentric gbox.
Definition: lwgeodetic.c:1558
void lwmpoly_free(LWMPOLY *mpoly)
Definition: lwmpoly.c:53
LWGEOM * lwgeom_filter_m(LWGEOM *geom, double min, double max, int returnm)
Definition: lwmval.c:221
LWPOINT * lwpoint_make3dm(int32_t srid, double x, double y, double m)
Definition: lwpoint.c:184
uint32_t gserialized_get_version(const GSERIALIZED *g)
Return the serialization version.
Definition: gserialized.c:42
LWPROJ * lwproj_from_str_pipeline(const char *str_pipeline, bool is_forward)
Allocate a new LWPROJ containing the reference to the PROJ's PJ using a PROJ pipeline definition:
void(* lwfreeor)(void *mem)
Definition: liblwgeom.h:244
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
Definition: lwgeom.c:380
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
Definition: lwcurvepoly.c:52
LWTIN * lwtin_add_lwtriangle(LWTIN *mobj, const LWTRIANGLE *obj)
Definition: lwtin.c:34
LWGEOM * lwgeom_unstroke(const LWGEOM *geom)
Convert linearized type into arc type, de-linearizing the strokes where possible.
Definition: lwstroke.c:1271
double lwgeom_perimeter_2d(const LWGEOM *geom)
Definition: lwgeom.c:1930
int lwpointiterator_next(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assign the next point in the iterator to p, and advances the iterator to the next point.
Definition: lwiterator.c:210
LWPOINT * lwcompound_get_lwpoint(const LWCOMPOUND *lwcmp, uint32_t where)
Definition: lwcompound.c:213
lwvarlena_t * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
Definition: lwalgorithm.c:860
int lwpoint_inside_circle(const LWPOINT *p, double cx, double cy, double rad)
Definition: lwgeom.c:662
LWGEOM * lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2)
void interpolate_point4d(const POINT4D *A, const POINT4D *B, POINT4D *I, double F)
Find interpolation point I between point A and point B so that the len(AI) == len(AB)*F and I falls o...
Definition: lwgeom_api.c:649
void lwtin_free(LWTIN *tin)
Definition: lwtin.c:39
LWGEOM * lwgeom_from_twkb(const uint8_t *twkb, size_t twkb_size, char check)
WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory...
Definition: lwin_twkb.c:654
LWGEOM * lwcollection_getsubgeom(LWCOLLECTION *col, int gnum)
Definition: lwcollection.c:114
POINTARRAY * ptarray_removePoint(POINTARRAY *pa, uint32_t where)
Remove a point from a pointarray.
Definition: ptarray.c:574
int lwpoint_getPoint3dm_p(const LWPOINT *point, POINT3DM *out)
Definition: lwpoint.c:52
void printLWPOLY(LWPOLY *poly)
Definition: lwpoly.c:193
lwvarlena_t * lwgeom_to_geojson(const LWGEOM *geo, const char *srs, int precision, int has_bbox)
Takes a GEOMETRY and returns a GeoJson representation.
LWGEOM * lwmline_as_lwgeom(const LWMLINE *obj)
Definition: lwgeom.c:299
LWGEOM * lwgeom_segmentize2d(const LWGEOM *line, double dist)
Definition: lwgeom.c:771
LWGEOM * lwgeom_offsetcurve(const LWGEOM *geom, double size, int quadsegs, int joinStyle, double mitreLimit)
void lwgeom_set_debuglogger(lwdebuglogger debuglogger)
Definition: lwutil.c:171
double lwgeom_interpolate_point(const LWGEOM *lwin, const LWPOINT *lwpt)
Find the measure value at the location on the line closest to the point.
POINT3DM getPoint3dm(const POINTARRAY *pa, uint32_t n)
Definition: lwgeom_api.c:201
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
Definition: lwgeodetic.c:3027
int gbox_merge_point3d(const POINT3D *p, GBOX *gbox)
Update the GBOX to be large enough to include itself and the new point.
Definition: gbox.c:228
lwvarlena_t * lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision)
POINTARRAY * ptarray_addPoint(const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where)
Add a point in a pointarray.
Definition: ptarray.c:522
struct struct_lwgeom_parser_result LWGEOM_PARSER_RESULT
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.
LWGEOM * lwgeom_furthest_line_3d(LWGEOM *lw1, LWGEOM *lw2)
Definition: measures3d.c:82
LWGEOM * lwgeom_closest_point_3d(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures3d.c:88
BOX3D * box3d_from_gbox(const GBOX *gbox)
Definition: gbox.c:53
int gserialized_peek_first_point(const GSERIALIZED *g, POINT4D *out_point)
Pull the first point values of a GSERIALIZED.
Definition: gserialized.c:257
uint16_t lwflags_t
Definition: liblwgeom.h:299
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: gserialized.c:174
LWGEOM * lwmpoint_as_lwgeom(const LWMPOINT *obj)
Definition: lwgeom.c:304
unsigned int geohash_point_as_int(POINT2D *pt)
Definition: lwalgorithm.c:661
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:329
void lwline_release(LWLINE *lwline)
Definition: lwline.c:125
double lwgeom_area_spheroid(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the spheroid.
Definition: lwspheroid.c:647
LWGEOM * lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad)
Convert type with arcs into equivalent linearized type.
Definition: lwstroke.c:871
int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the 2-4D bounding box of a geometry.
Definition: gbox.c:740
int lwgeom_is_trajectory(const LWGEOM *geom)
Return LW_TRUE or LW_FALSE depending on whether or not a geometry is a linestring with measure value ...
Definition: lwgeom.c:2496
int gbox_overlaps(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the GBOX overlaps, LW_FALSE otherwise.
Definition: gbox.c:283
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result)
Definition: lwin_wkt.c:880
LWGEOM * lwgeom_force_sfs(LWGEOM *geom, int version)
Definition: lwgeom.c:849
char * lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection)
Definition: lwutil.c:268
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
LWGEOM * lwgeom_furthest_point(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures.c:58
int lwline_crossing_direction(const LWLINE *l1, const LWLINE *l2)
Given two lines, characterize how (and if) they cross each other.
Definition: lwalgorithm.c:459
int lwgeom_is_simple(const LWGEOM *lwgeom)
double lwpoint_get_x(const LWPOINT *point)
Definition: lwpoint.c:63
LWGEOM * lwgeom_snap(const LWGEOM *geom1, const LWGEOM *geom2, double tolerance)
Snap vertices and segments of a geometry to another using a given tolerance.
int lwpointiterator_peek(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assigns the next point in the iterator to p.
Definition: lwiterator.c:193
void lwtin_release(LWTIN *lwtin)
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:647
void printPA(POINTARRAY *pa)
Definition: lwgeom_api.c:440
LWGEOM * lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
Create an LWGEOM object from an Encoded Polyline representation.
int lwgeom_check_geodetic(const LWGEOM *geom)
Check that coordinates of LWGEOM are all within the geodetic range (-180, -90, 180,...
Definition: lwgeodetic.c:3130
char * lwgeom_to_hexwkb_buffer(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:845
lwvarlena_t * lwgeom_to_twkb(const LWGEOM *geom, uint8_t variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m)
Definition: lwout_twkb.c:636
LWGEOM * lwgeom_difference(const LWGEOM *geom1, const LWGEOM *geom2)
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition: lwgeom.c:529
GBOX * gbox_new(lwflags_t flags)
Create a new gbox with the dimensionality indicated by the flags.
Definition: gbox.c:32
const char * lwgeom_geos_version(void)
Return GEOS version string (not to be freed)
uint8_t * bytes_from_hexbytes(const char *hexbuf, size_t hexsize)
Definition: lwin_wkb.c:92
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
Definition: lwmline.c:46
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
Definition: lwiterator.c:267
int gbox_overlaps_2d(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the GBOX overlaps on the 2d plane, LW_FALSE otherwise.
Definition: gbox.c:323
lwvarlena_t * lwgeom_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:920
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
Definition: lwpoly.c:247
double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located)
Definition: ptarray.c:1386
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: gserialized.c:152
LWMPOLY * lwgeom_as_lwmpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:260
int lwgeom_remove_repeated_points_in_place(LWGEOM *in, double tolerance)
Definition: lwgeom.c:1594
LWGEOM * lwgeom_force_3dm(const LWGEOM *geom, double mval)
Definition: lwgeom.c:805
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition: lwgeom_api.c:342
int lwgeom_has_srid(const LWGEOM *geom)
Return true or false depending on whether a geometry has a valid SRID set.
Definition: lwgeom.c:1404
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: gbox.c:40
int box3d_transform(GBOX *box, LWPROJ *pj)
LWGEOM * lwgeom_force_4d(const LWGEOM *geom, double zval, double mval)
Definition: lwgeom.c:811
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition: ptarray.c:51
double lwgeom_length(const LWGEOM *geom)
Definition: lwgeom.c:1952
LWGEOM * lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance)
Definition: lwgeom.c:1471
void gbox_expand_xyzm(GBOX *g, double dx, double dy, double dz, double dm)
Move the box minimums down and the maximums up by the distances provided.
Definition: gbox.c:115
const char * lwgeom_version(void)
Return lwgeom version string (not to be freed)
Definition: lwgeom_api.c:39
const float * gserialized_get_float_box_p(const GSERIALIZED *g, size_t *ndims)
Access to the float bounding box, if there is one.
Definition: gserialized.c:248
void gserialized_set_srid(GSERIALIZED *g, int32_t srid)
Write the SRID into the serialized form (it is packed into three bytes so this is a handy function).
Definition: gserialized.c:138
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
Definition: lwgeom.c:1208
LWMLINE * lwmline_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwmline.c:38
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *box)
Pull a GBOX from the header of a GSERIALIZED, if one is available.
Definition: gserialized.c:65
LWGEOM * lwgeom_reverse(const LWGEOM *lwgeom)
Definition: lwgeom.c:94
LWMPOINT * lwpoly_to_points(const LWPOLY *poly, uint32_t npoints, int32_t seed)
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)
Definition: ptarray.c:1832
LWGEOM * lwpsurface_as_lwgeom(const LWPSURFACE *obj)
Definition: lwgeom.c:289
LWGEOM * lwgeom_force_3dz(const LWGEOM *geom, double zval)
Definition: lwgeom.c:799
int lwgeom_covers_lwgeom_sphere(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
Calculate covers predicate for two lwgeoms on the sphere.
Definition: lwgeodetic.c:2430
LWGEOM * geography_substring(const LWLINE *line, const SPHEROID *s, double from, double to, double tolerance)
Return the part of a line between two fractional locations.
LWPOINT * lwgeom_project_spheroid_lwpoint(const LWPOINT *from, const LWPOINT *to, const SPHEROID *spheroid, double distance)
Calculate the location of a point on a spheroid, give a start point, end point and distance.
Definition: lwgeodetic.c:2154
lwvarlena_t * lwgeom_extent_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix)
Definition: lwout_gml.c:1081
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:934
lwvarlena_t * lwgeom_extent_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:1063
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)
Definition: lwgeom.c:294
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:1105
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:565
void printBOX3D(BOX3D *b)
Definition: lwgeom_api.c:434
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
Definition: lwgeom.c:682
int lwgeom_isfinite(const LWGEOM *lwgeom)
Check if a LWGEOM has any non-finite (NaN or Inf) coordinates.
Definition: lwgeom.c:2681
LWPOINT * lwcompound_get_startpoint(const LWCOMPOUND *lwcmp)
Definition: lwcompound.c:248
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
Utility function to get type number from string.
Definition: lwutil.c:489
void lwgeom_scale(LWGEOM *geom, const POINT4D *factors)
Definition: lwgeom.c:2051
LWTRIANGLE * lwtriangle_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwtriangle.c:58
LWTRIANGLE * lwtriangle_from_lwline(const LWLINE *shell)
Definition: lwtriangle.c:153
uint8_t * lwgeom_to_wkb_buffer(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:815
char * lwgeom_summary(const LWGEOM *lwgeom, int offset)
Definition: lwgeom_debug.c:166
double lwgeom_tcpa(const LWGEOM *g1, const LWGEOM *g2, double *mindist)
Find the time of closest point of approach.
void lwmline_release(LWMLINE *lwline)
Definition: lwmline.c:32
LWGEOM * lwgeom_pointonsurface(const LWGEOM *geom)
LWBOUNDINGCIRCLE * lwgeom_calculate_mbc(const LWGEOM *g)
int gbox_init_point3d(const POINT3D *p, GBOX *gbox)
Initialize a GBOX using the values of the point.
Definition: gbox.c:239
LWGEOM * lwgeom_sharedpaths(const LWGEOM *geom1, const LWGEOM *geom2)
int pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring)
Definition: lwalgorithm.c:279
LWPOLY * lwpoly_construct_rectangle(char hasz, char hasm, POINT4D *p1, POINT4D *p2, POINT4D *p3, POINT4D *p4)
Definition: lwpoly.c:80
LWTRIANGLE * lwgeom_as_lwtriangle(const LWGEOM *lwgeom)
Definition: lwgeom.c:224
void(* lwreporter)(const char *fmt, va_list ap) __attribute__((format(printf
Definition: liblwgeom.h:245
LWMPOINT * lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
Definition: lwmpoint.c:45
LWLINE * lwline_addpoint(LWLINE *line, LWPOINT *point, uint32_t where)
double lwgeom_area(const LWGEOM *geom)
Definition: lwgeom.c:1885
int lwgeom_type_arc(const LWGEOM *geom)
Geometry type is one of the potentially "arc containing" types (circstring, multicurve,...
Definition: lwstroke.c:89
LWMLINE * lwgeom_as_lwmline(const LWGEOM *lwgeom)
Definition: lwgeom.c:251
LWMPOLY * lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj)
Definition: lwmpoly.c:47
LWGEOM * lwgeom_simplify_polygonal(const LWGEOM *geom, double vertex_fraction, uint32_t is_outer)
Computes a boundary-respecting hull of a polygonal geometry, with hull shape determined by a target p...
LWGEOM * lwgeom_voronoi_diagram(const LWGEOM *g, const GBOX *env, double tolerance, int output_edges)
Take vertices of a geometry and build the Voronoi diagram.
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where)
Insert a point into an existing POINTARRAY.
Definition: ptarray.c:85
LWPOLY * lwpoly_construct_envelope(int32_t srid, double x1, double y1, double x2, double y2)
Definition: lwpoly.c:98
LWPSURFACE * lwpsurface_add_lwpoly(LWPSURFACE *mobj, const LWPOLY *obj)
Definition: lwpsurface.c:33
LWPOINT * lwpoint_project(const LWPOINT *lwpoint1, double distance, double azimuth)
Definition: lwpoint.c:290
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition: lwgeom.c:1246
LWPROJ * lwproj_from_str(const char *str_in, const char *str_out)
Allocate a new LWPROJ containing the reference to the PROJ's PJ If extra_geography_data is true,...
int gserialized_is_geodetic(const GSERIALIZED *gser)
Check if a GSERIALIZED is a geography.
Definition: gserialized.c:196
int ptarray_calculate_gbox_cartesian(const POINTARRAY *pa, GBOX *gbox)
Calculate box (x/y) and add values to gbox.
Definition: gbox.c:601
void printLWTIN(LWTIN *tin)
Definition: lwtin.c:57
LW_LINEARIZE_FLAGS
Definition: liblwgeom.h:2366
@ LW_LINEARIZE_FLAG_SYMMETRIC
Symmetric linearization means that the output vertices would be the same no matter the order of the p...
Definition: liblwgeom.h:2372
@ LW_LINEARIZE_FLAG_RETAIN_ANGLE
Retain angle instructs the engine to try its best to retain the requested angle between generating ra...
Definition: liblwgeom.h:2392
int * lwgeom_cluster_kmeans(const LWGEOM **geoms, uint32_t n, uint32_t k, double max_radius)
Take a list of LWGEOMs and a number of clusters and return an integer array indicating which cluster ...
Definition: lwkmeans.c:321
double distance3d_pt_pt(const POINT3D *p1, const POINT3D *p2)
Definition: measures3d.c:1029
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
Definition: lwgeom_api.c:215
int lwpointiterator_modify_next(LWPOINTITERATOR *s, const POINT4D *p)
Attempts to replace the next point int the iterator with p, and advances the iterator to the next poi...
Definition: lwiterator.c:224
POINTARRAY * lwline_interpolate_points(const LWLINE *line, double length_fraction, char repeat)
Interpolate one or more points along a line.
Definition: lwline.c:528
int lwgeom_dimension(const LWGEOM *geom)
For an LWGEOM, returns 0 for points, 1 for lines, 2 for polygons, 3 for volume, and the max dimension...
Definition: lwgeom.c:1298
LWCOLLECTION * lwgeom_subdivide(const LWGEOM *geom, uint32_t maxvertices)
Definition: lwgeom.c:2488
LWGEOM * lwgeom_chaikin(const LWGEOM *igeom, int n_iterations, int preserve_endpoint)
Definition: lwchaikins.c:182
LWGEOM * lwgeom_difference_prec(const LWGEOM *geom1, const LWGEOM *geom2, double gridSize)
void * lwrealloc(void *mem, size_t size)
Definition: lwutil.c:235
int lwpoint_getPoint3dz_p(const LWPOINT *point, POINT3DZ *out)
Definition: lwpoint.c:47
uint64_t gbox_get_sortable_hash(const GBOX *g, const int32_t srid)
Return a sortable key based on the center point of the GBOX.
Definition: gbox.c:796
LWGEOM * lwgeom_homogenize(const LWGEOM *geom)
Definition: lwhomogenize.c:208
void lwfree(void *mem)
Definition: lwutil.c:242
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition: lwgeom.c:344
double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin calculations.
Definition: measures.c:207
LWGEOM * lwgeom_unaryunion(const LWGEOM *geom1)
LWGEOM * lwgeom_union_prec(const LWGEOM *geom1, const LWGEOM *geom2, double gridSize)
LWGEOM * lwgeom_as_curve(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate CURVE* type.
Definition: lwgeom.c:420
int ptarray_calculate_gbox_geodetic(const POINTARRAY *pa, GBOX *gbox)
Calculate geodetic (x/y/z) box and add values to gbox.
Definition: lwgeodetic.c:2888
LWCOLLECTION * lwcollection_extract(const LWCOLLECTION *col, uint32_t type)
Definition: lwcollection.c:432
LWGEOM * lwgeom_normalize(const LWGEOM *geom)
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1097
LWPOINT * lwpoint_make3dz(int32_t srid, double x, double y, double z)
Definition: lwpoint.c:173
void lwcircstring_free(LWCIRCSTRING *curve)
Definition: lwcircstring.c:97
LWMPOINT * lwmpoint_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwmpoint.c:39
uint64_t gserialized_get_sortable_hash(const GSERIALIZED *g)
Return a sortable key based on gserialized.
Definition: gserialized.c:390
double lwgeom_mindistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling 3d min distance calculations and dwithin calculations.
Definition: measures3d.c:442
int gserialized_fast_gbox_p(const GSERIALIZED *g, GBOX *box)
Pull a GBOX from the header of a GSERIALIZED, if one is available.
Definition: gserialized.c:77
void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2)
Swap ordinate values in every vertex of the geometry.
Definition: lwgeom.c:1478
int lwgeom_transform_from_str(LWGEOM *geom, const char *instr, const char *outstr)
void lwgeom_affine(LWGEOM *geom, const AFFINE *affine)
Definition: lwgeom.c:1997
LWCOLLECTION * lwgeom_clip_to_ordinate_range(const LWGEOM *lwin, char ordinate, double from, double to, double offset)
Given a geometry clip based on the from/to range of one of its ordinates (x, y, z,...
int gserialized_ndims(const GSERIALIZED *gser)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: gserialized.c:207
LWMPOINT * lwmpoly_to_points(const LWMPOLY *mpoly, uint32_t npoints, int32_t seed)
LWGEOM * lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures.c:40
LWGEOM * lwgeom_unaryunion_prec(const LWGEOM *geom1, double gridSize)
uint8_t lwtype_multitype(uint8_t type)
Definition: lwgeom.c:370
LWPOINT * lwpoint_construct(int32_t srid, GBOX *bbox, POINTARRAY *point)
Definition: lwpoint.c:129
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
Definition: lwspheroid.c:39
LWGEOM * lwgeom_boundary(LWGEOM *lwgeom)
Definition: lwgeom.c:2560
#define __attribute__(x)
Definition: liblwgeom.h:228
const char * lwgeom_geos_compiled_version(void)
LWGEOM * lwgeom_buildarea(const LWGEOM *geom)
Take a geometry and return an areal geometry (Polygon or MultiPolygon).
void lwtriangle_free(LWTRIANGLE *triangle)
Definition: lwtriangle.c:69
int lwcurvepoly_add_ring(LWCURVEPOLY *poly, LWGEOM *ring)
Add a ring, allocating extra space if necessary.
Definition: lwcurvepoly.c:71
void *(* lwreallocator)(void *mem, size_t size)
Definition: liblwgeom.h:243
LWCURVEPOLY * lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:206
LWPOINTITERATOR * lwpointiterator_create_rw(LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM* Supports modification of coordinates during iterat...
Definition: lwiterator.c:251
CG_LINE_CROSS_TYPE
The return values of lwline_crossing_direction()
Definition: liblwgeom.h:1657
@ LINE_MULTICROSS_END_RIGHT
Definition: liblwgeom.h:1662
@ LINE_MULTICROSS_END_SAME_FIRST_LEFT
Definition: liblwgeom.h:1663
@ LINE_MULTICROSS_END_LEFT
Definition: liblwgeom.h:1661
@ LINE_CROSS_LEFT
Definition: liblwgeom.h:1659
@ LINE_MULTICROSS_END_SAME_FIRST_RIGHT
Definition: liblwgeom.h:1664
@ LINE_CROSS_RIGHT
Definition: liblwgeom.h:1660
@ LINE_NO_CROSS
Definition: liblwgeom.h:1658
void lwboundingcircle_destroy(LWBOUNDINGCIRCLE *c)
void *(* lwallocator)(size_t size)
Global functions for memory/logging handlers.
Definition: liblwgeom.h:242
void lwcollection_release(LWCOLLECTION *lwcollection)
Definition: lwcollection.c:36
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: gserialized.c:89
GSERIALIZED * gserialized_set_gbox(GSERIALIZED *g, GBOX *gbox)
Copy a new bounding box into an existing gserialized.
Definition: gserialized.c:31
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:59
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
Definition: lwcollection.c:92
LWPOINT * lwpoint_project_lwpoint(const LWPOINT *lwpoint1, const LWPOINT *lwpoint2, double distance)
Definition: lwpoint.c:277
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
Definition: gserialized.c:185
double lwgeom_length_2d(const LWGEOM *geom)
Definition: lwgeom.c:1974
uint32_t lwgeom_count_rings(const LWGEOM *geom)
Count the total number of rings in any LWGEOM.
Definition: lwgeom.c:1356
int lwgeom_force_geodetic(LWGEOM *geom)
Force coordinates of LWGEOM into geodetic range (-180, -90, 180, 90)
Definition: lwgeodetic.c:3221
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing min distance calculation.
Definition: measures.c:197
int ptarray_is_closed_z(const POINTARRAY *pa)
Definition: ptarray.c:740
char * lwpoint_to_latlon(const LWPOINT *p, const char *format)
Definition: lwprint.c:431
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
LWGEOM * lwgeom_symdifference_prec(const LWGEOM *geom1, const LWGEOM *geom2, double gridSize)
POINT3DZ getPoint3dz(const POINTARRAY *pa, uint32_t n)
Definition: lwgeom_api.c:187
void lwgeom_force_clockwise(LWGEOM *lwgeom)
Force Right-hand-rule on LWGEOM polygons.
Definition: lwgeom.c:38
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: gserialized.c:163
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:357
void printLWLINE(LWLINE *line)
Definition: lwline.c:79
int lwgeom_is_solid(const LWGEOM *geom)
Return LW_TRUE if geometry has SOLID flag.
Definition: lwgeom.c:948
uint32_t gserialized_max_header_size(void)
Returns the size in bytes to read from toast to get the basic information from a geometry: GSERIALIZE...
Definition: gserialized.c:101
GBOX * gbox_from_string(const char *str)
Warning, do not use this function, it is very particular about inputs.
Definition: gbox.c:364
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:125
int lwcollection_ngeoms(const LWCOLLECTION *col)
Definition: lwcollection.c:319
double distance2d_sqr_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
Definition: measures.c:2408
LWGEOM * lwgeom_intersection_prec(const LWGEOM *geom1, const LWGEOM *geom2, double gridSize)
LWGEOM * lwgeom_linemerge_directed(const LWGEOM *geom1, int directed)
LWCOLLECTION * lwgeom_locate_between(const LWGEOM *lwin, double from, double to, double offset)
Determine the segments along a measured line that fall within the m-range given.
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:319
LWLINE * lwline_from_lwmpoint(int32_t srid, const LWMPOINT *mpoint)
Definition: lwline.c:275
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:708
int lwgeom_nudge_geodetic(LWGEOM *geom)
Gently move coordinates of LWGEOM if they are close enough into geodetic range.
Definition: lwgeodetic.c:3403
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
Definition: lwgeom.c:743
GSERIALIZED * gserialized_drop_gbox(GSERIALIZED *g)
Remove the bounding box from a GSERIALIZED.
Definition: gserialized.c:52
void lwcircstring_release(LWCIRCSTRING *lwcirc)
Definition: lwcircstring.c:91
LWGEOM * lwgeom_set_effective_area(const LWGEOM *igeom, int set_area, double area)
LWGEOM * lwtin_as_lwgeom(const LWTIN *obj)
Definition: lwgeom.c:284
LWPOLY * lwpoly_segmentize2d(const LWPOLY *line, double dist)
Definition: lwpoly.c:312
POINT2D getPoint2d(const POINTARRAY *pa, uint32_t n)
Definition: lwgeom_api.c:328
LWGEOM * lwcurvepoly_as_lwgeom(const LWCURVEPOLY *obj)
Definition: lwgeom.c:319
lwvarlena_t * lwgeom_to_hexwkb_varlena(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:875
struct lwvarlena_t lwvarlena_t
LWTIN * lwgeom_as_lwtin(const LWGEOM *lwgeom)
Definition: lwgeom.c:277
void lwpoly_release(LWPOLY *lwpoly)
Definition: lwpoly.c:306
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:491
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
Definition: lwgeom.c:755
LWGEOM * lwcircstring_as_lwgeom(const LWCIRCSTRING *obj)
Definition: lwgeom.c:314
LWPSURFACE * lwgeom_as_lwpsurface(const LWGEOM *lwgeom)
Definition: lwgeom.c:269
void lwline_setPoint4d(LWLINE *line, uint32_t which, POINT4D *newpoint)
Definition: lwline.c:364
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:905
LWCOLLECTION * lwcollection_concat_in_place(LWCOLLECTION *col1, const LWCOLLECTION *col2)
Appends all geometries from col2 to col1 in place.
Definition: lwcollection.c:241
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
Definition: ptarray.c:147
LWMPOINT * lwmpoint_from_lwgeom(const LWGEOM *g)
Definition: lwmpoint.c:93
void expand_box3d(BOX3D *box, double d)
Expand given box of 'd' units in all directions.
Definition: lwgeom_box3d.c:344
void lwgeom_add_bbox_deep(LWGEOM *lwgeom, GBOX *gbox)
Compute a box for geom and all sub-geometries, if not already computed.
Definition: lwgeom.c:714
int lwpointiterator_has_next(LWPOINTITERATOR *s)
Returns LW_TRUE if there is another point available in the iterator.
Definition: lwiterator.c:202
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
Definition: lwcollection.c:188
double lwgeom_length_spheroid(const LWGEOM *geom, const SPHEROID *s)
Calculate the geodetic length of a lwgeom on the unit sphere.
Definition: lwgeodetic.c:3296
LWPOINT * lwmpoint_median(const LWMPOINT *g, double tol, uint32_t maxiter, char fail_if_not_converged)
LWGEOM * lwgeom_triangulate_polygon(const LWGEOM *geom)
Take vertices of a polygon and build a constrained triangulation that respects the boundary of the po...
LWGEOM * lwgeom_linemerge(const LWGEOM *geom1)
LWGEOM * lwgeom_furthest_line(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures.c:46
void printLWPOINT(LWPOINT *point)
Definition: lwpoint.c:224
void * lwalloc(size_t size)
Definition: lwutil.c:227
int lwgeom_dimensionality(const LWGEOM *geom)
Return the dimensionality (relating to point/line/poly) of an lwgeom.
Definition: lwgeom.c:1426
uint8_t parse_hex(char *str)
Convert a single hex digit into the corresponding char.
Definition: lwgeom_api.c:482
LWCOMPOUND * lwcompound_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwcompound.c:123
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:42
int lwcompound_add_lwgeom(LWCOMPOUND *comp, LWGEOM *geom)
Add a component, allocating extra space if necessary.
Definition: lwcompound.c:88
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:714
double lwgeom_maxdistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling max distance calculations and dfullywithin calculations.
Definition: measures.c:177
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:233
LWLINE * lwline_measured_from_lwline(const LWLINE *lwline, double m_start, double m_end)
Add a measure dimension to a line, interpolating linearly from the start to the end value.
Definition: lwline.c:379
LWGEOM * lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1)
LWGEOM * lwtriangle_as_lwgeom(const LWTRIANGLE *obj)
Definition: lwgeom.c:334
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
Definition: lwgeom.c:188
LWGEOM * lwgeom_wrapx(const LWGEOM *lwgeom, double cutx, double amount)
wrap geometry on given cut x value
Definition: lwgeom_wrapx.c:169
void lwpsurface_free(LWPSURFACE *psurf)
Definition: lwpsurface.c:39
float next_float_up(double d)
Definition: lwgeom_api.c:75
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:175
int lwgeom_transform_pipeline(LWGEOM *geom, const char *pipeline, bool is_forward)
Transform (reproject) a geometry in-place using a PROJ pipeline.
LWGEOM * lwgeom_reduceprecision(const LWGEOM *geom, double gridSize)
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
Definition: lwutil.c:471
LWPOINT * lwgeom_median(const LWGEOM *g, double tol, uint32_t maxiter, char fail_if_not_converged)
LWMPOINT * lwgeom_to_points(const LWGEOM *lwgeom, uint32_t npoints, int32_t seed)
double lwpoint_get_z(const LWPOINT *point)
Definition: lwpoint.c:89
void lwmline_free(LWMLINE *mline)
Definition: lwmline.c:112
void lwpsurface_release(LWPSURFACE *lwpsurface)
int lwline_is_trajectory(const LWLINE *geom)
Definition: lwline.c:454
void printLWTRIANGLE(LWTRIANGLE *triangle)
Definition: lwtriangle.c:82
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:215
int getPoint3dm_p(const POINTARRAY *pa, uint32_t n, POINT3DM *point)
Definition: lwgeom_api.c:268
double lwgeom_maxdistance3d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing 3d max distance calculation.
Definition: measures3d.c:300
int gbox_same_2d_float(const GBOX *g1, const GBOX *g2)
Check if two given GBOX are the same in x and y, or would round to the same GBOX in x and if serializ...
Definition: gbox.c:187
LWMLINE * lwmline_measured_from_lwmline(const LWMLINE *lwmline, double m_start, double m_end)
Re-write the measure ordinate (or add one, if it isn't already there) interpolating the measure betwe...
Definition: lwmline.c:56
lwvarlena_t * lwgeom_to_twkb_with_idlist(const LWGEOM *geom, int64_t *idlist, uint8_t variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m)
Convert LWGEOM to a char* in TWKB format.
Definition: lwout_twkb.c:589
LWCURVEPOLY * lwcurvepoly_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwcurvepoly.c:35
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
Definition: lwgeom.c:468
double lwgeom_perimeter(const LWGEOM *geom)
Definition: lwgeom.c:1908
LWPOLY * lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes)
Definition: lwpoly.c:360
LWGEOM * lwgeom_from_wkb(const uint8_t *wkb, const size_t wkb_size, const char check)
WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory...
Definition: lwin_wkb.c:834
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:941
struct LWPROJ LWPROJ
LWCOLLECTION * lwgeom_subdivide_prec(const LWGEOM *geom, uint32_t maxvertices, double gridSize)
Definition: lwgeom.c:2465
int gbox_is_valid(const GBOX *gbox)
Return false if any of the dimensions is NaN or infinite.
Definition: gbox.c:197
struct gridspec_t gridspec
Snap-to-grid.
LWCOMPOUND * lwcompound_construct_from_lwline(const LWLINE *lwpoly)
Construct an equivalent compound curve from a linestring.
Definition: lwcompound.c:204
double lwgeom_azumith_spheroid(const LWPOINT *r, const LWPOINT *s, const SPHEROID *spheroid)
Calculate the bearing between two points on a spheroid.
Definition: lwgeodetic.c:2170
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
Definition: gserialized.c:222
lwvarlena_t * lwgeom_to_x3d3(const LWGEOM *geom, int precision, int opts, const char *defid)
Definition: lwout_x3d.c:37
lwvarlena_t * lwgeom_to_wkb_varlena(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:851
LWLINE * lwline_extend(const LWLINE *line, double distance_forward, double distance_backward)
Extend the ends of a line.
Definition: lwline.c:672
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwpoly.c:161
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:43
lwflags_t gserialized_get_lwflags(const GSERIALIZED *g)
Read standard lwflags from gserialized.
Definition: gserialized.c:18
LWGEOM * lwgeom_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
Definition: lwgeom.c:2105
LWGEOM * lwgeom_grid(const LWGEOM *lwgeom, const gridspec *grid)
Definition: lwgeom.c:2267
int lwgeom_is_clockwise(LWGEOM *lwgeom)
Ensure the outer ring is clockwise oriented and all inner rings are counter-clockwise.
Definition: lwgeom.c:66
LWCIRCSTRING * lwcircstring_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwcircstring.c:79
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
Definition: lwgeom_api.c:369
LWLINE * lwline_removepoint(LWLINE *line, uint32_t which)
Definition: lwline.c:347
LWMPOINT * lwmpoint_construct(int32_t srid, const POINTARRAY *pa)
Definition: lwmpoint.c:52
int32_t gserialized_hash(const GSERIALIZED *g)
Returns a hash code for the srid/type/geometry information in the GSERIALIZED.
Definition: gserialized.c:114
POINTARRAY * ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2)
Merge two given POINTARRAY and returns a pointer on the new aggregate one.
Definition: ptarray.c:616
int lwpoint_getPoint2d_p(const LWPOINT *point, POINT2D *out)
Definition: lwpoint.c:40
LWMPOLY * lwmpoly_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwmpoly.c:40
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:695
float next_float_down(double d)
Definition: lwgeom_api.c:54
void lwline_free(LWLINE *line)
Definition: lwline.c:67
int gserialized_cmp(const GSERIALIZED *g1, const GSERIALIZED *g2)
Return -1 if g1 is "less than" g2, 1 if g1 is "greater than" g2 and 0 if g1 and g2 are the "same".
Definition: gserialized.c:313
LWCIRCSTRING * lwcircstring_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition: lwcircstring.c:50
POINTARRAY * ptarray_flip_coordinates(POINTARRAY *pa)
Reverse X and Y axis on a given POINTARRAY.
Definition: ptarray.c:360
LWGEOM * lwgeom_union(const LWGEOM *geom1, const LWGEOM *geom2)
LWLINE * lwline_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwline.c:55
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
Definition: lwin_wkt.c:886
LWTRIANGLE * lwtriangle_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:40
int gbox_contains_2d(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the first GBOX contains the second on the 2d plane, LW_FALSE otherwise.
Definition: gbox.c:339
LWLINE * lwline_from_lwgeom_array(int32_t srid, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwline.c:151
POINTARRAY * ptarray_segmentize2d(const POINTARRAY *ipa, double dist)
Returns a modified POINTARRAY so that no segment is longer than the given distance (computed using 2d...
Definition: ptarray.c:405
int lwgeom_has_arc(const LWGEOM *geom)
Geometry includes at least one actual circular arc.
Definition: lwstroke.c:55
int32_t clamp_srid(int32_t srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...
Definition: lwutil.c:333
void lwmpoint_release(LWMPOINT *lwpoint)
Definition: lwmpoint.c:33
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
Definition: gbox.c:392
LWPOINT * lwcompound_get_endpoint(const LWCOMPOUND *lwcmp)
Definition: lwcompound.c:254
void lwtriangle_release(LWTRIANGLE *lwtriangle)
Definition: lwtriangle.c:119
double lwpoint_get_y(const LWPOINT *point)
Definition: lwpoint.c:76
double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the sphere.
Definition: lwgeodetic.c:2037
void printLWPSURFACE(LWPSURFACE *psurf)
Definition: lwpsurface.c:57
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
LWGEOM * lwgeom_closest_line_3d(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures3d.c:76
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
Definition: lwgeom.c:793
int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, uint32_t where)
Add a LWPOINT to an LWLINE.
Definition: lwline.c:327
lwvarlena_t * lwgeom_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix, const char *id)
Definition: lwout_gml.c:978
void lwgeom_drop_srid(LWGEOM *lwgeom)
Definition: lwgeom.c:765
void lwgeom_grid_in_place(LWGEOM *lwgeom, const gridspec *grid)
Definition: lwgeom.c:2166
lwinterrupt_callback * lwgeom_register_interrupt_callback(lwinterrupt_callback *)
Definition: lwgeom_api.c:673
void lwgeom_reverse_in_place(LWGEOM *lwgeom)
Reverse vertex order of LWGEOM.
Definition: lwgeom.c:103
double lwgeom_mindistance3d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing 3d min distance calculation.
Definition: measures3d.c:335
int lwgeom_cpa_within(const LWGEOM *g1, const LWGEOM *g2, double maxdist)
Is the closest point of approach within a distance ?
int gbox_merge(const GBOX *new_box, GBOX *merged_box)
Update the merged GBOX to be large enough to include itself and the new box.
Definition: gbox.c:257
LWPOINT * lwpoint_make(int32_t srid, int hasz, int hasm, const POINT4D *p)
Definition: lwpoint.c:206
lwvarlena_t * lwgeom_to_wkt_varlena(const LWGEOM *geom, uint8_t variant, int precision)
Definition: lwout_wkt.c:721
enum LWORD_T LWORD
Ordinate names.
LWCOMPOUND * lwgeom_as_lwcompound(const LWGEOM *lwgeom)
Definition: lwgeom.c:197
LWPOINT * lwline_get_lwpoint(const LWLINE *line, uint32_t where)
Returns freshly allocated LWPOINT that corresponds to the index where.
Definition: lwline.c:309
#define str(s)
static double distance(double x1, double y1, double x2, double y2)
Definition: lwtree.c:1032
int value
Definition: genraster.py:62
opts
Definition: ovdump.py:45
type
Definition: ovdump.py:42
data
Definition: ovdump.py:104
def fmt
Definition: pixval.py:93
double afac
Definition: liblwgeom.h:332
double xmax
Definition: liblwgeom.h:340
double xmin
Definition: liblwgeom.h:339
int32_t srid
Definition: liblwgeom.h:341
double ymax
Definition: liblwgeom.h:357
double zmax
Definition: liblwgeom.h:359
double xmax
Definition: liblwgeom.h:355
double zmin
Definition: liblwgeom.h:358
double mmax
Definition: liblwgeom.h:361
double ymin
Definition: liblwgeom.h:356
double xmin
Definition: liblwgeom.h:354
double mmin
Definition: liblwgeom.h:360
lwflags_t flags
Definition: liblwgeom.h:353
uint32_t size
Definition: liblwgeom.h:444
uint8_t gflags
Definition: liblwgeom.h:446
POINT2D * center
Definition: liblwgeom.h:1816
uint8_t type
Definition: liblwgeom.h:510
int32_t srid
Definition: liblwgeom.h:508
lwflags_t flags
Definition: liblwgeom.h:509
POINTARRAY * points
Definition: liblwgeom.h:507
GBOX * bbox
Definition: liblwgeom.h:506
lwflags_t flags
Definition: liblwgeom.h:577
uint32_t ngeoms
Definition: liblwgeom.h:580
uint32_t maxgeoms
Definition: liblwgeom.h:581
uint8_t type
Definition: liblwgeom.h:578
GBOX * bbox
Definition: liblwgeom.h:574
LWGEOM ** geoms
Definition: liblwgeom.h:575
int32_t srid
Definition: liblwgeom.h:576
uint32_t maxgeoms
Definition: liblwgeom.h:595
lwflags_t flags
Definition: liblwgeom.h:591
int32_t srid
Definition: liblwgeom.h:590
GBOX * bbox
Definition: liblwgeom.h:588
uint32_t ngeoms
Definition: liblwgeom.h:594
uint8_t type
Definition: liblwgeom.h:592
LWGEOM ** geoms
Definition: liblwgeom.h:589
int32_t srid
Definition: liblwgeom.h:604
GBOX * bbox
Definition: liblwgeom.h:602
uint8_t type
Definition: liblwgeom.h:606
LWGEOM ** rings
Definition: liblwgeom.h:603
lwflags_t flags
Definition: liblwgeom.h:605
uint32_t nrings
Definition: liblwgeom.h:608
uint32_t maxrings
Definition: liblwgeom.h:609
void * data
Definition: liblwgeom.h:459
uint8_t type
Definition: liblwgeom.h:462
GBOX * bbox
Definition: liblwgeom.h:458
int32_t srid
Definition: liblwgeom.h:460
lwflags_t flags
Definition: liblwgeom.h:461
lwflags_t flags
Definition: liblwgeom.h:485
GBOX * bbox
Definition: liblwgeom.h:482
POINTARRAY * points
Definition: liblwgeom.h:483
uint8_t type
Definition: liblwgeom.h:486
int32_t srid
Definition: liblwgeom.h:484
uint32_t maxgeoms
Definition: liblwgeom.h:623
LWGEOM ** geoms
Definition: liblwgeom.h:617
GBOX * bbox
Definition: liblwgeom.h:616
lwflags_t flags
Definition: liblwgeom.h:619
uint32_t ngeoms
Definition: liblwgeom.h:622
int32_t srid
Definition: liblwgeom.h:618
uint8_t type
Definition: liblwgeom.h:620
uint32_t maxgeoms
Definition: liblwgeom.h:553
lwflags_t flags
Definition: liblwgeom.h:549
GBOX * bbox
Definition: liblwgeom.h:546
int32_t srid
Definition: liblwgeom.h:548
LWLINE ** geoms
Definition: liblwgeom.h:547
uint8_t type
Definition: liblwgeom.h:550
uint32_t ngeoms
Definition: liblwgeom.h:552
uint32_t maxgeoms
Definition: liblwgeom.h:539
int32_t srid
Definition: liblwgeom.h:534
GBOX * bbox
Definition: liblwgeom.h:532
lwflags_t flags
Definition: liblwgeom.h:535
uint32_t ngeoms
Definition: liblwgeom.h:538
LWPOINT ** geoms
Definition: liblwgeom.h:533
uint8_t type
Definition: liblwgeom.h:536
uint8_t type
Definition: liblwgeom.h:564
GBOX * bbox
Definition: liblwgeom.h:560
uint32_t maxgeoms
Definition: liblwgeom.h:567
uint32_t ngeoms
Definition: liblwgeom.h:566
LWPOLY ** geoms
Definition: liblwgeom.h:561
lwflags_t flags
Definition: liblwgeom.h:563
int32_t srid
Definition: liblwgeom.h:562
uint8_t type
Definition: liblwgeom.h:634
int32_t srid
Definition: liblwgeom.h:632
uint32_t maxgeoms
Definition: liblwgeom.h:637
GBOX * bbox
Definition: liblwgeom.h:630
uint32_t ngeoms
Definition: liblwgeom.h:636
lwflags_t flags
Definition: liblwgeom.h:633
LWGEOM ** geoms
Definition: liblwgeom.h:631
POINTARRAY * point
Definition: liblwgeom.h:471
uint8_t type
Definition: liblwgeom.h:474
lwflags_t flags
Definition: liblwgeom.h:473
GBOX * bbox
Definition: liblwgeom.h:470
int32_t srid
Definition: liblwgeom.h:472
POINTARRAY ** rings
Definition: liblwgeom.h:519
uint8_t type
Definition: liblwgeom.h:522
uint32_t maxrings
Definition: liblwgeom.h:525
uint32_t nrings
Definition: liblwgeom.h:524
GBOX * bbox
Definition: liblwgeom.h:518
lwflags_t flags
Definition: liblwgeom.h:521
int32_t srid
Definition: liblwgeom.h:520
bool pipeline_is_forward
Definition: liblwgeom.h:49
uint8_t source_is_latlong
Definition: liblwgeom.h:52
double source_semi_major_metre
Definition: liblwgeom.h:54
double source_semi_minor_metre
Definition: liblwgeom.h:55
PJ * pj
Definition: liblwgeom.h:46
lwflags_t flags
Definition: liblwgeom.h:647
uint32_t maxgeoms
Definition: liblwgeom.h:651
LWPOLY ** geoms
Definition: liblwgeom.h:645
uint32_t ngeoms
Definition: liblwgeom.h:650
uint8_t type
Definition: liblwgeom.h:648
int32_t srid
Definition: liblwgeom.h:646
GBOX * bbox
Definition: liblwgeom.h:644
uint32_t ngeoms
Definition: liblwgeom.h:664
int32_t srid
Definition: liblwgeom.h:660
uint8_t type
Definition: liblwgeom.h:662
lwflags_t flags
Definition: liblwgeom.h:661
LWTRIANGLE ** geoms
Definition: liblwgeom.h:659
uint32_t maxgeoms
Definition: liblwgeom.h:665
GBOX * bbox
Definition: liblwgeom.h:658
int32_t srid
Definition: liblwgeom.h:496
uint8_t type
Definition: liblwgeom.h:498
GBOX * bbox
Definition: liblwgeom.h:494
lwflags_t flags
Definition: liblwgeom.h:497
POINTARRAY * points
Definition: liblwgeom.h:495
double x
Definition: liblwgeom.h:390
double m
Definition: liblwgeom.h:408
double x
Definition: liblwgeom.h:396
double x
Definition: liblwgeom.h:402
double m
Definition: liblwgeom.h:414
lwflags_t flags
Definition: liblwgeom.h:431
uint32_t maxpoints
Definition: liblwgeom.h:428
uint32_t npoints
Definition: liblwgeom.h:427
uint8_t * serialized_pointlist
Definition: liblwgeom.h:434
double e_sq
Definition: liblwgeom.h:379
double e
Definition: liblwgeom.h:378
double radius
Definition: liblwgeom.h:380
double a
Definition: liblwgeom.h:375
double b
Definition: liblwgeom.h:376
double f
Definition: liblwgeom.h:377
double ipm
Definition: liblwgeom.h:1379
double zsize
Definition: liblwgeom.h:1382
double ysize
Definition: liblwgeom.h:1381
double xsize
Definition: liblwgeom.h:1380
double ipx
Definition: liblwgeom.h:1376
double msize
Definition: liblwgeom.h:1383
double ipy
Definition: liblwgeom.h:1377
double ipz
Definition: liblwgeom.h:1378
Snap-to-grid.
Definition: liblwgeom.h:1375
uint32_t size
Definition: liblwgeom.h:307
char data[]
Definition: liblwgeom.h:308
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.
Definition: liblwgeom.h:2122