PostGIS  2.2.8dev-r@@SVN_REVISION@@
liblwgeom.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  *
5  * Copyright 2011 Sandro Santilli <strk@keybit.net>
6  * Copyright 2011 Paul Ramsey <pramsey@cleverelephant.ca>
7  * Copyright 2007-2008 Mark Cave-Ayland
8  * Copyright 2001-2006 Refractions Research Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU General Public Licence. See the COPYING file.
12  *
13  **********************************************************************/
14 
15 #ifndef _LIBLWGEOM_H
16 #define _LIBLWGEOM_H 1
17 
18 #include <stdarg.h>
19 #include <stdio.h>
20 #include <stdint.h>
21 #include "proj_api.h"
22 
23 #if defined(PJ_VERSION) && PJ_VERSION >= 490
24 /* Enable new geodesic functions */
25 #define PROJ_GEODESIC 1
26 #else
27 /* Use the old (pre-2.2) geodesic functions */
28 #define PROJ_GEODESIC 0
29 #endif
30 
50 #define LIBLWGEOM_VERSION "2.2.8dev"
51 #define LIBLWGEOM_VERSION_MAJOR "2"
52 #define LIBLWGEOM_VERSION_MINOR "2"
53 #define LIBLWGEOM_GEOS_VERSION "37"
54 
56 const char* lwgeom_version(void);
57 
61 #define LW_TRUE 1
62 #define LW_FALSE 0
63 #define LW_UNKNOWN 2
64 #define LW_FAILURE 0
65 #define LW_SUCCESS 1
66 
70 #define POINTTYPE 1
71 #define LINETYPE 2
72 #define POLYGONTYPE 3
73 #define MULTIPOINTTYPE 4
74 #define MULTILINETYPE 5
75 #define MULTIPOLYGONTYPE 6
76 #define COLLECTIONTYPE 7
77 #define CIRCSTRINGTYPE 8
78 #define COMPOUNDTYPE 9
79 #define CURVEPOLYTYPE 10
80 #define MULTICURVETYPE 11
81 #define MULTISURFACETYPE 12
82 #define POLYHEDRALSURFACETYPE 13
83 #define TRIANGLETYPE 14
84 #define TINTYPE 15
85 
86 #define NUMTYPES 16
87 
92 #define WKBZOFFSET 0x80000000
93 #define WKBMOFFSET 0x40000000
94 #define WKBSRIDFLAG 0x20000000
95 #define WKBBBOXFLAG 0x10000000
96 
98 typedef enum LWORD_T {
99  LWORD_X = 0,
100  LWORD_Y = 1,
101  LWORD_Z = 2,
103 } LWORD;
104 
105 /**********************************************************************
106 ** Spherical radius.
107 ** Moritz, H. (1980). Geodetic Reference System 1980, by resolution of
108 ** the XVII General Assembly of the IUGG in Canberra.
109 ** http://en.wikipedia.org/wiki/Earth_radius
110 ** http://en.wikipedia.org/wiki/World_Geodetic_System
111 */
112 
113 #define WGS84_MAJOR_AXIS 6378137.0
114 #define WGS84_INVERSE_FLATTENING 298.257223563
115 #define WGS84_MINOR_AXIS (WGS84_MAJOR_AXIS - WGS84_MAJOR_AXIS / WGS84_INVERSE_FLATTENING)
116 #define WGS84_RADIUS ((2.0 * WGS84_MAJOR_AXIS + WGS84_MINOR_AXIS ) / 3.0)
117 
118 
124 #define FLAGS_GET_Z(flags) ((flags) & 0x01)
125 #define FLAGS_GET_M(flags) (((flags) & 0x02)>>1)
126 #define FLAGS_GET_BBOX(flags) (((flags) & 0x04)>>2)
127 #define FLAGS_GET_GEODETIC(flags) (((flags) & 0x08)>>3)
128 #define FLAGS_GET_READONLY(flags) (((flags) & 0x10)>>4)
129 #define FLAGS_GET_SOLID(flags) (((flags) & 0x20)>>5)
130 #define FLAGS_SET_Z(flags, value) ((flags) = (value) ? ((flags) | 0x01) : ((flags) & 0xFE))
131 #define FLAGS_SET_M(flags, value) ((flags) = (value) ? ((flags) | 0x02) : ((flags) & 0xFD))
132 #define FLAGS_SET_BBOX(flags, value) ((flags) = (value) ? ((flags) | 0x04) : ((flags) & 0xFB))
133 #define FLAGS_SET_GEODETIC(flags, value) ((flags) = (value) ? ((flags) | 0x08) : ((flags) & 0xF7))
134 #define FLAGS_SET_READONLY(flags, value) ((flags) = (value) ? ((flags) | 0x10) : ((flags) & 0xEF))
135 #define FLAGS_SET_SOLID(flags, value) ((flags) = (value) ? ((flags) | 0x20) : ((flags) & 0xDF))
136 #define FLAGS_NDIMS(flags) (2 + FLAGS_GET_Z(flags) + FLAGS_GET_M(flags))
137 #define FLAGS_GET_ZM(flags) (FLAGS_GET_M(flags) + FLAGS_GET_Z(flags) * 2)
138 #define FLAGS_NDIMS_BOX(flags) (FLAGS_GET_GEODETIC(flags) ? 3 : FLAGS_NDIMS(flags))
139 
149 #define TYPMOD_GET_SRID(typmod) ((((typmod) & 0x0FFFFF00) - ((typmod) & 0x10000000)) >> 8)
150 #define TYPMOD_SET_SRID(typmod, srid) ((typmod) = (((typmod) & 0xE00000FF) | ((srid & 0x001FFFFF)<<8)))
151 #define TYPMOD_GET_TYPE(typmod) ((typmod & 0x000000FC)>>2)
152 #define TYPMOD_SET_TYPE(typmod, type) ((typmod) = (typmod & 0xFFFFFF03) | ((type & 0x0000003F)<<2))
153 #define TYPMOD_GET_Z(typmod) ((typmod & 0x00000002)>>1)
154 #define TYPMOD_SET_Z(typmod) ((typmod) = typmod | 0x00000002)
155 #define TYPMOD_GET_M(typmod) (typmod & 0x00000001)
156 #define TYPMOD_SET_M(typmod) ((typmod) = typmod | 0x00000001)
157 #define TYPMOD_GET_NDIMS(typmod) (2+TYPMOD_GET_Z(typmod)+TYPMOD_GET_M(typmod))
158 
163 #define SRID_MAXIMUM 999999
164 
169 #define SRID_USER_MAXIMUM 998999
170 
172 #define SRID_UNKNOWN 0
173 #define SRID_IS_UNKNOWN(x) ((int)x<=0)
174 
175 /*
176 ** EPSG WGS84 geographics, OGC standard default SRS, better be in
177 ** the SPATIAL_REF_SYS table!
178 */
179 #define SRID_DEFAULT 4326
180 
181 #ifndef __GNUC__
182 # define __attribute__(x)
183 #endif
184 
191 extern int clamp_srid(int srid);
192 
193 /* Raise an lwerror if srids do not match */
194 void error_if_srid_mismatch(int srid1, int srid2);
195 
199 typedef void* (*lwallocator)(size_t size);
200 typedef void* (*lwreallocator)(void *mem, size_t size);
201 typedef void (*lwfreeor)(void* mem);
202 typedef void (*lwreporter)(const char* fmt, va_list ap)
203  __attribute__ (( format(printf, 1, 0) ));
204 typedef void (*lwdebuglogger)(int level, const char* fmt, va_list ap)
205  __attribute__ (( format(printf, 2,0) ));
206 
213 extern void lwgeom_set_handlers(lwallocator allocator,
214  lwreallocator reallocator, lwfreeor freeor, lwreporter errorreporter,
215  lwreporter noticereporter);
216 
217 extern void lwgeom_set_debuglogger(lwdebuglogger debuglogger);
218 
231 extern void lwgeom_request_interrupt(void);
232 
236 extern void lwgeom_cancel_interrupt(void);
237 
248 typedef void (lwinterrupt_callback)();
250 
251 /******************************************************************/
252 
253 typedef struct {
254  double afac, bfac, cfac, dfac, efac, ffac, gfac, hfac, ifac, xoff, yoff, zoff;
255 } AFFINE;
256 
257 /******************************************************************/
258 
259 typedef struct
260 {
261  double xmin, ymin, zmin;
262  double xmax, ymax, zmax;
263  int32_t srid;
264 }
265 BOX3D;
266 
267 /******************************************************************
268 * GBOX structure.
269 * We include the flags (information about dimensinality),
270 * so we don't have to constantly pass them
271 * into functions that use the GBOX.
272 */
273 typedef struct
274 {
275  uint8_t flags;
276  double xmin;
277  double xmax;
278  double ymin;
279  double ymax;
280  double zmin;
281  double zmax;
282  double mmin;
283  double mmax;
284 } GBOX;
285 
286 
287 /******************************************************************
288 * SPHEROID
289 *
290 * Standard definition of an ellipsoid (what wkt calls a spheroid)
291 * f = (a-b)/a
292 * e_sq = (a*a - b*b)/(a*a)
293 * b = a - fa
294 */
295 typedef struct
296 {
297  double a; /* semimajor axis */
298  double b; /* semiminor axis b = (a - fa) */
299  double f; /* flattening f = (a-b)/a */
300  double e; /* eccentricity (first) */
301  double e_sq; /* eccentricity squared (first) e_sq = (a*a-b*b)/(a*a) */
302  double radius; /* spherical average radius = (2*a+b)/3 */
303  char name[20]; /* name of ellipse */
304 }
305 SPHEROID;
306 
307 /******************************************************************
308 * POINT2D, POINT3D, POINT3DM, POINT4D
309 */
310 typedef struct
311 {
312  double x, y;
313 }
314 POINT2D;
315 
316 typedef struct
317 {
318  double x, y, z;
319 }
320 POINT3DZ;
321 
322 typedef struct
323 {
324  double x, y, z;
325 }
326 POINT3D;
327 
328 typedef struct
329 {
330  double x, y, m;
331 }
332 POINT3DM;
333 
334 typedef struct
335 {
336  double x, y, z, m;
337 }
338 POINT4D;
339 
340 /******************************************************************
341 * POINTARRAY
342 * Point array abstracts a lot of the complexity of points and point lists.
343 * It handles 2d/3d translation
344 * (2d points converted to 3d will have z=0 or NaN)
345 * DO NOT MIX 2D and 3D POINTS! EVERYTHING* is either one or the other
346 */
347 typedef struct
348 {
349  /* Array of POINT 2D, 3D or 4D, possibly missaligned. */
351 
352  /* Use FLAGS_* macros to handle */
353  uint8_t flags;
354 
355  int npoints; /* how many points we are currently storing */
356  int maxpoints; /* how many points we have space for in serialized_pointlist */
357 }
358 POINTARRAY;
359 
360 /******************************************************************
361 * GSERIALIZED
362 */
363 typedef struct
364 {
365  uint32_t size; /* For PgSQL use only, use VAR* macros to manipulate. */
366  uint8_t srid[3]; /* 24 bits of SRID */
367  uint8_t flags; /* HasZ, HasM, HasBBox, IsGeodetic, IsReadOnly */
368  uint8_t data[1]; /* See gserialized.txt */
369 } GSERIALIZED;
370 
371 
372 /******************************************************************
373 * LWGEOM (any geometry type)
374 *
375 * Abstract type, note that 'type', 'bbox' and 'srid' are available in
376 * all geometry variants.
377 */
378 typedef struct
379 {
380  uint8_t type;
381  uint8_t flags;
383  int32_t srid;
384  void *data;
385 }
386 LWGEOM;
387 
388 /* POINTYPE */
389 typedef struct
390 {
391  uint8_t type; /* POINTTYPE */
392  uint8_t flags;
394  int32_t srid;
395  POINTARRAY *point; /* hide 2d/3d (this will be an array of 1 point) */
396 }
397 LWPOINT; /* "light-weight point" */
398 
399 /* LINETYPE */
400 typedef struct
401 {
402  uint8_t type; /* LINETYPE */
403  uint8_t flags;
405  int32_t srid;
406  POINTARRAY *points; /* array of POINT3D */
407 }
408 LWLINE; /* "light-weight line" */
409 
410 /* TRIANGLE */
411 typedef struct
412 {
413  uint8_t type;
414  uint8_t flags;
416  int32_t srid;
418 }
419 LWTRIANGLE;
420 
421 /* CIRCSTRINGTYPE */
422 typedef struct
423 {
424  uint8_t type; /* CIRCSTRINGTYPE */
425  uint8_t flags;
427  int32_t srid;
428  POINTARRAY *points; /* array of POINT(3D/3DM) */
429 }
430 LWCIRCSTRING; /* "light-weight circularstring" */
431 
432 /* POLYGONTYPE */
433 typedef struct
434 {
435  uint8_t type; /* POLYGONTYPE */
436  uint8_t flags;
438  int32_t srid;
439  int nrings; /* how many rings we are currently storing */
440  int maxrings; /* how many rings we have space for in **rings */
441  POINTARRAY **rings; /* list of rings (list of points) */
442 }
443 LWPOLY; /* "light-weight polygon" */
444 
445 /* MULTIPOINTTYPE */
446 typedef struct
447 {
448  uint8_t type;
449  uint8_t flags;
451  int32_t srid;
452  int ngeoms; /* how many geometries we are currently storing */
453  int maxgeoms; /* how many geometries we have space for in **geoms */
455 }
456 LWMPOINT;
457 
458 /* MULTILINETYPE */
459 typedef struct
460 {
461  uint8_t type;
462  uint8_t flags;
464  int32_t srid;
465  int ngeoms; /* how many geometries we are currently storing */
466  int maxgeoms; /* how many geometries we have space for in **geoms */
468 }
469 LWMLINE;
470 
471 /* MULTIPOLYGONTYPE */
472 typedef struct
473 {
474  uint8_t type;
475  uint8_t flags;
477  int32_t srid;
478  int ngeoms; /* how many geometries we are currently storing */
479  int maxgeoms; /* how many geometries we have space for in **geoms */
481 }
482 LWMPOLY;
483 
484 /* COLLECTIONTYPE */
485 typedef struct
486 {
487  uint8_t type;
488  uint8_t flags;
490  int32_t srid;
491  int ngeoms; /* how many geometries we are currently storing */
492  int maxgeoms; /* how many geometries we have space for in **geoms */
494 }
496 
497 /* COMPOUNDTYPE */
498 typedef struct
499 {
500  uint8_t type; /* COMPOUNDTYPE */
501  uint8_t flags;
503  int32_t srid;
504  int ngeoms; /* how many geometries we are currently storing */
505  int maxgeoms; /* how many geometries we have space for in **geoms */
507 }
508 LWCOMPOUND; /* "light-weight compound line" */
509 
510 /* CURVEPOLYTYPE */
511 typedef struct
512 {
513  uint8_t type; /* CURVEPOLYTYPE */
514  uint8_t flags;
516  int32_t srid;
517  int nrings; /* how many rings we are currently storing */
518  int maxrings; /* how many rings we have space for in **rings */
519  LWGEOM **rings; /* list of rings (list of points) */
520 }
521 LWCURVEPOLY; /* "light-weight polygon" */
522 
523 /* MULTICURVE */
524 typedef struct
525 {
526  uint8_t type;
527  uint8_t flags;
529  int32_t srid;
530  int ngeoms; /* how many geometries we are currently storing */
531  int maxgeoms; /* how many geometries we have space for in **geoms */
533 }
534 LWMCURVE;
535 
536 /* MULTISURFACETYPE */
537 typedef struct
538 {
539  uint8_t type;
540  uint8_t flags;
542  int32_t srid;
543  int ngeoms; /* how many geometries we are currently storing */
544  int maxgeoms; /* how many geometries we have space for in **geoms */
546 }
547 LWMSURFACE;
548 
549 /* POLYHEDRALSURFACETYPE */
550 typedef struct
551 {
552  uint8_t type;
553  uint8_t flags;
555  int32_t srid;
556  int ngeoms; /* how many geometries we are currently storing */
557  int maxgeoms; /* how many geometries we have space for in **geoms */
559 }
560 LWPSURFACE;
561 
562 /* TINTYPE */
563 typedef struct
564 {
565  uint8_t type;
566  uint8_t flags;
568  int32_t srid;
569  int ngeoms; /* how many geometries we are currently storing */
570  int maxgeoms; /* how many geometries we have space for in **geoms */
572 }
573 LWTIN;
574 
575 /* Casts LWGEOM->LW* (return NULL if cast is illegal) */
576 extern LWMPOLY *lwgeom_as_lwmpoly(const LWGEOM *lwgeom);
577 extern LWMLINE *lwgeom_as_lwmline(const LWGEOM *lwgeom);
578 extern LWMPOINT *lwgeom_as_lwmpoint(const LWGEOM *lwgeom);
579 extern LWCOLLECTION *lwgeom_as_lwcollection(const LWGEOM *lwgeom);
580 extern LWPOLY *lwgeom_as_lwpoly(const LWGEOM *lwgeom);
581 extern LWLINE *lwgeom_as_lwline(const LWGEOM *lwgeom);
582 extern LWPOINT *lwgeom_as_lwpoint(const LWGEOM *lwgeom);
583 extern LWCIRCSTRING *lwgeom_as_lwcircstring(const LWGEOM *lwgeom);
584 extern LWCURVEPOLY *lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom);
585 extern LWCOMPOUND *lwgeom_as_lwcompound(const LWGEOM *lwgeom);
586 extern LWPSURFACE *lwgeom_as_lwpsurface(const LWGEOM *lwgeom);
587 extern LWTRIANGLE *lwgeom_as_lwtriangle(const LWGEOM *lwgeom);
588 extern LWTIN *lwgeom_as_lwtin(const LWGEOM *lwgeom);
589 extern LWGEOM *lwgeom_as_multi(const LWGEOM *lwgeom);
590 extern LWGEOM *lwgeom_as_curve(const LWGEOM *lwgeom);
591 
592 /* Casts LW*->LWGEOM (always cast) */
593 extern LWGEOM *lwtin_as_lwgeom(const LWTIN *obj);
594 extern LWGEOM *lwtriangle_as_lwgeom(const LWTRIANGLE *obj);
595 extern LWGEOM *lwpsurface_as_lwgeom(const LWPSURFACE *obj);
596 extern LWGEOM *lwmpoly_as_lwgeom(const LWMPOLY *obj);
597 extern LWGEOM *lwmline_as_lwgeom(const LWMLINE *obj);
598 extern LWGEOM *lwmpoint_as_lwgeom(const LWMPOINT *obj);
599 extern LWGEOM *lwcollection_as_lwgeom(const LWCOLLECTION *obj);
600 extern LWGEOM *lwcircstring_as_lwgeom(const LWCIRCSTRING *obj);
601 extern LWGEOM *lwcompound_as_lwgeom(const LWCOMPOUND *obj);
602 extern LWGEOM *lwcurvepoly_as_lwgeom(const LWCURVEPOLY *obj);
603 extern LWGEOM *lwpoly_as_lwgeom(const LWPOLY *obj);
604 extern LWGEOM *lwline_as_lwgeom(const LWLINE *obj);
605 extern LWGEOM *lwpoint_as_lwgeom(const LWPOINT *obj);
606 
607 
608 extern LWCOLLECTION* lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom);
609 extern LWMPOINT* lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj);
610 extern LWMLINE* lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj);
611 extern LWMPOLY* lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj);
612 extern LWPSURFACE* lwpsurface_add_lwpoly(LWPSURFACE *mobj, const LWPOLY *obj);
613 extern LWTIN* lwtin_add_lwtriangle(LWTIN *mobj, const LWTRIANGLE *obj);
614 
615 
616 
617 /***********************************************************************
618 ** Utility functions for flag byte and srid_flag integer.
619 */
620 
624 extern uint8_t gflags(int hasz, int hasm, int geodetic);
625 
630 extern uint32_t gserialized_get_type(const GSERIALIZED *g);
631 
636 extern uint32_t gserialized_max_header_size(void);
637 
642 extern int32_t gserialized_get_srid(const GSERIALIZED *g);
643 
648 extern void gserialized_set_srid(GSERIALIZED *g, int32_t srid);
649 
656 extern int gserialized_is_empty(const GSERIALIZED *g);
657 
661 extern int gserialized_has_bbox(const GSERIALIZED *gser);
662 
666 extern int gserialized_has_z(const GSERIALIZED *gser);
667 
671 extern int gserialized_has_m(const GSERIALIZED *gser);
672 
676 extern int gserialized_is_geodetic(const GSERIALIZED *gser);
677 
682 extern int gserialized_get_zm(const GSERIALIZED *gser);
683 
687 extern int gserialized_ndims(const GSERIALIZED *gser);
688 
689 
696 extern void lwgeom_drop_bbox(LWGEOM *lwgeom);
697 extern void lwgeom_drop_srid(LWGEOM *lwgeom);
698 
705 extern void lwgeom_add_bbox(LWGEOM *lwgeom);
709 extern void lwgeom_add_bbox_deep(LWGEOM *lwgeom, GBOX *gbox);
710 
718 extern const GBOX *lwgeom_get_bbox(const LWGEOM *lwgeom);
719 
723 extern int lwgeom_is_collection(const LWGEOM *lwgeom);
724 
725 /******************************************************************/
726 /* Functions that work on type numbers */
727 
731 extern int lwtype_is_collection(uint8_t type);
732 
736 extern int lwtype_get_collectiontype(uint8_t type);
737 
742 extern const char *lwtype_name(uint8_t type);
743 
744 
745 /******************************************************************/
746 
747 /*
748  * copies a point from the point array into the parameter point
749  * will set point's z=0 (or NaN) if pa is 2d
750  * will set point's m=0 (or NaN) if pa is 3d or 2d
751  * NOTE: point is a real POINT3D *not* a pointer
752  */
753 extern POINT4D getPoint4d(const POINTARRAY *pa, int n);
754 
755 /*
756  * copies a point from the point array into the parameter point
757  * will set point's z=0 (or NaN) if pa is 2d
758  * will set point's m=0 (or NaN) if pa is 3d or 2d
759  * NOTE: this will modify the point4d pointed to by 'point'.
760  */
761 extern int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point);
762 
763 /*
764  * copies a point from the point array into the parameter point
765  * will set point's z=0 (or NaN) if pa is 2d
766  * NOTE: point is a real POINT3D *not* a pointer
767  */
768 extern POINT3DZ getPoint3dz(const POINTARRAY *pa, int n);
769 extern POINT3DM getPoint3dm(const POINTARRAY *pa, int n);
770 
771 /*
772  * copies a point from the point array into the parameter point
773  * will set point's z=0 (or NaN) if pa is 2d
774  * NOTE: this will modify the point3d pointed to by 'point'.
775  */
776 extern int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point);
777 extern int getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *point);
778 
779 
780 /*
781  * copies a point from the point array into the parameter point
782  * z value (if present is not returned)
783  * NOTE: point is a real POINT3D *not* a pointer
784  */
785 extern POINT2D getPoint2d(const POINTARRAY *pa, int n);
786 
787 /*
788  * copies a point from the point array into the parameter point
789  * z value (if present is not returned)
790  * NOTE: this will modify the point2d pointed to by 'point'.
791  */
792 extern int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point);
793 
800 extern const POINT2D* getPoint2d_cp(const POINTARRAY *pa, int n);
801 
808 extern const POINT3DZ* getPoint3dz_cp(const POINTARRAY *pa, int n);
809 
816 extern const POINT4D* getPoint4d_cp(const POINTARRAY *pa, int n);
817 
818 /*
819  * set point N to the given value
820  * NOTE that the pointarray can be of any
821  * dimension, the appropriate ordinate values
822  * will be extracted from it
823  *
824  * N must be a valid point index
825  */
826 extern void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d);
827 
828 /*
829  * get a pointer to nth point of a POINTARRAY
830  * You'll need to cast it to appropriate dimensioned point.
831  * Note that if you cast to a higher dimensional point you'll
832  * possibly corrupt the POINTARRAY.
833  *
834  * WARNING: Don't cast this to a POINT !
835  * it would not be reliable due to memory alignment constraints
836  */
837 extern uint8_t *getPoint_internal(const POINTARRAY *pa, int n);
838 
839 /*
840  * size of point represeneted in the POINTARRAY
841  * 16 for 2d, 24 for 3d, 32 for 4d
842  */
843 extern int ptarray_point_size(const POINTARRAY *pa);
844 
845 
851 extern POINTARRAY* ptarray_construct(char hasz, char hasm, uint32_t npoints);
852 
856 extern POINTARRAY* ptarray_construct_copy_data(char hasz, char hasm, uint32_t npoints, const uint8_t *ptlist);
857 
861 extern POINTARRAY* ptarray_construct_reference_data(char hasz, char hasm, uint32_t npoints, uint8_t *ptlist);
862 
868 extern POINTARRAY* ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints);
869 
875 extern int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates);
876 
888 extern int ptarray_append_ptarray(POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance);
889 
894 extern int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where);
895 
900 extern int ptarray_remove_point(POINTARRAY *pa, int where);
901 
913 extern POINTARRAY *ptarray_addPoint(const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where);
914 
920 extern POINTARRAY *ptarray_removePoint(POINTARRAY *pa, uint32_t where);
921 
928 extern POINTARRAY *ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2);
929 
930 extern int ptarray_is_closed(const POINTARRAY *pa);
931 extern int ptarray_is_closed_2d(const POINTARRAY *pa);
932 extern int ptarray_is_closed_3d(const POINTARRAY *pa);
933 extern int ptarray_is_closed_z(const POINTARRAY *pa);
934 extern void ptarray_longitude_shift(POINTARRAY *pa);
935 extern int ptarray_isccw(const POINTARRAY *pa);
936 extern void ptarray_reverse(POINTARRAY *pa);
938 
944 extern POINTARRAY *ptarray_substring(POINTARRAY *pa, double d1, double d2,
945  double tolerance);
946 
947 
951 extern LWGEOM* lwgeom_force_2d(const LWGEOM *geom);
952 extern LWGEOM* lwgeom_force_3dz(const LWGEOM *geom);
953 extern LWGEOM* lwgeom_force_3dm(const LWGEOM *geom);
954 extern LWGEOM* lwgeom_force_4d(const LWGEOM *geom);
955 
956 extern LWGEOM* lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed);
957 extern LWGEOM* lwgeom_set_effective_area(const LWGEOM *igeom, int set_area, double area);
958 
959 /*
960  * Force to use SFS 1.1 geometry type
961  * (rather than SFS 1.2 and/or SQL/MM)
962  */
963 extern LWGEOM* lwgeom_force_sfs(LWGEOM *geom, int version);
964 
965 
966 /*--------------------------------------------------------
967  * all the base types (point/line/polygon) will have a
968  * basic constructor, basic de-serializer, basic serializer,
969  * bounding box finder and (TODO) serialized form size finder.
970  *--------------------------------------------------------*/
971 
972 /*
973  * convenience functions to hide the POINTARRAY
974  */
975 extern int lwpoint_getPoint2d_p(const LWPOINT *point, POINT2D *out);
976 extern int lwpoint_getPoint3dz_p(const LWPOINT *point, POINT3DZ *out);
977 extern int lwpoint_getPoint3dm_p(const LWPOINT *point, POINT3DM *out);
978 extern int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out);
979 
980 /******************************************************************
981  * LWLINE functions
982  ******************************************************************/
983 
987 extern int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, int where);
988 
989 /******************************************************************
990  * LWPOLY functions
991  ******************************************************************/
992 
997 extern int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa);
998 
1003 extern int lwcurvepoly_add_ring(LWCURVEPOLY *poly, LWGEOM *ring);
1004 
1009 extern int lwcompound_add_lwgeom(LWCOMPOUND *comp, LWGEOM *geom);
1010 
1015 extern LWCOMPOUND* lwcompound_construct_from_lwline(const LWLINE *lwpoly);
1016 
1022 
1023 
1024 /******************************************************************
1025  * LWGEOM functions
1026  ******************************************************************/
1027 
1028 extern int lwcollection_ngeoms(const LWCOLLECTION *col);
1029 
1030 /* Given a generic geometry/collection, return the "simplest" form.
1031  * The elements of the homogenized collection are references to the
1032  * input geometry; a deep clone is not performed.
1033  * TODO: consider returning a geometry that does not reference the
1034  * input
1035  * */
1036 extern LWGEOM *lwgeom_homogenize(const LWGEOM *geom);
1037 
1038 
1039 /******************************************************************
1040  * LWMULTIx and LWCOLLECTION functions
1041  ******************************************************************/
1042 
1045 
1046 
1047 /******************************************************************
1048  * SERIALIZED FORM functions
1049  ******************************************************************/
1050 
1056 extern void lwgeom_set_srid(LWGEOM *geom, int srid);
1057 
1058 /*------------------------------------------------------
1059  * other stuff
1060  *
1061  * handle the double-to-float conversion. The results of this
1062  * will usually be a slightly bigger box because of the difference
1063  * between float8 and float4 representations.
1064  */
1065 
1066 extern BOX3D* box3d_from_gbox(const GBOX *gbox);
1067 extern GBOX* box3d_to_gbox(const BOX3D *b3d);
1068 
1069 void expand_box3d(BOX3D *box, double d);
1070 
1071 
1072 /****************************************************************
1073  * MEMORY MANAGEMENT
1074  ****************************************************************/
1075 
1076 /*
1077 * The *_free family of functions frees *all* memory associated
1078 * with the pointer. When the recursion gets to the level of the
1079 * POINTARRAY, the POINTARRAY is only freed if it is not flagged
1080 * as "read only". LWGEOMs constructed on top of GSERIALIZED
1081 * from PgSQL use read only point arrays.
1082 */
1083 
1084 extern void ptarray_free(POINTARRAY *pa);
1085 extern void lwpoint_free(LWPOINT *pt);
1086 extern void lwline_free(LWLINE *line);
1087 extern void lwpoly_free(LWPOLY *poly);
1088 extern void lwtriangle_free(LWTRIANGLE *triangle);
1089 extern void lwmpoint_free(LWMPOINT *mpt);
1090 extern void lwmline_free(LWMLINE *mline);
1091 extern void lwmpoly_free(LWMPOLY *mpoly);
1092 extern void lwpsurface_free(LWPSURFACE *psurf);
1093 extern void lwtin_free(LWTIN *tin);
1094 extern void lwcollection_free(LWCOLLECTION *col);
1095 extern void lwcircstring_free(LWCIRCSTRING *curve);
1096 extern void lwgeom_free(LWGEOM *geom);
1097 
1098 /*
1099 * The *_release family of functions frees the LWGEOM structures
1100 * surrounding the POINTARRAYs but leaves the POINTARRAYs
1101 * intact. Useful when re-shaping geometries between types,
1102 * or splicing geometries together.
1103 */
1104 
1105 extern void lwpoint_release(LWPOINT *lwpoint);
1106 extern void lwline_release(LWLINE *lwline);
1107 extern void lwpoly_release(LWPOLY *lwpoly);
1108 extern void lwtriangle_release(LWTRIANGLE *lwtriangle);
1109 extern void lwcircstring_release(LWCIRCSTRING *lwcirc);
1110 extern void lwmpoint_release(LWMPOINT *lwpoint);
1111 extern void lwmline_release(LWMLINE *lwline);
1112 extern void lwmpoly_release(LWMPOLY *lwpoly);
1113 extern void lwpsurface_release(LWPSURFACE *lwpsurface);
1114 extern void lwtin_release(LWTIN *lwtin);
1115 extern void lwcollection_release(LWCOLLECTION *lwcollection);
1116 extern void lwgeom_release(LWGEOM *lwgeom);
1117 
1118 
1119 /****************************************************************
1120 * Utility
1121 ****************************************************************/
1122 
1123 extern void printBOX3D(BOX3D *b);
1124 extern void printPA(POINTARRAY *pa);
1125 extern void printLWPOINT(LWPOINT *point);
1126 extern void printLWLINE(LWLINE *line);
1127 extern void printLWPOLY(LWPOLY *poly);
1128 extern void printLWTRIANGLE(LWTRIANGLE *triangle);
1129 extern void printLWPSURFACE(LWPSURFACE *psurf);
1130 extern void printLWTIN(LWTIN *tin);
1131 
1132 extern float next_float_down(double d);
1133 extern float next_float_up(double d);
1134 extern double next_double_down(float d);
1135 extern double next_double_up(float d);
1136 
1137 /* general utilities 2D */
1138 extern double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2);
1139 extern double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2);
1140 extern double distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B);
1141 extern double distance2d_sqr_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B);
1142 extern LWGEOM* lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2);
1143 extern LWGEOM* lwgeom_furthest_line(const LWGEOM *lw1, const LWGEOM *lw2);
1144 extern LWGEOM* lwgeom_closest_point(const LWGEOM *lw1, const LWGEOM *lw2);
1145 extern LWGEOM* lwgeom_furthest_point(const LWGEOM *lw1, const LWGEOM *lw2);
1146 extern double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2);
1147 extern double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance);
1148 extern double lwgeom_maxdistance2d(const LWGEOM *lw1, const LWGEOM *lw2);
1149 extern double lwgeom_maxdistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance);
1150 
1151 /* 3D */
1152 extern double distance3d_pt_pt(const POINT3D *p1, const POINT3D *p2);
1153 extern double distance3d_pt_seg(const POINT3D *p, const POINT3D *A, const POINT3D *B);
1154 
1155 extern LWGEOM* lwgeom_furthest_line_3d(LWGEOM *lw1, LWGEOM *lw2);
1156 extern LWGEOM* lwgeom_closest_line_3d(const LWGEOM *lw1, const LWGEOM *lw2);
1157 extern LWGEOM* lwgeom_closest_point_3d(const LWGEOM *lw1, const LWGEOM *lw2);
1158 
1159 
1160 extern double lwgeom_mindistance3d(const LWGEOM *lw1, const LWGEOM *lw2);
1161 extern double lwgeom_mindistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance);
1162 extern double lwgeom_maxdistance3d(const LWGEOM *lw1, const LWGEOM *lw2);
1163 extern double lwgeom_maxdistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance);
1164 
1165 extern double lwgeom_area(const LWGEOM *geom);
1166 extern double lwgeom_length(const LWGEOM *geom);
1167 extern double lwgeom_length_2d(const LWGEOM *geom);
1168 extern double lwgeom_perimeter(const LWGEOM *geom);
1169 extern double lwgeom_perimeter_2d(const LWGEOM *geom);
1170 extern void lwgeom_affine(LWGEOM *geom, const AFFINE *affine);
1171 extern void lwgeom_scale(LWGEOM *geom, const POINT4D *factors);
1172 extern int lwgeom_dimension(const LWGEOM *geom);
1173 
1174 extern LWPOINT* lwline_get_lwpoint(const LWLINE *line, int where);
1175 extern LWPOINT* lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, int where);
1176 
1177 extern LWPOINT* lwcompound_get_startpoint(const LWCOMPOUND *lwcmp);
1178 extern LWPOINT* lwcompound_get_endpoint(const LWCOMPOUND *lwcmp);
1179 extern LWPOINT* lwcompound_get_lwpoint(const LWCOMPOUND *lwcmp, int where);
1180 
1181 
1182 extern double ptarray_length_2d(const POINTARRAY *pts);
1183 extern double ptarray_length(const POINTARRAY *pts);
1184 extern double ptarray_arc_length_2d(const POINTARRAY *pts);
1185 
1186 
1187 extern int pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring);
1188 extern int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret);
1189 extern int lwpoint_inside_circle(const LWPOINT *p, double cx, double cy, double rad);
1190 extern void lwgeom_reverse(LWGEOM *lwgeom);
1191 extern void lwline_reverse(LWLINE *line);
1192 extern void lwpoly_reverse(LWPOLY *poly);
1193 extern void lwtriangle_reverse(LWTRIANGLE *triangle);
1194 extern char* lwgeom_summary(const LWGEOM *lwgeom, int offset);
1195 extern char* lwpoint_to_latlon(const LWPOINT *p, const char *format);
1196 extern int lwgeom_startpoint(const LWGEOM* lwgeom, POINT4D* pt);
1197 
1202 extern void lwgeom_force_clockwise(LWGEOM *lwgeom);
1203 extern void lwpoly_force_clockwise(LWPOLY *poly);
1204 extern void lwtriangle_force_clockwise(LWTRIANGLE *triangle);
1205 
1206 
1207 extern void interpolate_point4d(POINT4D *A, POINT4D *B, POINT4D *I, double F);
1208 
1209 void lwgeom_longitude_shift(LWGEOM *lwgeom);
1210 
1211 
1221 extern int lwgeom_needs_bbox(const LWGEOM *geom);
1222 
1226 extern int lwgeom_count_vertices(const LWGEOM *geom);
1227 
1232 extern int lwgeom_count_rings(const LWGEOM *geom);
1233 
1238 extern int lwgeom_has_srid(const LWGEOM *geom);
1239 
1244 extern int lwgeom_is_empty(const LWGEOM *geom);
1245 
1250 extern int lwgeom_is_closed(const LWGEOM *geom);
1251 
1255 extern int lwgeom_dimensionality(LWGEOM *geom);
1256 
1257 /* Is lwgeom1 geometrically equal to lwgeom2 ? */
1258 char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2);
1259 char ptarray_same(const POINTARRAY *pa1, const POINTARRAY *pa2);
1260 char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2);
1261 char lwline_same(const LWLINE *p1, const LWLINE *p2);
1262 char lwpoly_same(const LWPOLY *p1, const LWPOLY *p2);
1263 char lwtriangle_same(const LWTRIANGLE *p1, const LWTRIANGLE *p2);
1264 char lwcollection_same(const LWCOLLECTION *p1, const LWCOLLECTION *p2);
1265 char lwcircstring_same(const LWCIRCSTRING *p1, const LWCIRCSTRING *p2);
1266 
1267 
1275 extern LWGEOM *lwgeom_clone(const LWGEOM *lwgeom);
1276 
1280 extern LWGEOM *lwgeom_clone_deep(const LWGEOM *lwgeom);
1281 
1282 /* TODO Move to Internal */
1283 LWPOINT *lwpoint_clone(const LWPOINT *lwgeom);
1284 POINTARRAY *ptarray_clone_deep(const POINTARRAY *ptarray);
1285 
1286 
1287 /*
1288 * Geometry constructors. These constructors to not copy the point arrays
1289 * passed to them, they just take references, so do not free them out
1290 * from underneath the geometries.
1291 */
1292 extern LWPOINT* lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point);
1293 extern LWMPOINT *lwmpoint_construct(int srid, const POINTARRAY *pa);
1294 extern LWLINE* lwline_construct(int srid, GBOX *bbox, POINTARRAY *points);
1295 extern LWCIRCSTRING* lwcircstring_construct(int srid, GBOX *bbox, POINTARRAY *points);
1296 extern LWPOLY* lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points);
1297 extern LWCURVEPOLY* lwcurvepoly_construct(int srid, GBOX *bbox, uint32_t nrings, LWGEOM **geoms);
1298 extern LWTRIANGLE* lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points);
1299 extern LWCOLLECTION* lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms);
1300 /*
1301 * Empty geometry constructors.
1302 */
1303 extern LWGEOM* lwgeom_construct_empty(uint8_t type, int srid, char hasz, char hasm);
1304 extern LWPOINT* lwpoint_construct_empty(int srid, char hasz, char hasm);
1305 extern LWLINE* lwline_construct_empty(int srid, char hasz, char hasm);
1306 extern LWPOLY* lwpoly_construct_empty(int srid, char hasz, char hasm);
1307 extern LWCURVEPOLY* lwcurvepoly_construct_empty(int srid, char hasz, char hasm);
1308 extern LWCIRCSTRING* lwcircstring_construct_empty(int srid, char hasz, char hasm);
1309 extern LWCOMPOUND* lwcompound_construct_empty(int srid, char hasz, char hasm);
1310 extern LWTRIANGLE* lwtriangle_construct_empty(int srid, char hasz, char hasm);
1311 extern LWMPOINT* lwmpoint_construct_empty(int srid, char hasz, char hasm);
1312 extern LWMLINE* lwmline_construct_empty(int srid, char hasz, char hasm);
1313 extern LWMPOLY* lwmpoly_construct_empty(int srid, char hasz, char hasm);
1314 extern LWCOLLECTION* lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm);
1315 
1316 
1317 /* Other constructors */
1318 extern LWPOINT *lwpoint_make2d(int srid, double x, double y);
1319 extern LWPOINT *lwpoint_make3dz(int srid, double x, double y, double z);
1320 extern LWPOINT *lwpoint_make3dm(int srid, double x, double y, double m);
1321 extern LWPOINT *lwpoint_make4d(int srid, double x, double y, double z, double m);
1322 extern LWPOINT *lwpoint_make(int srid, int hasz, int hasm, const POINT4D *p);
1323 extern LWLINE *lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms);
1324 extern LWLINE *lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points); /* TODO: deprecate */
1325 extern LWLINE *lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint);
1326 extern LWLINE *lwline_addpoint(LWLINE *line, LWPOINT *point, uint32_t where);
1327 extern LWLINE *lwline_removepoint(LWLINE *line, uint32_t which);
1328 extern void lwline_setPoint4d(LWLINE *line, uint32_t which, POINT4D *newpoint);
1329 extern LWPOLY *lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes);
1330 extern LWTRIANGLE *lwtriangle_from_lwline(const LWLINE *shell);
1331 
1332 
1333 /* Some point accessors */
1334 extern double lwpoint_get_x(const LWPOINT *point);
1335 extern double lwpoint_get_y(const LWPOINT *point);
1336 extern double lwpoint_get_z(const LWPOINT *point);
1337 extern double lwpoint_get_m(const LWPOINT *point);
1338 
1342 extern int32_t lwgeom_get_srid(const LWGEOM *geom);
1343 
1347 extern uint32_t lwgeom_get_type(const LWGEOM *geom);
1348 
1352 extern int lwgeom_has_z(const LWGEOM *geom);
1353 
1357 extern int lwgeom_has_m(const LWGEOM *geom);
1358 
1362 extern int lwgeom_ndims(const LWGEOM *geom);
1363 
1364 /*
1365  * Given a point, returns the location of closest point on pointarray
1366  * as a fraction of total length (0: first point -- 1: last point).
1367  *
1368  * If not-null, the third argument will be set to the actual distance
1369  * of the point from the pointarray.
1370  */
1371 extern double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located);
1372 
1377 extern LWLINE *lwline_measured_from_lwline(const LWLINE *lwline, double m_start, double m_end);
1378 extern LWMLINE* lwmline_measured_from_lwmline(const LWMLINE *lwmline, double m_start, double m_end);
1379 
1384 extern LWGEOM* lwgeom_locate_along(const LWGEOM *lwin, double m, double offset);
1385 
1391 extern LWCOLLECTION* lwgeom_locate_between(const LWGEOM *lwin, double from, double to, double offset);
1392 
1396 extern double lwgeom_interpolate_point(const LWGEOM *lwin, const LWPOINT *lwpt);
1397 
1408 extern double lwgeom_tcpa(const LWGEOM *g1, const LWGEOM *g2, double *mindist);
1409 
1415 extern int lwgeom_cpa_within(const LWGEOM *g1, const LWGEOM *g2, double maxdist);
1416 
1421 extern int lwgeom_is_trajectory(const LWGEOM *geom);
1422 extern int lwline_is_trajectory(const LWLINE *geom);
1423 
1424 /*
1425  * Ensure every segment is at most 'dist' long.
1426  * Returned LWGEOM might is unchanged if a POINT.
1427  */
1428 extern LWGEOM *lwgeom_segmentize2d(LWGEOM *line, double dist);
1429 extern POINTARRAY *ptarray_segmentize2d(const POINTARRAY *ipa, double dist);
1430 extern LWLINE *lwline_segmentize2d(LWLINE *line, double dist);
1431 extern LWPOLY *lwpoly_segmentize2d(LWPOLY *line, double dist);
1432 extern LWCOLLECTION *lwcollection_segmentize2d(LWCOLLECTION *coll, double dist);
1433 
1437 char *lwgeom_geohash(const LWGEOM *lwgeom, int precision);
1438 unsigned int geohash_point_as_int(POINT2D *pt);
1439 
1440 
1452 };
1453 
1457 int lwline_crossing_direction(const LWLINE *l1, const LWLINE *l2);
1458 
1462 LWCOLLECTION* lwgeom_clip_to_ordinate_range(const LWGEOM *lwin, char ordinate, double from, double to, double offset);
1463 
1469 #define LW_GML_IS_DIMS (1<<0)
1470 
1471 #define LW_GML_IS_DEGREE (1<<1)
1472 
1473 #define LW_GML_SHORTLINE (1<<2)
1474 
1475 #define LW_GML_EXTENT (1<<4)
1476 
1477 
1478 #define IS_DIMS(x) ((x) & LW_GML_IS_DIMS)
1479 #define IS_DEGREE(x) ((x) & LW_GML_IS_DEGREE)
1480 
1487 #define LW_X3D_FLIP_XY (1<<0)
1488 #define LW_X3D_USE_GEOCOORDS (1<<1)
1489 #define X3D_USE_GEOCOORDS(x) ((x) & LW_X3D_USE_GEOCOORDS)
1490 
1491 
1492 
1493 extern char* lwgeom_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix);
1494 extern char* lwgeom_extent_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix);
1498 extern char* lwgeom_extent_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix);
1499 extern char* lwgeom_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix, const char *id);
1500 extern char* lwgeom_to_kml2(const LWGEOM *geom, int precision, const char *prefix);
1501 extern char* lwgeom_to_geojson(const LWGEOM *geo, char *srs, int precision, int has_bbox);
1502 extern char* lwgeom_to_svg(const LWGEOM *geom, int precision, int relative);
1503 extern char* lwgeom_to_x3d3(const LWGEOM *geom, char *srs, int precision, int opts, const char *defid);
1504 extern char* lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision);
1505 
1515 extern LWGEOM* lwgeom_from_geojson(const char *geojson, char **srs);
1516 
1522 extern LWGEOM* lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision);
1523 
1527 extern void spheroid_init(SPHEROID *s, double a, double b);
1528 
1534 extern double lwgeom_distance_spheroid(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2, const SPHEROID *spheroid, double tolerance);
1535 
1539 extern LWPOINT* lwgeom_project_spheroid(const LWPOINT *r, const SPHEROID *spheroid, double distance, double azimuth);
1540 
1545 extern LWGEOM* lwgeom_segmentize_sphere(const LWGEOM *lwg_in, double max_seg_length);
1546 
1550 extern double lwgeom_azumith_spheroid(const LWPOINT *r, const LWPOINT *s, const SPHEROID *spheroid);
1551 
1556 extern double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid);
1557 
1562 extern double lwgeom_area_spheroid(const LWGEOM *lwgeom, const SPHEROID *spheroid);
1563 
1568 extern double lwgeom_length_spheroid(const LWGEOM *geom, const SPHEROID *s);
1569 
1574 extern int lwgeom_covers_lwgeom_sphere(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2);
1575 
1579 extern LWGEOM* lwgeom_remove_repeated_points(LWGEOM *in, double tolerance);
1580 
1581 extern char lwtriangle_is_repeated_points(LWTRIANGLE *triangle);
1582 
1595 extern void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2);
1596 
1605 
1609 extern uint8_t parse_hex(char *str);
1610 
1614 extern void deparse_hex(uint8_t str, char *result);
1615 
1616 
1617 
1618 /***********************************************************************
1619 ** Functions for managing serialized forms and bounding boxes.
1620 */
1621 
1628 
1635 
1640 extern char* gserialized_to_string(const GSERIALIZED *g);
1641 
1645 extern GSERIALIZED* gserialized_copy(const GSERIALIZED *g);
1646 
1650 extern int lwgeom_check_geodetic(const LWGEOM *geom);
1651 
1655 extern int lwgeom_nudge_geodetic(LWGEOM *geom);
1656 
1660 extern int lwgeom_force_geodetic(LWGEOM *geom);
1661 
1665 extern void lwgeom_set_geodetic(LWGEOM *geom, int value);
1666 
1673 extern int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox);
1674 
1680 extern int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox);
1681 
1686 extern int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox);
1687 
1692 extern int getPoint2d_p_ro(const POINTARRAY *pa, int n, POINT2D **point);
1693 
1697 extern int ptarray_calculate_gbox_geodetic(const POINTARRAY *pa, GBOX *gbox);
1698 
1702 extern int ptarray_calculate_gbox_cartesian(const POINTARRAY *pa, GBOX *gbox );
1703 
1707 void gbox_pt_outside(const GBOX *gbox, POINT2D *pt_outside);
1708 
1713 extern GBOX* gbox_new(uint8_t flags);
1714 
1719 extern void gbox_init(GBOX *gbox);
1720 
1724 extern int gbox_merge(const GBOX *new_box, GBOX *merged_box);
1725 
1729 extern int gbox_union(const GBOX *g1, const GBOX *g2, GBOX *gout);
1730 
1734 extern void gbox_expand(GBOX *g, double d);
1735 
1739 extern int gbox_init_point3d(const POINT3D *p, GBOX *gbox);
1740 
1744 extern int gbox_merge_point3d(const POINT3D *p, GBOX *gbox);
1745 
1749 extern int gbox_contains_point3d(const GBOX *gbox, const POINT3D *pt);
1750 
1754 extern char* gbox_to_string(const GBOX *gbox);
1755 
1759 extern GBOX* gbox_copy(const GBOX *gbox);
1760 
1764 extern GBOX* gbox_from_string(const char *str);
1765 
1769 extern int gbox_overlaps(const GBOX *g1, const GBOX *g2);
1770 
1774 extern int gbox_overlaps_2d(const GBOX *g1, const GBOX *g2);
1775 
1779 extern int gbox_contains_2d(const GBOX *g1, const GBOX *g2);
1780 
1784 extern void gbox_duplicate(const GBOX *original, GBOX *duplicate);
1785 
1790 extern size_t gbox_serialized_size(uint8_t flags);
1791 
1795 extern int gbox_same(const GBOX *g1, const GBOX *g2);
1796 
1800 extern int gbox_same_2d(const GBOX *g1, const GBOX *g2);
1801 
1806 extern int gbox_same_2d_float(const GBOX *g1, const GBOX *g2);
1807 
1814 extern void gbox_float_round(GBOX *gbox);
1815 
1819 extern int gbox_is_valid(const GBOX *gbox);
1820 
1825 extern int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m);
1826 
1832 extern size_t gserialized_from_lwgeom_size(const LWGEOM *geom);
1833 
1841 extern GSERIALIZED* gserialized_from_lwgeom(LWGEOM *geom, int is_geodetic, size_t *size);
1842 
1847 extern LWGEOM* lwgeom_from_gserialized(const GSERIALIZED *g);
1848 
1854 extern int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *gbox);
1855 
1856 
1864 #define LW_PARSER_CHECK_MINPOINTS 1
1865 #define LW_PARSER_CHECK_ODD 2
1866 #define LW_PARSER_CHECK_CLOSURE 4
1867 #define LW_PARSER_CHECK_ZCLOSURE 8
1868 
1869 #define LW_PARSER_CHECK_NONE 0
1870 #define LW_PARSER_CHECK_ALL (LW_PARSER_CHECK_MINPOINTS | LW_PARSER_CHECK_ODD | LW_PARSER_CHECK_CLOSURE)
1871 
1877 {
1878  const char *wkinput; /* Copy of pointer to input WKT/WKB */
1879  uint8_t *serialized_lwgeom; /* Pointer to serialized LWGEOM */
1880  int size; /* Size of serialized LWGEOM in bytes */
1881  LWGEOM *geom; /* Pointer to LWGEOM struct */
1882  const char *message; /* Error/warning message */
1883  int errcode; /* Error/warning number */
1884  int errlocation; /* Location of error */
1885  int parser_check_flags; /* Bitmask of validity checks run during this parse */
1886 }
1888 
1889 /*
1890  * Parser error messages (these must match the message array in lwgparse.c)
1891  */
1892 #define PARSER_ERROR_MOREPOINTS 1
1893 #define PARSER_ERROR_ODDPOINTS 2
1894 #define PARSER_ERROR_UNCLOSED 3
1895 #define PARSER_ERROR_MIXDIMS 4
1896 #define PARSER_ERROR_INVALIDGEOM 5
1897 #define PARSER_ERROR_INVALIDWKBTYPE 6
1898 #define PARSER_ERROR_INCONTINUOUS 7
1899 #define PARSER_ERROR_TRIANGLEPOINTS 8
1900 #define PARSER_ERROR_LESSPOINTS 9
1901 #define PARSER_ERROR_OTHER 10
1902 
1903 
1904 
1905 /*
1906  * Unparser result structure: returns the result of attempting to convert LWGEOM to (E)WKT/(E)WKB
1907  */
1909 {
1910  uint8_t *serialized_lwgeom; /* Copy of pointer to input serialized LWGEOM */
1911  char *wkoutput; /* Pointer to WKT or WKB output */
1912  int size; /* Size of serialized LWGEOM in bytes */
1913  const char *message; /* Error/warning message */
1914  int errlocation; /* Location of error */
1915 }
1917 
1918 /*
1919  * Unparser error messages (these must match the message array in lwgunparse.c)
1920  */
1921 #define UNPARSER_ERROR_MOREPOINTS 1
1922 #define UNPARSER_ERROR_ODDPOINTS 2
1923 #define UNPARSER_ERROR_UNCLOSED 3
1924 
1925 
1926 /*
1927 ** Variants available for WKB and WKT output types
1928 */
1929 
1930 #define WKB_ISO 0x01
1931 #define WKB_SFSQL 0x02
1932 #define WKB_EXTENDED 0x04
1933 #define WKB_NDR 0x08
1934 #define WKB_XDR 0x10
1935 #define WKB_HEX 0x20
1936 #define WKB_NO_NPOINTS 0x40 /* Internal use only */
1937 #define WKB_NO_SRID 0x80 /* Internal use only */
1938 
1939 #define WKT_ISO 0x01
1940 #define WKT_SFSQL 0x02
1941 #define WKT_EXTENDED 0x04
1942 
1943 
1944 /*
1945 ** Variants available for TWKB
1946 */
1947 #define TWKB_BBOX 0x01 /* User wants bboxes */
1948 #define TWKB_SIZE 0x02 /* User wants sizes */
1949 #define TWKB_ID 0x04 /* User wants id */
1950 #define TWKB_NO_TYPE 0x10 /* No type because it is a sub geoemtry */
1951 #define TWKB_NO_ID 0x20 /* No ID because it is a subgeoemtry */
1952 #define TWKB_DEFAULT_PRECISION 0 /* Aim for 1m (or ft) rounding by default */
1953 
1954 /*
1955 ** New parsing and unparsing functions.
1956 */
1957 
1962 extern char* lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out);
1963 
1969 extern uint8_t* lwgeom_to_wkb(const LWGEOM *geom, uint8_t variant, size_t *size_out);
1970 
1976 extern char* lwgeom_to_hexwkb(const LWGEOM *geom, uint8_t variant, size_t *size_out);
1977 
1981 extern char *lwgeom_to_ewkt(const LWGEOM *lwgeom);
1982 
1988 extern LWGEOM* lwgeom_from_wkb(const uint8_t *wkb, const size_t wkb_size, const char check);
1989 
1994 extern LWGEOM* lwgeom_from_wkt(const char *wkt, const char check);
1995 
1999 extern LWGEOM* lwgeom_from_hexwkb(const char *hexwkb, const char check);
2000 
2001 extern uint8_t* bytes_from_hexbytes(const char *hexbuf, size_t hexsize);
2002 
2003 extern char* hexbytes_from_bytes(uint8_t *bytes, size_t size);
2004 
2005 /*
2006 * WKT detailed parsing support
2007 */
2008 extern int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags);
2009 void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result);
2010 void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result);
2011 
2012 
2013 /* Memory management */
2014 extern void *lwalloc(size_t size);
2015 extern void *lwrealloc(void *mem, size_t size);
2016 extern void lwfree(void *mem);
2017 
2018 /* Utilities */
2019 extern char *lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection);
2020 
2021 /*
2022 * TWKB functions
2023 */
2024 
2029 extern LWGEOM* lwgeom_from_twkb(uint8_t *twkb, size_t twkb_size, char check);
2030 
2036 extern uint8_t* lwgeom_to_twkb(const LWGEOM *geom, uint8_t variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m, size_t *twkb_size);
2037 
2038 extern uint8_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, size_t *twkb_size);
2039 
2040 /*******************************************************************************
2041  * SQLMM internal functions - TODO: Move into separate header files
2042  ******************************************************************************/
2043 
2044 int lwgeom_has_arc(const LWGEOM *geom);
2045 LWGEOM *lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad);
2047 
2048 /*******************************************************************************
2049  * GEOS proxy functions on LWGEOM
2050  ******************************************************************************/
2051 
2053 const char* lwgeom_geos_version(void);
2054 
2057 
2059 LWGEOM *lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2);
2060 LWGEOM *lwgeom_difference(const LWGEOM *geom1, const LWGEOM *geom2);
2061 LWGEOM *lwgeom_symdifference(const LWGEOM* geom1, const LWGEOM* geom2);
2062 LWGEOM *lwgeom_union(const LWGEOM *geom1, const LWGEOM *geom2);
2063 LWGEOM *lwgeom_linemerge(const LWGEOM *geom1);
2064 LWGEOM *lwgeom_unaryunion(const LWGEOM *geom1);
2065 LWGEOM *lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1);
2066 LWCOLLECTION *lwgeom_subdivide(const LWGEOM *geom, int maxvertices);
2067 
2077 LWGEOM* lwgeom_snap(const LWGEOM* geom1, const LWGEOM* geom2, double tolerance);
2078 
2079 /*
2080  * Return the set of paths shared between two linear geometries,
2081  * and their direction (same or opposite).
2082  *
2083  * @param geom1 a lineal geometry
2084  * @param geom2 another lineal geometry
2085  *
2086  * Requires GEOS-3.3.0+
2087  */
2088 LWGEOM* lwgeom_sharedpaths(const LWGEOM* geom1, const LWGEOM* geom2);
2089 
2090 /*
2091  * An offset curve against the input line.
2092  *
2093  * @param lwline a lineal geometry
2094  * @param size offset distance. Offset left if negative and right if positive
2095  * @param quadsegs number of quadrature segments in curves (try 8)
2096  * @param joinStyle (1 = round, 2 = mitre, 3 = bevel)
2097  * @param mitreLimit (try 5.0)
2098  * @return derived geometry (linestring or multilinestring)
2099  *
2100  * Requires GEOS-3.2.0+
2101  */
2102 LWGEOM* lwgeom_offsetcurve(const LWLINE *lwline, double size, int quadsegs, int joinStyle, double mitreLimit);
2103 
2104 /*
2105  * Return true if the input geometry is "simple" as per OGC defn.
2106  *
2107  * @return 1 if simple, 0 if non-simple, -1 on exception (lwerror is called
2108  * in that case)
2109  */
2110 int lwgeom_is_simple(const LWGEOM *lwgeom);
2111 
2112 
2113 /*******************************************************************************
2114  * PROJ4-dependent extra functions on LWGEOM
2115  ******************************************************************************/
2116 
2122 projPJ lwproj_from_string(const char* txt);
2123 
2130 int lwgeom_transform(LWGEOM *geom, projPJ inpj, projPJ outpj) ;
2131 int ptarray_transform(POINTARRAY *geom, projPJ inpj, projPJ outpj) ;
2132 int point4d_transform(POINT4D *pt, projPJ srcpj, projPJ dstpj) ;
2133 
2134 
2135 /*******************************************************************************
2136  * GEOS-dependent extra functions on LWGEOM
2137  ******************************************************************************/
2138 
2147 
2148 
2156 
2157 /*
2158  * Split (multi)polygon by line; (multi)line by (multi)line,
2159  * (multi)point or (multi)polygon boundary.
2160  *
2161  * Collections are accepted as first argument.
2162  * Returns all obtained pieces as a collection.
2163  */
2164 LWGEOM* lwgeom_split(const LWGEOM* lwgeom_in, const LWGEOM* blade_in);
2165 
2166 /*
2167  * Fully node a set of linestrings, using the least nodes preserving
2168  * all the input ones.
2169  *
2170  * Requires GEOS-3.3.0 or higher
2171  */
2172 LWGEOM* lwgeom_node(const LWGEOM* lwgeom_in);
2173 
2183 LWGEOM* lwgeom_delaunay_triangulation(const LWGEOM *geom, double tolerance, int edgeOnly);
2184 
2185 #endif /* !defined _LIBLWGEOM_H */
2186 
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
Definition: lwgeom_api.c:536
int ngeoms
Definition: liblwgeom.h:530
int32_t srid
Definition: liblwgeom.h:503
LWCOMPOUND * lwcompound_construct_empty(int srid, char hasz, char hasm)
Definition: lwcompound.c:110
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
Definition: lwgeodetic.c:2615
char * lwgeom_to_hexwkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
Definition: lwout_wkb.c:834
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, int is_geodetic, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
Definition: g_serialized.c:906
double lwgeom_mindistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling 3d min distance calculations and dwithin calculations.
Definition: measures3d.c:339
int32_t srid
Definition: liblwgeom.h:263
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:367
uint8_t type
Definition: liblwgeom.h:402
uint8_t flags
Definition: liblwgeom.h:553
int clamp_srid(int srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...
Definition: lwutil.c:350
LWGEOM * lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad)
Definition: lwstroke.c:446
uint8_t flags
Definition: liblwgeom.h:527
LWGEOM * lwgeom_set_effective_area(const LWGEOM *igeom, int set_area, double area)
char * lwgeom_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
VERSION GML 2 takes a GEOMETRY and returns a GML2 representation.
Definition: lwout_gml.c:218
uint8_t type
Definition: liblwgeom.h:461
double z
Definition: liblwgeom.h:318
int gbox_overlaps(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the GBOX overlaps, LW_FALSE otherwise.
Definition: g_box.c:260
size_t gserialized_from_lwgeom_size(const LWGEOM *geom)
Calculate required memory segment to contain a serialized form of the LWGEOM.
Definition: g_serialized.c:539
GBOX * gbox_from_string(const char *str)
Warning, do not use this function, it is very particular about inputs.
Definition: g_box.c:341
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:947
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:62
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:611
LWTIN * lwtin_add_lwtriangle(LWTIN *mobj, const LWTRIANGLE *obj)
Definition: lwtin.c:21
GBOX * bbox
Definition: liblwgeom.h:382
POINT2D getPoint2d(const POINTARRAY *pa, int n)
Definition: lwgeom_api.c:434
uint8_t flags
Definition: liblwgeom.h:425
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
Definition: lwline.c:51
POINTARRAY * points
Definition: liblwgeom.h:417
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
Definition: lwpoint.c:233
GBOX * bbox
Definition: liblwgeom.h:450
void printLWPSURFACE(LWPSURFACE *psurf)
Definition: lwpsurface.c:44
int lwtype_get_collectiontype(uint8_t type)
Given an lwtype number, what homogeneous collection can hold it?
Definition: lwgeom.c:1026
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:2034
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
Definition: lwspheroid.c:25
uint8_t * serialized_pointlist
Definition: liblwgeom.h:350
int lwgeom_has_srid(const LWGEOM *geom)
Return true or false depending on whether a geometry has a valid SRID set.
Definition: lwgeom.c:1340
uint8_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, size_t *twkb_size)
Convert LWGEOM to a char* in TWKB format.
Definition: lwout_twkb.c:546
GBOX * bbox
Definition: liblwgeom.h:404
uint8_t variant
Definition: cu_in_twkb.c:26
LWGEOM * lwgeom_closest_point(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures.c:40
void lwmpoly_release(LWMPOLY *lwpoly)
Definition: lwmpoly.c:21
uint8_t * bytes_from_hexbytes(const char *hexbuf, size_t hexsize)
Definition: lwin_wkb.c:72
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:991
void lwtin_release(LWTIN *lwtin)
LWGEOM * lwgeom_sharedpaths(const LWGEOM *geom1, const LWGEOM *geom2)
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
Definition: lwcollection.c:353
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:30
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:2050
uint8_t type
Definition: liblwgeom.h:391
char * r
Definition: cu_in_wkt.c:24
int gserialized_get_zm(const GSERIALIZED *gser)
Return a number indicating presence of Z and M coordinates.
Definition: g_serialized.c:34
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:655
char * lwgeom_to_x3d3(const LWGEOM *geom, char *srs, int precision, int opts, const char *defid)
Definition: lwout_x3d.c:48
int maxgeoms
Definition: liblwgeom.h:479
int lwcollection_ngeoms(const LWCOLLECTION *col)
Definition: lwcollection.c:288
void lwmline_free(LWMLINE *mline)
Definition: lwmline.c:98
LWLINE * lwline_segmentize2d(LWLINE *line, double dist)
Definition: lwline.c:134
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: g_serialized.c:19
void lwfree(void *mem)
Definition: lwutil.c:214
LWTRIANGLE * lwtriangle_construct_empty(int srid, char hasz, char hasm)
Definition: lwtriangle.c:45
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
Definition: g_util.c:130
uint8_t flags
Definition: liblwgeom.h:540
double lwgeom_maxdistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling max distance calculations and dfyllywithin calculations.
Definition: measures.c:167
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
Definition: g_serialized.c:29
LWGEOM ** rings
Definition: liblwgeom.h:519
int npoints
Definition: liblwgeom.h:355
double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin calculations.
Definition: measures.c:199
LWGEOM * lwgeom_force_4d(const LWGEOM *geom)
Definition: lwgeom.c:708
struct struct_lwgeom_unparser_result LWGEOM_UNPARSER_RESULT
int gbox_same_2d(const GBOX *g1, const GBOX *g2)
Check if 2 given GBOX are the same in x and y.
Definition: g_box.c:156
uint8_t type
Definition: liblwgeom.h:487
void lwgeom_cancel_interrupt(void)
Cancel any interruption request.
Definition: lwgeom_api.c:828
void deparse_hex(uint8_t str, char *result)
Convert a char into a human readable hex digit.
Definition: lwgeom_api.c:774
double lwgeom_mindistance3d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing 3d min distance calculation.
Definition: measures3d.c:328
LWGEOM * lwcollection_getsubgeom(LWCOLLECTION *col, int gnum)
Definition: lwcollection.c:100
int lwline_crossing_direction(const LWLINE *l1, const LWLINE *l2)
Given two lines, characterize how (and if) they cross each other.
Definition: lwalgorithm.c:446
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
Definition: lwgeom.c:829
int ptarray_is_closed_3d(const POINTARRAY *pa)
Definition: ptarray.c:707
GBOX * bbox
Definition: liblwgeom.h:528
GBOX * bbox
Definition: liblwgeom.h:567
void lwcircstring_free(LWCIRCSTRING *curve)
Definition: lwcircstring.c:85
LWPSURFACE * lwpsurface_add_lwpoly(LWPSURFACE *mobj, const LWPOLY *obj)
Definition: lwpsurface.c:20
int maxrings
Definition: liblwgeom.h:518
char * lwgeom_to_svg(const LWGEOM *geom, int precision, int relative)
Takes a GEOMETRY and returns a SVG representation.
Definition: lwout_svg.c:42
double next_double_down(float d)
Definition: lwgeom_api.c:175
int32_t srid
Definition: liblwgeom.h:427
int lwgeom_covers_lwgeom_sphere(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
Calculate covers predicate for two lwgeoms on the sphere.
Definition: lwgeodetic.c:2303
GSERIALIZED * gserialized_copy(const GSERIALIZED *g)
Return a copy of the input serialized geometry.
Definition: g_serialized.c:102
int lwgeom_startpoint(const LWGEOM *lwgeom, POINT4D *pt)
Definition: lwgeom.c:1837
LWPOINT * lwpoint_make2d(int srid, double x, double y)
Definition: lwpoint.c:132
Datum area(PG_FUNCTION_ARGS)
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:469
LWGEOM * lwgeom_force_3dz(const LWGEOM *geom)
Definition: lwgeom.c:696
double b
Definition: liblwgeom.h:298
void lwtin_free(LWTIN *tin)
Definition: lwtin.c:26
uint8_t flags
Definition: liblwgeom.h:381
#define __attribute__(x)
Definition: liblwgeom.h:182
double xmax
Definition: liblwgeom.h:277
int lwpoint_getPoint2d_p(const LWPOINT *point, POINT2D *out)
Definition: lwpoint.c:27
LWLINE * lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points)
Definition: lwline.c:214
char * lwpoint_to_latlon(const LWPOINT *p, const char *format)
Definition: lwprint.c:393
LWGEOM * lwcircstring_as_lwgeom(const LWCIRCSTRING *obj)
Definition: lwgeom.c:224
int lwgeom_check_geodetic(const LWGEOM *geom)
Check that coordinates of LWGEOM are all within the geodetic range (-180, -90, 180, 90)
Definition: lwgeodetic.c:2718
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
void lwpoint_free(LWPOINT *pt)
Definition: lwpoint.c:182
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
void printLWTIN(LWTIN *tin)
Definition: lwtin.c:44
LWGEOM * lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1)
POINTARRAY * ptarray_substring(POINTARRAY *pa, double d1, double d2, double tolerance)
start location (distance from start / total distance) end location (distance from start / total dist...
Definition: ptarray.c:1058
LWGEOM * lwgeom_geos_noop(const LWGEOM *geom)
Convert an LWGEOM to a GEOS Geometry and convert back – for debug only.
LWMPOINT * lwmpoint_construct(int srid, const POINTARRAY *pa)
Definition: lwmpoint.c:39
def fmt
Definition: pixval.py:92
void lwpoint_release(LWPOINT *lwpoint)
Definition: lwpoint.c:225
LWGEOM * lwgeom_offsetcurve(const LWLINE *lwline, double size, int quadsegs, int joinStyle, double mitreLimit)
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it&#39;s 3d)
Definition: ptarray.c:1645
int lwgeom_dimensionality(LWGEOM *geom)
Return the dimensionality (relating to point/line/poly) of an lwgeom.
Definition: lwgeom.c:1362
void lwline_free(LWLINE *line)
Definition: lwline.c:63
void() lwinterrupt_callback()
Install a callback to be called periodically during algorithm execution.
Definition: liblwgeom.h:248
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: g_box.c:316
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:420
int pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring)
Definition: lwalgorithm.c:266
LWLINE * lwline_addpoint(LWLINE *line, LWPOINT *point, uint32_t where)
int32_t srid
Definition: liblwgeom.h:529
GBOX * bbox
Definition: liblwgeom.h:489
void lwgeom_scale(LWGEOM *geom, const POINT4D *factors)
Definition: lwgeom.c:1742
LWMPOLY * lwmpoly_construct_empty(int srid, char hasz, char hasm)
Definition: lwmpoly.c:27
LWPOINT * lwcompound_get_startpoint(const LWCOMPOUND *lwcmp)
Definition: lwcompound.c:235
int ptarray_is_closed_z(const POINTARRAY *pa)
Definition: ptarray.c:720
double radius
Definition: liblwgeom.h:302
void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2)
Swap ordinate values in every vertex of the geometry.
Definition: lwgeom.c:1464
LWCURVEPOLY * lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:116
LWGEOM * lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
Create an LWGEOM object from an Encoded Polyline representation.
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
Definition: lwgeom.c:822
LWGEOM * lwmline_as_lwgeom(const LWMLINE *obj)
Definition: lwgeom.c:209
void lwtriangle_reverse(LWTRIANGLE *triangle)
Definition: lwtriangle.c:100
int lwgeom_transform(LWGEOM *geom, projPJ inpj, projPJ outpj)
Transform (reproject) a geometry in-place.
int lwline_is_trajectory(const LWLINE *geom)
Definition: lwline.c:448
data
Definition: ovdump.py:103
LWGEOM * lwgeom_closest_line_3d(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures3d.c:64
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:1995
GBOX * bbox
Definition: liblwgeom.h:415
void printBOX3D(BOX3D *b)
Definition: lwgeom_api.c:592
int lwpoint_inside_circle(const LWPOINT *p, double cx, double cy, double rad)
Definition: lwgeom.c:566
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
Definition: lwin_wkt.c:871
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int lwgeom_nudge_geodetic(LWGEOM *geom)
Gently move coordinates of LWGEOM if they are close enough into geodetic range.
Definition: lwgeodetic.c:2991
uint8_t type
Definition: liblwgeom.h:513
void lwtriangle_force_clockwise(LWTRIANGLE *triangle)
Definition: lwtriangle.c:93
LWGEOM * lwgeom_furthest_point(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures.c:46
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
Definition: g_serialized.c:55
int gbox_contains_point3d(const GBOX *gbox, const POINT3D *pt)
Return true if the point is inside the gbox.
Definition: g_box.c:224
LWPOLY ** geoms
Definition: liblwgeom.h:558
char * hexbytes_from_bytes(uint8_t *bytes, size_t size)
Definition: lwout_wkb.c:25
int getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *point)
Definition: lwgeom_api.c:369
int gbox_init_point3d(const POINT3D *p, GBOX *gbox)
Initialize a GBOX using the values of the point.
Definition: g_box.c:216
int gbox_merge_point3d(const POINT3D *p, GBOX *gbox)
Update the GBOX to be large enough to include itself and the new point.
Definition: g_box.c:205
uint8_t flags
Definition: liblwgeom.h:449
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition: lwgeom.c:433
float next_float_down(double d)
Definition: lwgeom_api.c:143
GBOX * bbox
Definition: liblwgeom.h:437
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:125
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
Definition: measures.c:2302
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:890
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:341
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
Definition: lwgeom.c:284
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
Definition: lwmline.c:32
LWPOINT * lwpoint_construct_empty(int srid, char hasz, char hasm)
Definition: lwpoint.c:120
double zoff
Definition: liblwgeom.h:254
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:80
int32_t srid
Definition: liblwgeom.h:405
void lwpoly_force_clockwise(LWPOLY *poly)
Definition: lwpoly.c:175
LWGEOM ** geoms
Definition: liblwgeom.h:506
uint8_t flags
Definition: liblwgeom.h:501
double lwgeom_length_spheroid(const LWGEOM *geom, const SPHEROID *s)
Calculate the geodetic length of a lwgeom on the unit sphere.
Definition: lwgeodetic.c:2884
GBOX * bbox
Definition: liblwgeom.h:502
LWGEOM * lwgeom_furthest_line_3d(LWGEOM *lw1, LWGEOM *lw2)
Definition: measures3d.c:70
void lwgeom_request_interrupt(void)
Request interruption of any running code.
Definition: lwgeom_api.c:824
LWGEOM * lwgeom_force_sfs(LWGEOM *geom, int version)
Definition: lwgeom.c:744
double distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
Definition: measures.c:2327
POINTARRAY * point
Definition: liblwgeom.h:395
double lwgeom_length_2d(const LWGEOM *geom)
Definition: lwgeom.c:1668
LWMLINE * lwmline_construct_empty(int srid, char hasz, char hasm)
Definition: lwmline.c:24
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Pull a GBOX from the header of a GSERIALIZED, if one is available.
Definition: g_serialized.c:371
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:694
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:836
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
Definition: lwgeom.c:586
int32_t srid
Definition: liblwgeom.h:383
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:239
void interpolate_point4d(POINT4D *A, 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:806
void lwline_setPoint4d(LWLINE *line, uint32_t which, POINT4D *newpoint)
Definition: lwline.c:351
int ngeoms
Definition: liblwgeom.h:465
char * lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision)
GBOX * bbox
Definition: liblwgeom.h:541
POINT3DZ getPoint3dz(const POINTARRAY *pa, int n)
Definition: lwgeom_api.c:291
int lwgeom_ndims(const LWGEOM *geom)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: lwgeom.c:850
double lwgeom_interpolate_point(const LWGEOM *lwin, const LWPOINT *lwpt)
Find the measure value at the location on the line closest to the point.
void lwgeom_longitude_shift(LWGEOM *lwgeom)
Definition: lwgeom.c:902
LWGEOM * lwgeom_flip_coordinates(LWGEOM *in)
Reverse the X and Y coordinate order.
Definition: lwgeom.c:1458
double distance3d_pt_seg(const POINT3D *p, const POINT3D *A, const POINT3D *B)
GBOX * box3d_to_gbox(const BOX3D *b3d)
Definition: g_box.c:76
uint8_t type
Definition: liblwgeom.h:413
double lwgeom_perimeter(const LWGEOM *geom)
Definition: lwgeom.c:1602
void lwtriangle_release(LWTRIANGLE *lwtriangle)
Definition: lwtriangle.c:107
LWMPOLY * lwgeom_as_lwmpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:170
void * data
Definition: liblwgeom.h:384
int lwgeom_cpa_within(const LWGEOM *g1, const LWGEOM *g2, double maxdist)
Is the closest point of approach within a distance ?
double lwgeom_maxdistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling 3d max distance calculations and dfullywithin calculations.
Definition: measures3d.c:302
POINTARRAY * ptarray_flip_coordinates(POINTARRAY *pa)
Reverse X and Y axis on a given POINTARRAY.
Definition: ptarray.c:369
char lwcollection_same(const LWCOLLECTION *p1, const LWCOLLECTION *p2)
check for same geometry composition
Definition: lwcollection.c:248
LWGEOM * lwgeom_closest_point_3d(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures3d.c:76
int maxgeoms
Definition: liblwgeom.h:531
float next_float_up(double d)
Definition: lwgeom_api.c:159
uint8_t type
Definition: liblwgeom.h:539
LWPOINT * lwpoint_make3dm(int srid, double x, double y, double m)
Definition: lwpoint.c:153
double z
Definition: liblwgeom.h:324
void lwmpoint_release(LWMPOINT *lwpoint)
Definition: lwmpoint.c:20
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:652
void(* lwfreeor)(void *mem)
Definition: liblwgeom.h:201
void printLWPOLY(LWPOLY *poly)
Definition: lwpoly.c:100
uint8_t flags
Definition: liblwgeom.h:488
double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located)
Definition: ptarray.c:1303
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
Definition: lwcurvepoly.c:40
LWTRIANGLE * lwtriangle_from_lwline(const LWLINE *shell)
Definition: lwtriangle.c:128
int gbox_union(const GBOX *g1, const GBOX *g2, GBOX *gout)
Update the output GBOX to be large enough to include both inputs.
Definition: g_box.c:111
double lwpoint_get_x(const LWPOINT *point)
Definition: lwpoint.c:50
void lwgeom_force_clockwise(LWGEOM *lwgeom)
Ensure the outer ring is clockwise oriented and all inner rings are counter-clockwise.
Definition: lwgeom.c:23
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
Utility function to get type number from string.
Definition: g_util.c:148
int ngeoms
Definition: liblwgeom.h:569
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.
uint8_t flags
Definition: liblwgeom.h:462
POINTARRAY * ptarray_addPoint(const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where)
Add a point in a pointarray.
Definition: ptarray.c:509
LWGEOM * lwgeom_remove_repeated_points(LWGEOM *in, double tolerance)
Remove repeated points!
Definition: lwgeom.c:1407
void lwmpoly_free(LWMPOLY *mpoly)
Definition: lwmpoly.c:40
void lwmpoint_free(LWMPOINT *mpt)
Definition: lwmpoint.c:59
void expand_box3d(BOX3D *box, double d)
Expand given box of &#39;d&#39; units in all directions.
Definition: lwgeom_box3d.c:251
double zmax
Definition: liblwgeom.h:281
double ymin
Definition: liblwgeom.h:278
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
LWGEOM * lwgeom_homogenize(const LWGEOM *geom)
Definition: lwhomogenize.c:195
void *(* lwallocator)(size_t size)
Global functions for memory/logging handlers.
Definition: liblwgeom.h:199
void lwpoly_release(LWPOLY *lwpoly)
Definition: lwpoly.c:195
POINT4D getPoint4d(const POINTARRAY *pa, int n)
Definition: lwgeom_api.c:216
char lwcircstring_same(const LWCIRCSTRING *p1, const LWCIRCSTRING *p2)
Definition: lwcircstring.c:125
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: g_box.c:300
int ptarray_isccw(const POINTARRAY *pa)
Definition: ptarray.c:1026
double f
Definition: liblwgeom.h:299
uint8_t type
Definition: liblwgeom.h:448
uint8_t * lwgeom_to_wkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
Convert LWGEOM to a char* in WKB format.
Definition: lwout_wkb.c:750
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
Definition: lwgeom_api.c:319
uint8_t type
Definition: liblwgeom.h:526
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
Definition: g_box.c:141
double xmin
Definition: liblwgeom.h:276
LWCIRCSTRING * lwcircstring_construct_empty(int srid, char hasz, char hasm)
Definition: lwcircstring.c:67
LWCURVEPOLY * lwcurvepoly_construct(int srid, GBOX *bbox, uint32_t nrings, LWGEOM **geoms)
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_TRUE, then a duplicate point will not be added.
Definition: ptarray.c:156
int32_t srid
Definition: liblwgeom.h:516
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
LWGEOM * lwgeom_node(const LWGEOM *lwgeom_in)
projPJ lwproj_from_string(const char *txt)
Get a projection from a string representation.
char lwtriangle_same(const LWTRIANGLE *p1, const LWTRIANGLE *p2)
Definition: lwtriangle.c:114
LWTIN * lwgeom_as_lwtin(const LWGEOM *lwgeom)
Definition: lwgeom.c:187
uint8_t type
Definition: liblwgeom.h:435
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:472
void lwcircstring_release(LWCIRCSTRING *lwcirc)
Definition: lwcircstring.c:79
POINT3DM getPoint3dm(const POINTARRAY *pa, int n)
Definition: lwgeom_api.c:305
uint8_t flags
Definition: liblwgeom.h:353
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:29
GBOX * bbox
Definition: liblwgeom.h:515
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:79
const char * lwgeom_version(void)
Return lwgeom version string (not to be freed)
Definition: lwgeom_api.c:28
int gserialized_is_geodetic(const GSERIALIZED *gser)
Check if a GSERIALIZED is a geography.
Definition: g_serialized.c:44
LWPOINT * lwpoint_clone(const LWPOINT *lwgeom)
Definition: lwpoint.c:208
LWPOLY ** geoms
Definition: liblwgeom.h:480
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM...
Definition: liblwgeom.h:1876
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:29
LWLINE * lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint)
Definition: lwline.c:261
int lwpoint_getPoint3dz_p(const LWPOINT *point, POINT3DZ *out)
Definition: lwpoint.c:34
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:24
char * lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection)
Definition: lwutil.c:264
int lwgeom_force_geodetic(LWGEOM *geom)
Force coordinates of LWGEOM into geodetic range (-180, -90, 180, 90)
Definition: lwgeodetic.c:2809
LWGEOM ** geoms
Definition: liblwgeom.h:493
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: g_serialized.c:139
LWGEOM * lwgeom_delaunay_triangulation(const LWGEOM *geom, double tolerance, int edgeOnly)
Take vertices of a geometry and build a delaunay triangulation on them.
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
Definition: lwgeom.c:1558
LWPOINT * lwcompound_get_endpoint(const LWCOMPOUND *lwcmp)
Definition: lwcompound.c:241
LWTRIANGLE ** geoms
Definition: liblwgeom.h:571
void lwpsurface_release(LWPSURFACE *lwpsurface)
GBOX * gserialized_calculate_gbox_geocentric(const GSERIALIZED *g)
Calculate the geocentric bounding box directly from the serialized form of the geodetic coordinates...
LWGEOM * lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2)
uint8_t flags
Definition: liblwgeom.h:475
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
Definition: lwgeom.c:690
uint8_t type
Definition: liblwgeom.h:424
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1706
GBOX * bbox
Definition: liblwgeom.h:554
int ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
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:295
char * lwgeom_to_geojson(const LWGEOM *geo, char *srs, int precision, int has_bbox)
Takes a GEOMETRY and returns a GeoJson representation.
Definition: lwout_geojson.c:34
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
Definition: g_box.c:682
LWMLINE * lwgeom_as_lwmline(const LWGEOM *lwgeom)
Definition: lwgeom.c:161
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:640
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:187
LWPOINT * lwpoint_make(int srid, int hasz, int hasm, const POINT4D *p)
Definition: lwpoint.c:175
POINTARRAY ** rings
Definition: liblwgeom.h:441
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:999
double e
Definition: liblwgeom.h:300
LWGEOM * lwcompound_as_lwgeom(const LWCOMPOUND *obj)
Definition: lwgeom.c:234
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:309
uint8_t precision
Definition: cu_in_twkb.c:25
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
Definition: lwpoint.c:44
LWPOINT * lwpoint_make3dz(int srid, double x, double y, double z)
Definition: lwpoint.c:142
LWPOINT ** geoms
Definition: liblwgeom.h:454
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:634
double lwgeom_maxdistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initialazing max distance calculation.
Definition: measures.c:155
LWGEOM * lwgeom_difference(const LWGEOM *geom1, const LWGEOM *geom2)
LWCURVEPOLY * lwcurvepoly_construct_empty(int srid, char hasz, char hasm)
Definition: lwcurvepoly.c:23
size_t gbox_serialized_size(uint8_t flags)
Return the number of bytes necessary to hold a GBOX of this dimension in serialized form...
Definition: g_box.c:416
LWCOMPOUND * lwgeom_as_lwcompound(const LWGEOM *lwgeom)
Definition: lwgeom.c:107
int maxgeoms
Definition: liblwgeom.h:557
int nrings
Definition: liblwgeom.h:439
LWMPOINT * lwmpoint_construct_empty(int srid, char hasz, char hasm)
Definition: lwmpoint.c:26
int32_t srid
Definition: liblwgeom.h:490
void gbox_expand(GBOX *g, double d)
Move the box minimums down and the maximums up by the distance provided.
Definition: g_box.c:93
double ymax
Definition: liblwgeom.h:279
int lwgeom_has_arc(const LWGEOM *geom)
Definition: lwstroke.c:41
LWGEOM * lwgeom_furthest_line(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures.c:34
void printLWLINE(LWLINE *line)
Definition: lwline.c:75
LWGEOM * lwtriangle_as_lwgeom(const LWTRIANGLE *obj)
Definition: lwgeom.c:244
enum LWORD_T LWORD
Ordinate names.
char * s
Definition: cu_in_wkt.c:23
double y
Definition: liblwgeom.h:312
LWGEOM * lwgeom_normalize(const LWGEOM *geom)
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where)
Insert a point into an existing POINTARRAY.
Definition: ptarray.c:96
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:448
uint8_t flags
Definition: liblwgeom.h:514
void(* lwreporter)(const char *fmt, va_list ap) __attribute__((format(printf
Definition: liblwgeom.h:202
LWGEOM * lwgeom_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwgeom.c:1807
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, m).
double e_sq
Definition: liblwgeom.h:301
double z
Definition: liblwgeom.h:336
char * lwgeom_extent_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:185
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:27
LWCOMPOUND * lwcompound_construct_from_lwline(const LWLINE *lwpoly)
Construct an equivalent compound curve from a linestring.
Definition: lwcompound.c:191
int point4d_transform(POINT4D *pt, projPJ srcpj, projPJ dstpj)
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&#39;t already there) interpolating the measure betwe...
Definition: lwmline.c:42
uint8_t type
Definition: liblwgeom.h:565
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:395
Datum distance(PG_FUNCTION_ARGS)
BOX3D * box3d_from_gbox(const GBOX *gbox)
Definition: g_box.c:49
double y
Definition: liblwgeom.h:330
double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the sphere.
Definition: lwgeodetic.c:1927
int ngeoms
Definition: liblwgeom.h:478
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
Definition: lwgeom.c:858
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:89
int32_t srid
Definition: liblwgeom.h:394
LWCIRCSTRING * lwcircstring_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwcircstring.c:38
LWCOLLECTION * lwgeom_subdivide(const LWGEOM *geom, int maxvertices)
Definition: lwgeom.c:2008
uint8_t flags
Definition: liblwgeom.h:275
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
Definition: lwgeom.c:495
char * gserialized_to_string(const GSERIALIZED *g)
Return a WKT representation of the gserialized geometry.
Definition: g_serialized.c:153
void lwtriangle_free(LWTRIANGLE *triangle)
Definition: lwtriangle.c:56
LWCOLLECTION * lwcollection_segmentize2d(LWCOLLECTION *coll, double dist)
Definition: lwcollection.c:223
void *(* lwreallocator)(void *mem, size_t size)
Definition: liblwgeom.h:200
void lwpsurface_free(LWPSURFACE *psurf)
Definition: lwpsurface.c:26
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
Definition: lwin_wkb.c:779
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
Definition: lwgeom.c:98
unsigned int geohash_point_as_int(POINT2D *pt)
Definition: lwalgorithm.c:633
int lwgeom_count_rings(const LWGEOM *geom)
Count the total number of rings in any LWGEOM.
Definition: lwgeom.c:1249
double lwgeom_tcpa(const LWGEOM *g1, const LWGEOM *g2, double *mindist)
Find the time of closest point of approach.
int maxgeoms
Definition: liblwgeom.h:570
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.
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: g_box.c:234
uint8_t type
Definition: liblwgeom.h:552
GBOX * bbox
Definition: liblwgeom.h:426
LWGEOM * lwgeom_snap(const LWGEOM *geom1, const LWGEOM *geom2, double tolerance)
Snap vertices and segments of a geometry to another using a given tolerance.
void lwcollection_release(LWCOLLECTION *lwcollection)
Definition: lwcollection.c:23
GBOX * gbox_copy(const GBOX *gbox)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:403
uint8_t parse_hex(char *str)
Convert a single hex digit into the corresponding char.
Definition: lwgeom_api.c:639
uint8_t flags
Definition: liblwgeom.h:392
char * lwgeom_extent_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix)
Definition: lwout_gml.c:200
void lwpoly_reverse(LWPOLY *poly)
Definition: lwpoly.c:201
LWLINE ** geoms
Definition: liblwgeom.h:467
double ptarray_length(const POINTARRAY *pts)
Find the 3d/2d length of the given POINTARRAY (depending on its dimensionality)
Definition: ptarray.c:1673
int ptarray_calculate_gbox_geodetic(const POINTARRAY *pa, GBOX *gbox)
Calculate geodetic (x/y/z) box and add values to gbox.
Definition: lwgeodetic.c:2476
char lwtriangle_is_repeated_points(LWTRIANGLE *triangle)
Definition: lwtriangle.c:150
double lwgeom_perimeter_2d(const LWGEOM *geom)
Definition: lwgeom.c:1624
void lwgeom_reverse(LWGEOM *lwgeom)
Reverse vertex order of LWGEOM.
Definition: lwgeom.c:51
LWTRIANGLE * lwgeom_as_lwtriangle(const LWGEOM *lwgeom)
Definition: lwgeom.c:134
int ngeoms
Definition: liblwgeom.h:543
LWPOLY * lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes)
Definition: lwpoly.c:255
LWLINE * lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwline.c:153
int maxrings
Definition: liblwgeom.h:440
double lwpoint_get_m(const LWPOINT *point)
Definition: lwpoint.c:82
int maxgeoms
Definition: liblwgeom.h:466
void lwline_reverse(LWLINE *line)
Definition: lwline.c:127
int gbox_is_valid(const GBOX *gbox)
Return false if any of the dimensions is NaN or infinite.
Definition: g_box.c:174
char * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
Definition: lwalgorithm.c:813
GBOX * bbox
Definition: liblwgeom.h:393
int getPoint2d_p_ro(const POINTARRAY *pa, int n, POINT2D **point)
New function to read doubles directly from the double* coordinate array of an aligned lwgeom POINTARR...
Definition: lwgeodetic.c:2462
void gbox_pt_outside(const GBOX *gbox, POINT2D *pt_outside)
Calculate a spherical point that falls outside the geocentric gbox.
Definition: lwgeodetic.c:1444
lwinterrupt_callback * lwgeom_register_interrupt_callback(lwinterrupt_callback *)
Definition: lwgeom_api.c:834
const POINT3DZ * getPoint3dz_cp(const POINTARRAY *pa, int n)
Returns a POINT3DZ pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:486
void printPA(POINTARRAY *pa)
Definition: lwgeom_api.c:598
void ptarray_longitude_shift(POINTARRAY *pa)
Longitude shift for a pointarray.
Definition: ptarray.c:1414
LWGEOM * lwgeom_buildarea(const LWGEOM *geom)
Take a geometry and return an areal geometry (Polygon or MultiPolygon).
double a
Definition: liblwgeom.h:297
const char * lwgeom_geos_version(void)
Return GEOS version string (not to be freed)
void lwgeom_drop_srid(LWGEOM *lwgeom)
Definition: lwgeom.c:662
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:1639
LWPOINT * lwpoint_make4d(int srid, double x, double y, double z, double m)
Definition: lwpoint.c:164
int lwpoint_getPoint3dm_p(const LWPOINT *point, POINT3DM *out)
Definition: lwpoint.c:39
int32_t srid
Definition: liblwgeom.h:438
char ptarray_same(const POINTARRAY *pa1, const POINTARRAY *pa2)
Definition: ptarray.c:484
LWGEOM * lwpsurface_as_lwgeom(const LWPSURFACE *obj)
Definition: lwgeom.c:199
uint32_t size
Definition: liblwgeom.h:365
int maxgeoms
Definition: liblwgeom.h:505
LWGEOM ** geoms
Definition: liblwgeom.h:545
LWGEOM * lwgeom_unaryunion(const LWGEOM *geom1)
int ptarray_remove_point(POINTARRAY *pa, int where)
Remove a point from an existing POINTARRAY.
Definition: ptarray.c:261
void(*) typedef void(* lwdebuglogger)(int level, const char *fmt, va_list ap) __attribute__((format(printf
Definition: liblwgeom.h:204
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:143
LWGEOM * lwgeom_from_twkb(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:642
double lwgeom_area(const LWGEOM *geom)
Definition: lwgeom.c:1579
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: g_box.c:164
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:1192
double mmin
Definition: liblwgeom.h:282
double distance3d_pt_pt(const POINT3D *p1, const POINT3D *p2)
Definition: measures3d.c:771
int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the 2-4D bounding box of a geometry.
Definition: g_box.c:648
int ngeoms
Definition: liblwgeom.h:504
void gbox_duplicate(const GBOX *original, GBOX *duplicate)
Copy the values of original GBOX into duplicate.
Definition: g_box.c:410
double zmin
Definition: liblwgeom.h:280
int lwgeom_is_simple(const LWGEOM *lwgeom)
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: g_serialized.c:86
LWGEOM * lwgeom_symdifference(const LWGEOM *geom1, const LWGEOM *geom2)
void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result)
Definition: lwin_wkt.c:865
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...
LWMPOINT * lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
Definition: lwmpoint.c:32
double ptarray_arc_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY, using circular arc interpolation between each coordinate ...
Definition: ptarray.c:1618
LWGEOM ** geoms
Definition: liblwgeom.h:532
double lwgeom_length(const LWGEOM *geom)
Definition: lwgeom.c:1646
void * lwrealloc(void *mem, size_t size)
Definition: lwutil.c:207
LWGEOM * lwgeom_segmentize2d(LWGEOM *line, double dist)
Definition: lwgeom.c:668
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
Definition: lwpoly.c:66
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:152
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:599
void printLWPOINT(LWPOINT *point)
Definition: lwpoint.c:193
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initialazing min distance calculation.
Definition: measures.c:188
const POINT4D * getPoint4d_cp(const POINTARRAY *pa, int n)
Returns a POINT4D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:507
void ptarray_reverse(POINTARRAY *pa)
Definition: ptarray.c:343
LWPSURFACE * lwgeom_as_lwpsurface(const LWGEOM *lwgeom)
Definition: lwgeom.c:179
int ptarray_calculate_gbox_cartesian(const POINTARRAY *pa, GBOX *gbox)
Calculate box (x/y) and add values to gbox.
Definition: g_box.c:512
int32_t srid
Definition: liblwgeom.h:542
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
Definition: lwgeom.c:372
LWPOINT * lwline_get_lwpoint(const LWLINE *line, int where)
Returns freshly allocated LWPOINT that corresponds to the index where.
Definition: lwline.c:295
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: g_box.c:36
uint8_t type
Definition: liblwgeom.h:380
type
Definition: ovdump.py:41
uint8_t type
Definition: liblwgeom.h:500
int gserialized_ndims(const GSERIALIZED *gser)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: g_serialized.c:39
int lwcurvepoly_add_ring(LWCURVEPOLY *poly, LWGEOM *ring)
Add a ring, allocating extra space if necessary.
Definition: lwcurvepoly.c:59
double lwpoint_get_y(const LWPOINT *point)
Definition: lwpoint.c:60
double mmax
Definition: liblwgeom.h:283
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:326
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition: lwgeom.c:254
void lwgeom_set_debuglogger(lwdebuglogger debuglogger)
Definition: lwutil.c:182
LWGEOM * lwtin_as_lwgeom(const LWTIN *obj)
Definition: lwgeom.c:194
POINTARRAY * points
Definition: liblwgeom.h:428
struct struct_lwgeom_parser_result LWGEOM_PARSER_RESULT
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM...
void lwgeom_set_srid(LWGEOM *geom, int srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
LWGEOM * lwgeom_force_3dm(const LWGEOM *geom)
Definition: lwgeom.c:702
double lwgeom_area_spheroid(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the spheroid.
Definition: lwspheroid.c:628
CG_LINE_CROSS_TYPE
The return values of lwline_crossing_direction()
Definition: liblwgeom.h:1444
double lwgeom_maxdistance3d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing 3d max distance calculation.
Definition: measures3d.c:290
LWGEOM * lwcurvepoly_as_lwgeom(const LWCURVEPOLY *obj)
Definition: lwgeom.c:229
LWGEOM * lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures.c:28
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
Definition: lwpoly.c:154
int maxgeoms
Definition: liblwgeom.h:453
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:2081
double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
Definition: measures.c:2312
LWORD_T
Ordinate names.
Definition: liblwgeom.h:98
int maxpoints
Definition: liblwgeom.h:356
int value
Definition: genraster.py:61
uint8_t flags
Definition: liblwgeom.h:436
LWGEOM * lwgeom_as_curve(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate CURVE* type.
Definition: lwgeom.c:324
LWPOLY * lwpoly_segmentize2d(LWPOLY *line, double dist)
Definition: lwpoly.c:210
LWGEOM * lwgeom_union(const LWGEOM *geom1, const LWGEOM *geom2)
POINTARRAY * ptarray_removePoint(POINTARRAY *pa, uint32_t where)
Remove a point from a pointarray.
Definition: ptarray.c:562
char * lwgeom_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix, const char *id)
Definition: lwout_gml.c:723
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
Definition: lwpoint.c:98
void * lwalloc(size_t size)
Definition: lwutil.c:199
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1297
uint8_t flags
Definition: liblwgeom.h:566
void lwmline_release(LWMLINE *lwline)
Definition: lwmline.c:18
int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, int where)
Add a LWPOINT to an LWLINE.
Definition: lwline.c:313
int lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition: lwgeom.c:1140
LWGEOM * lwgeom_unstroke(const LWGEOM *geom)
Definition: lwstroke.c:842
GBOX * bbox
Definition: liblwgeom.h:476
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:754
LWPOINT * lwcompound_get_lwpoint(const LWCOMPOUND *lwcmp, int where)
Definition: lwcompound.c:200
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:81
double distance2d_sqr_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
Definition: measures.c:2376
int ngeoms
Definition: liblwgeom.h:452
opts
Definition: ovdump.py:44
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: g_serialized.c:49
uint8_t flags
Definition: liblwgeom.h:403
int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret)
Compute the azimuth of segment AB in radians.
Definition: measures.c:2412
int32_t srid
Definition: liblwgeom.h:555
uint8_t * lwgeom_to_twkb(const LWGEOM *geom, uint8_t variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m, size_t *twkb_size)
Definition: lwout_twkb.c:594
LWLINE * lwline_removepoint(LWLINE *line, uint32_t which)
Definition: lwline.c:334
void lwline_release(LWLINE *lwline)
Definition: lwline.c:121
GBOX * gbox_new(uint8_t flags)
Create a new gbox with the dimensionality indicated by the flags.
Definition: g_box.c:28
char * lwgeom_summary(const LWGEOM *lwgeom, int offset)
Definition: lwgeom_debug.c:145
char lwpoly_same(const LWPOLY *p1, const LWPOLY *p2)
Definition: lwpoly.c:234
int ptarray_transform(POINTARRAY *geom, projPJ inpj, projPJ outpj)
Transform given POINTARRAY from inpj projection to outpj projection.
int ngeoms
Definition: liblwgeom.h:556
int32_t srid
Definition: liblwgeom.h:451
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:843
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
Definition: lwcollection.c:174
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
Definition: lwgeom.c:1103
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)
Definition: lwgeom.c:204
char lwline_same(const LWLINE *p1, const LWLINE *p2)
Definition: lwline.c:143
LWMPOLY * lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj)
Definition: lwmpoly.c:34
double lwpoint_get_z(const LWPOINT *point)
Definition: lwpoint.c:70
int32_t srid
Definition: liblwgeom.h:568
int gserialized_calculate_gbox_geocentric_p(const GSERIALIZED *g, GBOX *g_box)
Calculate the geocentric bounding box directly from the serialized form of the geodetic coordinates...
int32_t srid
Definition: liblwgeom.h:477
int maxgeoms
Definition: liblwgeom.h:544
LWPOINT * lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, int where)
Definition: lwcircstring.c:287
int32_t srid
Definition: liblwgeom.h:416
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
Definition: g_box.c:369
GBOX * bbox
Definition: liblwgeom.h:463
int lwcompound_add_lwgeom(LWCOMPOUND *comp, LWGEOM *geom)
Add a component, allocating extra space if necessary.
Definition: lwcompound.c:75
int ptarray_is_closed(const POINTARRAY *pa)
Check for ring closure using whatever dimensionality is declared on the pointarray.
Definition: ptarray.c:680
uint8_t type
Definition: liblwgeom.h:474
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:231
void lwgeom_affine(LWGEOM *geom, const AFFINE *affine)
Definition: lwgeom.c:1691
double next_double_up(float d)
Definition: lwgeom_api.c:190
char * lwgeom_to_kml2(const LWGEOM *geom, int precision, const char *prefix)
Definition: lwout_kml.c:31
LWGEOM * lwgeom_linemerge(const LWGEOM *geom1)
uint8_t flags
Definition: liblwgeom.h:367
double zmax
Definition: liblwgeom.h:262
int32_t srid
Definition: liblwgeom.h:464
void printLWTRIANGLE(LWTRIANGLE *triangle)
Definition: lwtriangle.c:69
LWGEOM * lwgeom_split(const LWGEOM *lwgeom_in, const LWGEOM *blade_in)
uint8_t flags
Definition: liblwgeom.h:414
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: g_serialized.c:69
POINTARRAY * points
Definition: liblwgeom.h:406
LWGEOM * lwgeom_from_geojson(const char *geojson, char **srs)
Create an LWGEOM object from a GeoJSON representation.
Definition: lwin_geojson.c:512
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:219
double zmin
Definition: liblwgeom.h:261
LWGEOM * lwmpoint_as_lwgeom(const LWMPOINT *obj)
Definition: lwgeom.c:214
POINTARRAY * ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2)
Merge two given POINTARRAY and returns a pointer on the new aggregate one.
Definition: ptarray.c:603