PostGIS  2.4.9dev-r@@SVN_REVISION@@
liblwgeom.h File Reference

This library is the generic geometry handling section of PostGIS. More...

#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include "proj_api.h"
Include dependency graph for liblwgeom.h:

Go to the source code of this file.

Data Structures

struct  AFFINE
 
struct  BOX3D
 
struct  GBOX
 
struct  SPHEROID
 
struct  POINT2D
 
struct  POINT3DZ
 
struct  POINT3D
 
struct  POINT3DM
 
struct  POINT4D
 
struct  POINTARRAY
 
struct  GSERIALIZED
 
struct  LWGEOM
 
struct  LWPOINT
 
struct  LWLINE
 
struct  LWTRIANGLE
 
struct  LWCIRCSTRING
 
struct  LWPOLY
 
struct  LWMPOINT
 
struct  LWMLINE
 
struct  LWMPOLY
 
struct  LWCOLLECTION
 
struct  LWCOMPOUND
 
struct  LWCURVEPOLY
 
struct  LWMCURVE
 
struct  LWMSURFACE
 
struct  LWPSURFACE
 
struct  LWTIN
 
struct  LWBOUNDINGCIRCLE
 
struct  struct_lwgeom_parser_result
 Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM. More...
 
struct  struct_lwgeom_unparser_result
 

Macros

#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H   1
 
#define PROJ_GEODESIC   0
 
#define LIBLWGEOM_VERSION   "2.4.9dev"
 liblwgeom versions More...
 
#define LIBLWGEOM_VERSION_MAJOR   "2"
 
#define LIBLWGEOM_VERSION_MINOR   "4"
 
#define LIBLWGEOM_GEOS_VERSION   "37"
 
#define LW_TRUE   1
 Return types for functions with status returns. More...
 
#define LW_FALSE   0
 
#define LW_UNKNOWN   2
 
#define LW_FAILURE   0
 
#define LW_SUCCESS   1
 
#define POINTTYPE   1
 LWTYPE numbers, used internally by PostGIS. More...
 
#define LINETYPE   2
 
#define POLYGONTYPE   3
 
#define MULTIPOINTTYPE   4
 
#define MULTILINETYPE   5
 
#define MULTIPOLYGONTYPE   6
 
#define COLLECTIONTYPE   7
 
#define CIRCSTRINGTYPE   8
 
#define COMPOUNDTYPE   9
 
#define CURVEPOLYTYPE   10
 
#define MULTICURVETYPE   11
 
#define MULTISURFACETYPE   12
 
#define POLYHEDRALSURFACETYPE   13
 
#define TRIANGLETYPE   14
 
#define TINTYPE   15
 
#define NUMTYPES   16
 
#define WKBZOFFSET   0x80000000
 Flags applied in EWKB to indicate Z/M dimensions and presence/absence of SRID and bounding boxes. More...
 
#define WKBMOFFSET   0x40000000
 
#define WKBSRIDFLAG   0x20000000
 
#define WKBBBOXFLAG   0x10000000
 
#define WGS84_MAJOR_AXIS   6378137.0
 
#define WGS84_INVERSE_FLATTENING   298.257223563
 
#define WGS84_MINOR_AXIS   (WGS84_MAJOR_AXIS - WGS84_MAJOR_AXIS / WGS84_INVERSE_FLATTENING)
 
#define WGS84_RADIUS   ((2.0 * WGS84_MAJOR_AXIS + WGS84_MINOR_AXIS ) / 3.0)
 
#define FLAGS_GET_Z(flags)   ((flags) & 0x01)
 Macros for manipulating the 'flags' byte. More...
 
#define FLAGS_GET_M(flags)   (((flags) & 0x02)>>1)
 
#define FLAGS_GET_BBOX(flags)   (((flags) & 0x04)>>2)
 
#define FLAGS_GET_GEODETIC(flags)   (((flags) & 0x08)>>3)
 
#define FLAGS_GET_READONLY(flags)   (((flags) & 0x10)>>4)
 
#define FLAGS_GET_SOLID(flags)   (((flags) & 0x20)>>5)
 
#define FLAGS_SET_Z(flags, value)   ((flags) = (value) ? ((flags) | 0x01) : ((flags) & 0xFE))
 
#define FLAGS_SET_M(flags, value)   ((flags) = (value) ? ((flags) | 0x02) : ((flags) & 0xFD))
 
#define FLAGS_SET_BBOX(flags, value)   ((flags) = (value) ? ((flags) | 0x04) : ((flags) & 0xFB))
 
#define FLAGS_SET_GEODETIC(flags, value)   ((flags) = (value) ? ((flags) | 0x08) : ((flags) & 0xF7))
 
#define FLAGS_SET_READONLY(flags, value)   ((flags) = (value) ? ((flags) | 0x10) : ((flags) & 0xEF))
 
#define FLAGS_SET_SOLID(flags, value)   ((flags) = (value) ? ((flags) | 0x20) : ((flags) & 0xDF))
 
#define FLAGS_NDIMS(flags)   (2 + FLAGS_GET_Z(flags) + FLAGS_GET_M(flags))
 
#define FLAGS_GET_ZM(flags)   (FLAGS_GET_M(flags) + FLAGS_GET_Z(flags) * 2)
 
#define FLAGS_NDIMS_BOX(flags)   (FLAGS_GET_GEODETIC(flags) ? 3 : FLAGS_NDIMS(flags))
 
#define TYPMOD_GET_SRID(typmod)   ((((typmod) & 0x0FFFFF00) - ((typmod) & 0x10000000)) >> 8)
 Macros for manipulating the 'typemod' int. More...
 
#define TYPMOD_SET_SRID(typmod, srid)   ((typmod) = (((typmod) & 0xE00000FF) | ((srid & 0x001FFFFF)<<8)))
 
#define TYPMOD_GET_TYPE(typmod)   ((typmod & 0x000000FC)>>2)
 
#define TYPMOD_SET_TYPE(typmod, type)   ((typmod) = (typmod & 0xFFFFFF03) | ((type & 0x0000003F)<<2))
 
#define TYPMOD_GET_Z(typmod)   ((typmod & 0x00000002)>>1)
 
#define TYPMOD_SET_Z(typmod)   ((typmod) = typmod | 0x00000002)
 
#define TYPMOD_GET_M(typmod)   (typmod & 0x00000001)
 
#define TYPMOD_SET_M(typmod)   ((typmod) = typmod | 0x00000001)
 
#define TYPMOD_GET_NDIMS(typmod)   (2+TYPMOD_GET_Z(typmod)+TYPMOD_GET_M(typmod))
 
#define SRID_MAXIMUM   999999
 Maximum allowed SRID value in serialized geometry. More...
 
#define SRID_USER_MAXIMUM   998999
 Maximum valid SRID value for the user We reserve 1000 values for internal use. More...
 
#define SRID_UNKNOWN   0
 Unknown SRID value. More...
 
#define SRID_IS_UNKNOWN(x)   ((int)x<=0)
 
#define SRID_DEFAULT   4326
 
#define __attribute__(x)
 
#define LW_GML_IS_DIMS   (1<<0)
 Macros for specifying GML options. More...
 
#define LW_GML_IS_DEGREE   (1<<1)
 For GML3 only, declare that datas are lat/lon. More...
 
#define LW_GML_SHORTLINE   (1<<2)
 For GML3, use <LineString> rather than <Curve> for lines. More...
 
#define LW_GML_EXTENT   (1<<4)
 For GML2 and GML3, output only extent of geometry. More...
 
#define IS_DIMS(x)   ((x) & LW_GML_IS_DIMS)
 
#define IS_DEGREE(x)   ((x) & LW_GML_IS_DEGREE)
 

Typedefs

typedef enum LWORD_T LWORD
 Ordinate names. More...
 
typedef void *(* lwallocator) (size_t size)
 Global functions for memory/logging handlers. More...
 
typedef void *(* lwreallocator) (void *mem, size_t size)
 
typedef void(* lwfreeor) (void *mem)
 
typedef void(* lwreporter) (const char *fmt, va_list ap) __attribute__((format(printf
 
typedef void(*) typedef void(* lwdebuglogger) (int level, const char *fmt, va_list ap) __attribute__((format(printf
 
typedef 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. More...
 
typedef void() lwinterrupt_callback()
 Install a callback to be called periodically during algorithm execution. More...
 

Enumerations

enum  LWORD_T { LWORD_X = 0, LWORD_Y = 1, LWORD_Z = 2, LWORD_M = 3 }
 Ordinate names. More...
 
enum  CG_LINE_CROSS_TYPE {
  LINE_NO_CROSS = 0, LINE_CROSS_LEFT = -1, LINE_CROSS_RIGHT = 1, LINE_MULTICROSS_END_LEFT = -2,
  LINE_MULTICROSS_END_RIGHT = 2, LINE_MULTICROSS_END_SAME_FIRST_LEFT = -3, LINE_MULTICROSS_END_SAME_FIRST_RIGHT = 3
}
 The return values of lwline_crossing_direction() More...
 

Functions

const char * lwgeom_version (void)
 Return lwgeom version string (not to be freed) More...
 
int clamp_srid (int srid)
 Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from what went in. More...
 
void error_if_srid_mismatch (int srid1, int srid2)
 
void lwgeom_set_debuglogger (lwdebuglogger debuglogger)
 
void lwgeom_request_interrupt (void)
 Request interruption of any running code. More...
 
void lwgeom_cancel_interrupt (void)
 Cancel any interruption request. More...
 
lwinterrupt_callbacklwgeom_register_interrupt_callback (lwinterrupt_callback *)
 
LWMPOLYlwgeom_as_lwmpoly (const LWGEOM *lwgeom)
 
LWMLINElwgeom_as_lwmline (const LWGEOM *lwgeom)
 
LWMPOINTlwgeom_as_lwmpoint (const LWGEOM *lwgeom)
 
LWCOLLECTIONlwgeom_as_lwcollection (const LWGEOM *lwgeom)
 
LWPOLYlwgeom_as_lwpoly (const LWGEOM *lwgeom)
 
LWLINElwgeom_as_lwline (const LWGEOM *lwgeom)
 
LWPOINTlwgeom_as_lwpoint (const LWGEOM *lwgeom)
 
LWCIRCSTRINGlwgeom_as_lwcircstring (const LWGEOM *lwgeom)
 
LWCURVEPOLYlwgeom_as_lwcurvepoly (const LWGEOM *lwgeom)
 
LWCOMPOUNDlwgeom_as_lwcompound (const LWGEOM *lwgeom)
 
LWPSURFACElwgeom_as_lwpsurface (const LWGEOM *lwgeom)
 
LWTRIANGLElwgeom_as_lwtriangle (const LWGEOM *lwgeom)
 
LWTINlwgeom_as_lwtin (const LWGEOM *lwgeom)
 
LWGEOMlwgeom_as_multi (const LWGEOM *lwgeom)
 Create a new LWGEOM of the appropriate MULTI* type. More...
 
LWGEOMlwgeom_as_curve (const LWGEOM *lwgeom)
 Create a new LWGEOM of the appropriate CURVE* type. More...
 
LWGEOMlwtin_as_lwgeom (const LWTIN *obj)
 
LWGEOMlwtriangle_as_lwgeom (const LWTRIANGLE *obj)
 
LWGEOMlwpsurface_as_lwgeom (const LWPSURFACE *obj)
 
LWGEOMlwmpoly_as_lwgeom (const LWMPOLY *obj)
 
LWGEOMlwmline_as_lwgeom (const LWMLINE *obj)
 
LWGEOMlwmpoint_as_lwgeom (const LWMPOINT *obj)
 
LWGEOMlwcollection_as_lwgeom (const LWCOLLECTION *obj)
 
LWGEOMlwcircstring_as_lwgeom (const LWCIRCSTRING *obj)
 
LWGEOMlwcompound_as_lwgeom (const LWCOMPOUND *obj)
 
LWGEOMlwcurvepoly_as_lwgeom (const LWCURVEPOLY *obj)
 
LWGEOMlwpoly_as_lwgeom (const LWPOLY *obj)
 
LWGEOMlwline_as_lwgeom (const LWLINE *obj)
 
LWGEOMlwpoint_as_lwgeom (const LWPOINT *obj)
 
LWCOLLECTIONlwcollection_add_lwgeom (LWCOLLECTION *col, const LWGEOM *geom)
 Appends geom to the collection managed by col. More...
 
LWMPOINTlwmpoint_add_lwpoint (LWMPOINT *mobj, const LWPOINT *obj)
 
LWMLINElwmline_add_lwline (LWMLINE *mobj, const LWLINE *obj)
 
LWMPOLYlwmpoly_add_lwpoly (LWMPOLY *mobj, const LWPOLY *obj)
 
LWPSURFACElwpsurface_add_lwpoly (LWPSURFACE *mobj, const LWPOLY *obj)
 
LWTINlwtin_add_lwtriangle (LWTIN *mobj, const LWTRIANGLE *obj)
 
uint8_t gflags (int hasz, int hasm, int geodetic)
 Construct a new flags char. More...
 
uint32_t gserialized_get_type (const GSERIALIZED *g)
 Extract the geometry type from the serialized form (it hides in the anonymous data area, so this is a handy function). More...
 
uint32_t gserialized_max_header_size (void)
 Returns the size in bytes to read from toast to get the basic information from a geometry: GSERIALIZED struct, bbox and type. More...
 
uint32_t gserialized_header_size (const GSERIALIZED *gser)
 Returns the size in bytes of the header, from the start of the object up to the type number. More...
 
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). More...
 
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). More...
 
int gserialized_is_empty (const GSERIALIZED *g)
 Check if a GSERIALIZED is empty without deserializing first. More...
 
int gserialized_has_bbox (const GSERIALIZED *gser)
 Check if a GSERIALIZED has a bounding box without deserializing first. More...
 
int gserialized_has_z (const GSERIALIZED *gser)
 Check if a GSERIALIZED has a Z ordinate. More...
 
int gserialized_has_m (const GSERIALIZED *gser)
 Check if a GSERIALIZED has an M ordinate. More...
 
int gserialized_is_geodetic (const GSERIALIZED *gser)
 Check if a GSERIALIZED is a geography. More...
 
int gserialized_get_zm (const GSERIALIZED *gser)
 Return a number indicating presence of Z and M coordinates. More...
 
int gserialized_ndims (const GSERIALIZED *gser)
 Return the number of dimensions (2, 3, 4) in a geometry. More...
 
int gserialized_cmp (const GSERIALIZED *g1, const GSERIALIZED *g2)
 Return -1 if g1 is "less than" g2, 1 if g1 is "greater than" g2 and 0 if g1 and g2 are the "same". More...
 
void lwgeom_drop_bbox (LWGEOM *lwgeom)
 Call this function to drop BBOX and SRID from LWGEOM. More...
 
void lwgeom_drop_srid (LWGEOM *lwgeom)
 
void lwgeom_add_bbox (LWGEOM *lwgeom)
 Compute a bbox if not already computed. More...
 
void lwgeom_add_bbox_deep (LWGEOM *lwgeom, GBOX *gbox)
 Compute a box for geom and all sub-geometries, if not already computed. More...
 
const GBOXlwgeom_get_bbox (const LWGEOM *lwgeom)
 Get a non-empty geometry bounding box, computing and caching it if not already there. More...
 
int lwgeom_is_collection (const LWGEOM *lwgeom)
 Determine whether a LWGEOM can contain sub-geometries or not. More...
 
int lwtype_is_collection (uint8_t type)
 Determine whether a type number is a collection or not. More...
 
int lwtype_get_collectiontype (uint8_t type)
 Given an lwtype number, what homogeneous collection can hold it? More...
 
const char * lwtype_name (uint8_t type)
 Return the type name string associated with a type number (e.g. More...
 
POINT4D getPoint4d (const POINTARRAY *pa, int n)
 
int getPoint4d_p (const POINTARRAY *pa, int n, POINT4D *point)
 
POINT3DZ getPoint3dz (const POINTARRAY *pa, int n)
 
POINT3DM getPoint3dm (const POINTARRAY *pa, int n)
 
int getPoint3dz_p (const POINTARRAY *pa, int n, POINT3DZ *point)
 
int getPoint3dm_p (const POINTARRAY *pa, int n, POINT3DM *point)
 
POINT2D getPoint2d (const POINTARRAY *pa, int n)
 
int getPoint2d_p (const POINTARRAY *pa, int n, POINT2D *point)
 
const POINT2DgetPoint2d_cp (const POINTARRAY *pa, int n)
 Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from. More...
 
const POINT3DZgetPoint3dz_cp (const POINTARRAY *pa, int n)
 Returns a POINT3DZ pointer into the POINTARRAY serialized_ptlist, suitable for reading from. More...
 
const POINT4DgetPoint4d_cp (const POINTARRAY *pa, int n)
 Returns a POINT4D pointer into the POINTARRAY serialized_ptlist, suitable for reading from. More...
 
void ptarray_set_point4d (POINTARRAY *pa, int n, const POINT4D *p4d)
 
uint8_tgetPoint_internal (const POINTARRAY *pa, int n)
 
int ptarray_point_size (const POINTARRAY *pa)
 
POINTARRAYptarray_construct (char hasz, char hasm, uint32_t npoints)
 Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any information. More...
 
POINTARRAYptarray_construct_copy_data (char hasz, char hasm, uint32_t npoints, const uint8_t *ptlist)
 Construct a new POINTARRAY, copying in the data from ptlist. More...
 
POINTARRAYptarray_construct_reference_data (char hasz, char hasm, uint32_t npoints, uint8_t *ptlist)
 Construct a new POINTARRAY, referencing to the data from ptlist. More...
 
POINTARRAYptarray_construct_empty (char hasz, char hasm, uint32_t maxpoints)
 Create a new POINTARRAY with no points. More...
 
int ptarray_append_point (POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
 Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE, then a duplicate point will not be added. More...
 
int ptarray_append_ptarray (POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance)
 Append a POINTARRAY, pa2 to the end of an existing POINTARRAY, pa1. More...
 
int ptarray_insert_point (POINTARRAY *pa, const POINT4D *p, int where)
 Insert a point into an existing POINTARRAY. More...
 
int ptarray_remove_point (POINTARRAY *pa, int where)
 Remove a point from an existing POINTARRAY. More...
 
POINTARRAYptarray_addPoint (const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where)
 Add a point in a pointarray. More...
 
POINTARRAYptarray_removePoint (POINTARRAY *pa, uint32_t where)
 Remove a point from a pointarray. More...
 
POINTARRAYptarray_merge (POINTARRAY *pa1, POINTARRAY *pa2)
 Merge two given POINTARRAY and returns a pointer on the new aggregate one. More...
 
int ptarray_is_closed (const POINTARRAY *pa)
 Check for ring closure using whatever dimensionality is declared on the pointarray. More...
 
int ptarray_is_closed_2d (const POINTARRAY *pa)
 
int ptarray_is_closed_3d (const POINTARRAY *pa)
 
int ptarray_is_closed_z (const POINTARRAY *pa)
 
void ptarray_longitude_shift (POINTARRAY *pa)
 Longitude shift for a pointarray. More...
 
int ptarray_isccw (const POINTARRAY *pa)
 
void ptarray_reverse (POINTARRAY *pa)
 
POINTARRAYptarray_flip_coordinates (POINTARRAY *pa)
 Reverse X and Y axis on a given POINTARRAY. More...
 
POINTARRAYptarray_substring (POINTARRAY *pa, double d1, double d2, double tolerance)
 start location (distance from start / total distance) end location (distance from start / total distance) More...
 
LWGEOMlwgeom_force_2d (const LWGEOM *geom)
 Strip out the Z/M components of an LWGEOM. More...
 
LWGEOMlwgeom_force_3dz (const LWGEOM *geom)
 
LWGEOMlwgeom_force_3dm (const LWGEOM *geom)
 
LWGEOMlwgeom_force_4d (const LWGEOM *geom)
 
LWGEOMlwgeom_simplify (const LWGEOM *igeom, double dist, int preserve_collapsed)
 
LWGEOMlwgeom_set_effective_area (const LWGEOM *igeom, int set_area, double area)
 
LWGEOMlwgeom_force_sfs (LWGEOM *geom, int version)
 
int lwpoint_getPoint2d_p (const LWPOINT *point, POINT2D *out)
 
int lwpoint_getPoint3dz_p (const LWPOINT *point, POINT3DZ *out)
 
int lwpoint_getPoint3dm_p (const LWPOINT *point, POINT3DM *out)
 
int lwpoint_getPoint4d_p (const LWPOINT *point, POINT4D *out)
 
int lwline_add_lwpoint (LWLINE *line, LWPOINT *point, int where)
 Add a LWPOINT to an LWLINE. More...
 
int lwpoly_add_ring (LWPOLY *poly, POINTARRAY *pa)
 Add a ring, allocating extra space if necessary. More...
 
int lwcurvepoly_add_ring (LWCURVEPOLY *poly, LWGEOM *ring)
 Add a ring, allocating extra space if necessary. More...
 
int lwcompound_add_lwgeom (LWCOMPOUND *comp, LWGEOM *geom)
 Add a component, allocating extra space if necessary. More...
 
LWCOMPOUNDlwcompound_construct_from_lwline (const LWLINE *lwpoly)
 Construct an equivalent compound curve from a linestring. More...
 
LWCURVEPOLYlwcurvepoly_construct_from_lwpoly (LWPOLY *lwpoly)
 Construct an equivalent curve polygon from a polygon. More...
 
int lwcollection_ngeoms (const LWCOLLECTION *col)
 
LWGEOMlwgeom_homogenize (const LWGEOM *geom)
 
LWGEOMlwcollection_getsubgeom (LWCOLLECTION *col, int gnum)
 
LWCOLLECTIONlwcollection_extract (LWCOLLECTION *col, int type)
 Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of the specified type. More...
 
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_UNKNOWN. More...
 
BOX3Dbox3d_from_gbox (const GBOX *gbox)
 
GBOXbox3d_to_gbox (const BOX3D *b3d)
 
void expand_box3d (BOX3D *box, double d)
 Expand given box of 'd' units in all directions. More...
 
void ptarray_free (POINTARRAY *pa)
 
void lwpoint_free (LWPOINT *pt)
 
void lwline_free (LWLINE *line)
 
void lwpoly_free (LWPOLY *poly)
 
void lwtriangle_free (LWTRIANGLE *triangle)
 
void lwmpoint_free (LWMPOINT *mpt)
 
void lwmline_free (LWMLINE *mline)
 
void lwmpoly_free (LWMPOLY *mpoly)
 
void lwpsurface_free (LWPSURFACE *psurf)
 
void lwtin_free (LWTIN *tin)
 
void lwcollection_free (LWCOLLECTION *col)
 
void lwcircstring_free (LWCIRCSTRING *curve)
 
void lwgeom_free (LWGEOM *geom)
 
void lwpoint_release (LWPOINT *lwpoint)
 
void lwline_release (LWLINE *lwline)
 
void lwpoly_release (LWPOLY *lwpoly)
 
void lwtriangle_release (LWTRIANGLE *lwtriangle)
 
void lwcircstring_release (LWCIRCSTRING *lwcirc)
 
void lwmpoint_release (LWMPOINT *lwpoint)
 
void lwmline_release (LWMLINE *lwline)
 
void lwmpoly_release (LWMPOLY *lwpoly)
 
void lwpsurface_release (LWPSURFACE *lwpsurface)
 
void lwtin_release (LWTIN *lwtin)
 
void lwcollection_release (LWCOLLECTION *lwcollection)
 
void lwgeom_release (LWGEOM *lwgeom)
 Free the containing LWGEOM and the associated BOX. More...
 
void printBOX3D (BOX3D *b)
 
void printPA (POINTARRAY *pa)
 
void printLWPOINT (LWPOINT *point)
 
void printLWLINE (LWLINE *line)
 
void printLWPOLY (LWPOLY *poly)
 
void printLWTRIANGLE (LWTRIANGLE *triangle)
 
void printLWPSURFACE (LWPSURFACE *psurf)
 
void printLWTIN (LWTIN *tin)
 
float next_float_down (double d)
 
float next_float_up (double d)
 
double distance2d_pt_pt (const POINT2D *p1, const POINT2D *p2)
 The old function nessecary for ptarray_segmentize2d in ptarray.c. More...
 
double distance2d_sqr_pt_pt (const POINT2D *p1, const POINT2D *p2)
 
double distance2d_pt_seg (const POINT2D *p, const POINT2D *A, const POINT2D *B)
 The old function nessecary for ptarray_segmentize2d in ptarray.c. More...
 
double distance2d_sqr_pt_seg (const POINT2D *p, const POINT2D *A, const POINT2D *B)
 
LWGEOMlwgeom_closest_line (const LWGEOM *lw1, const LWGEOM *lw2)
 
LWGEOMlwgeom_furthest_line (const LWGEOM *lw1, const LWGEOM *lw2)
 
LWGEOMlwgeom_closest_point (const LWGEOM *lw1, const LWGEOM *lw2)
 
LWGEOMlwgeom_furthest_point (const LWGEOM *lw1, const LWGEOM *lw2)
 
double lwgeom_mindistance2d (const LWGEOM *lw1, const LWGEOM *lw2)
 Function initialazing min distance calculation. More...
 
double lwgeom_mindistance2d_tolerance (const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
 Function handling min distance calculations and dwithin calculations. More...
 
double lwgeom_maxdistance2d (const LWGEOM *lw1, const LWGEOM *lw2)
 Function initialazing max distance calculation. More...
 
double lwgeom_maxdistance2d_tolerance (const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
 Function handling max distance calculations and dfyllywithin calculations. More...
 
double distance3d_pt_pt (const POINT3D *p1, const POINT3D *p2)
 
double distance3d_pt_seg (const POINT3D *p, const POINT3D *A, const POINT3D *B)
 
LWGEOMlwgeom_furthest_line_3d (LWGEOM *lw1, LWGEOM *lw2)
 
LWGEOMlwgeom_closest_line_3d (const LWGEOM *lw1, const LWGEOM *lw2)
 
LWGEOMlwgeom_closest_point_3d (const LWGEOM *lw1, const LWGEOM *lw2)
 
double lwgeom_mindistance3d (const LWGEOM *lw1, const LWGEOM *lw2)
 Function initializing 3d min distance calculation. More...
 
double lwgeom_mindistance3d_tolerance (const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
 Function handling 3d min distance calculations and dwithin calculations. More...
 
double lwgeom_maxdistance3d (const LWGEOM *lw1, const LWGEOM *lw2)
 Function initializing 3d max distance calculation. More...
 
double lwgeom_maxdistance3d_tolerance (const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
 Function handling 3d max distance calculations and dfullywithin calculations. More...
 
double lwgeom_area (const LWGEOM *geom)
 
double lwgeom_length (const LWGEOM *geom)
 
double lwgeom_length_2d (const LWGEOM *geom)
 
double lwgeom_perimeter (const LWGEOM *geom)
 
double lwgeom_perimeter_2d (const LWGEOM *geom)
 
void lwgeom_affine (LWGEOM *geom, const AFFINE *affine)
 
void lwgeom_scale (LWGEOM *geom, const POINT4D *factors)
 
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 of a collection. More...
 
LWPOINTlwline_get_lwpoint (const LWLINE *line, int where)
 Returns freshly allocated LWPOINT that corresponds to the index where. More...
 
LWPOINTlwcircstring_get_lwpoint (const LWCIRCSTRING *circ, int where)
 
LWPOINTlwcompound_get_startpoint (const LWCOMPOUND *lwcmp)
 
LWPOINTlwcompound_get_endpoint (const LWCOMPOUND *lwcmp)
 
LWPOINTlwcompound_get_lwpoint (const LWCOMPOUND *lwcmp, int where)
 
double ptarray_length_2d (const POINTARRAY *pts)
 Find the 2d length of the given POINTARRAY (even if it's 3d) More...
 
double ptarray_length (const POINTARRAY *pts)
 Find the 3d/2d length of the given POINTARRAY (depending on its dimensionality) More...
 
double ptarray_arc_length_2d (const POINTARRAY *pts)
 Find the 2d length of the given POINTARRAY, using circular arc interpolation between each coordinate triple. More...
 
int pt_in_ring_2d (const POINT2D *p, const POINTARRAY *ring)
 
int azimuth_pt_pt (const POINT2D *p1, const POINT2D *p2, double *ret)
 Compute the azimuth of segment AB in radians. More...
 
int lwpoint_inside_circle (const LWPOINT *p, double cx, double cy, double rad)
 
void lwgeom_reverse (LWGEOM *lwgeom)
 Reverse vertex order of LWGEOM. More...
 
void lwline_reverse (LWLINE *line)
 
void lwpoly_reverse (LWPOLY *poly)
 
void lwtriangle_reverse (LWTRIANGLE *triangle)
 
char * lwgeom_summary (const LWGEOM *lwgeom, int offset)
 
char * lwpoint_to_latlon (const LWPOINT *p, const char *format)
 
int lwgeom_startpoint (const LWGEOM *lwgeom, POINT4D *pt)
 
void lwgeom_force_clockwise (LWGEOM *lwgeom)
 Ensure the outer ring is clockwise oriented and all inner rings are counter-clockwise. More...
 
void lwpoly_force_clockwise (LWPOLY *poly)
 
void lwtriangle_force_clockwise (LWTRIANGLE *triangle)
 
int lwgeom_is_clockwise (LWGEOM *lwgeom)
 Check clockwise orientation on LWGEOM polygons. More...
 
int lwpoly_is_clockwise (LWPOLY *poly)
 
int lwtriangle_is_clockwise (LWTRIANGLE *triangle)
 
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 on AB segment. More...
 
void lwgeom_longitude_shift (LWGEOM *lwgeom)
 
LWGEOMlwgeom_wrapx (const LWGEOM *lwgeom, double cutx, double amount)
 wrap geometry on given cut x value More...
 
int lwgeom_needs_bbox (const LWGEOM *geom)
 Check whether or not a lwgeom is big enough to warrant a bounding box. More...
 
int lwgeom_count_vertices (const LWGEOM *geom)
 Count the total number of vertices in any LWGEOM. More...
 
int lwgeom_count_rings (const LWGEOM *geom)
 Count the total number of rings in any LWGEOM. More...
 
int lwgeom_has_srid (const LWGEOM *geom)
 Return true or false depending on whether a geometry has a valid SRID set. More...
 
int lwgeom_is_empty (const LWGEOM *geom)
 Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) More...
 
int lwgeom_is_closed (const LWGEOM *geom)
 Return true or false depending on whether a geometry is a linear feature that closes on itself. More...
 
int lwgeom_dimensionality (LWGEOM *geom)
 Return the dimensionality (relating to point/line/poly) of an lwgeom. More...
 
char lwgeom_same (const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
 geom1 same as geom2 iff More...
 
char ptarray_same (const POINTARRAY *pa1, const POINTARRAY *pa2)
 
char lwpoint_same (const LWPOINT *p1, const LWPOINT *p2)
 
char lwline_same (const LWLINE *p1, const LWLINE *p2)
 
char lwpoly_same (const LWPOLY *p1, const LWPOLY *p2)
 
char lwtriangle_same (const LWTRIANGLE *p1, const LWTRIANGLE *p2)
 
char lwcollection_same (const LWCOLLECTION *p1, const LWCOLLECTION *p2)
 check for same geometry composition More...
 
char lwcircstring_same (const LWCIRCSTRING *p1, const LWCIRCSTRING *p2)
 
LWGEOMlwgeom_clone (const LWGEOM *lwgeom)
 Clone LWGEOM object. More...
 
LWGEOMlwgeom_clone_deep (const LWGEOM *lwgeom)
 Deep clone an LWGEOM, everything is copied. More...
 
LWPOINTlwpoint_clone (const LWPOINT *lwgeom)
 
POINTARRAYptarray_clone_deep (const POINTARRAY *ptarray)
 Deep clone a pointarray (also clones serialized pointlist) More...
 
LWPOINTlwpoint_construct (int srid, GBOX *bbox, POINTARRAY *point)
 
LWMPOINTlwmpoint_construct (int srid, const POINTARRAY *pa)
 
LWLINElwline_construct (int srid, GBOX *bbox, POINTARRAY *points)
 
LWCIRCSTRINGlwcircstring_construct (int srid, GBOX *bbox, POINTARRAY *points)
 
LWPOLYlwpoly_construct (int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
 
LWCURVEPOLYlwcurvepoly_construct (int srid, GBOX *bbox, uint32_t nrings, LWGEOM **geoms)
 
LWTRIANGLElwtriangle_construct (int srid, GBOX *bbox, POINTARRAY *points)
 
LWCOLLECTIONlwcollection_construct (uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
 
LWGEOMlwgeom_construct_empty (uint8_t type, int srid, char hasz, char hasm)
 
LWPOINTlwpoint_construct_empty (int srid, char hasz, char hasm)
 
LWLINElwline_construct_empty (int srid, char hasz, char hasm)
 
LWPOLYlwpoly_construct_empty (int srid, char hasz, char hasm)
 
LWCURVEPOLYlwcurvepoly_construct_empty (int srid, char hasz, char hasm)
 
LWCIRCSTRINGlwcircstring_construct_empty (int srid, char hasz, char hasm)
 
LWCOMPOUNDlwcompound_construct_empty (int srid, char hasz, char hasm)
 
LWTRIANGLElwtriangle_construct_empty (int srid, char hasz, char hasm)
 
LWMPOINTlwmpoint_construct_empty (int srid, char hasz, char hasm)
 
LWMLINElwmline_construct_empty (int srid, char hasz, char hasm)
 
LWMPOLYlwmpoly_construct_empty (int srid, char hasz, char hasm)
 
LWCOLLECTIONlwcollection_construct_empty (uint8_t type, int srid, char hasz, char hasm)
 
LWPOINTlwpoint_make2d (int srid, double x, double y)
 
LWPOINTlwpoint_make3dz (int srid, double x, double y, double z)
 
LWPOINTlwpoint_make3dm (int srid, double x, double y, double m)
 
LWPOINTlwpoint_make4d (int srid, double x, double y, double z, double m)
 
LWPOINTlwpoint_make (int srid, int hasz, int hasm, const POINT4D *p)
 
LWLINElwline_from_lwgeom_array (int srid, uint32_t ngeoms, LWGEOM **geoms)
 
LWLINElwline_from_ptarray (int srid, uint32_t npoints, LWPOINT **points)
 
LWLINElwline_from_lwmpoint (int srid, const LWMPOINT *mpoint)
 
LWLINElwline_addpoint (LWLINE *line, LWPOINT *point, uint32_t where)
 
LWLINElwline_removepoint (LWLINE *line, uint32_t which)
 
void lwline_setPoint4d (LWLINE *line, uint32_t which, POINT4D *newpoint)
 
LWPOLYlwpoly_from_lwlines (const LWLINE *shell, uint32_t nholes, const LWLINE **holes)
 
LWPOLYlwpoly_construct_rectangle (char hasz, char hasm, POINT4D *p1, POINT4D *p2, POINT4D *p3, POINT4D *p4)
 
LWPOLYlwpoly_construct_envelope (int srid, double x1, double y1, double x2, double y2)
 
LWPOLYlwpoly_construct_circle (int srid, double x, double y, double radius, uint32_t segments_per_quarter, char exterior)
 
LWTRIANGLElwtriangle_from_lwline (const LWLINE *shell)
 
LWMPOINTlwmpoint_from_lwgeom (const LWGEOM *g)
 
double lwpoint_get_x (const LWPOINT *point)
 
double lwpoint_get_y (const LWPOINT *point)
 
double lwpoint_get_z (const LWPOINT *point)
 
double lwpoint_get_m (const LWPOINT *point)
 
int32_t lwgeom_get_srid (const LWGEOM *geom)
 Return SRID number. More...
 
uint32_t lwgeom_get_type (const LWGEOM *geom)
 Return LWTYPE number. More...
 
int lwgeom_has_z (const LWGEOM *geom)
 Return LW_TRUE if geometry has Z ordinates. More...
 
int lwgeom_has_m (const LWGEOM *geom)
 Return LW_TRUE if geometry has M ordinates. More...
 
int lwgeom_ndims (const LWGEOM *geom)
 Return the number of dimensions (2, 3, 4) in a geometry. More...
 
double ptarray_locate_point (const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located)
 
LWLINElwline_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. More...
 
LWMLINElwmline_measured_from_lwmline (const LWMLINE *lwmline, double m_start, double m_end)
 Re-write the measure ordinate (or add one, if it isn't already there) interpolating the measure between the supplied start and end values. More...
 
LWGEOMlwgeom_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. More...
 
LWCOLLECTIONlwgeom_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. More...
 
double lwgeom_interpolate_point (const LWGEOM *lwin, const LWPOINT *lwpt)
 Find the measure value at the location on the line closest to the point. More...
 
double lwgeom_tcpa (const LWGEOM *g1, const LWGEOM *g2, double *mindist)
 Find the time of closest point of approach. More...
 
int lwgeom_cpa_within (const LWGEOM *g1, const LWGEOM *g2, double maxdist)
 Is the closest point of approach within a distance ? More...
 
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 growing from start to end vertex. More...
 
int lwline_is_trajectory (const LWLINE *geom)
 
LWGEOMlwgeom_segmentize2d (LWGEOM *line, double dist)
 
POINTARRAYptarray_segmentize2d (const POINTARRAY *ipa, double dist)
 Returns a modified POINTARRAY so that no segment is longer than the given distance (computed using 2d). More...
 
LWLINElwline_segmentize2d (LWLINE *line, double dist)
 
LWPOLYlwpoly_segmentize2d (LWPOLY *line, double dist)
 
LWCOLLECTIONlwcollection_segmentize2d (LWCOLLECTION *coll, double dist)
 
LWMPOINTlwpoly_to_points (const LWPOLY *poly, int npoints)
 
LWMPOINTlwmpoly_to_points (const LWMPOLY *mpoly, int npoints)
 
LWMPOINTlwgeom_to_points (const LWGEOM *lwgeom, int npoints)
 
LWPOINTlwgeom_median (const LWGEOM *g, double tol, uint32_t maxiter, char fail_if_not_converged)
 
LWPOINTlwmpoint_median (const LWMPOINT *g, double tol, uint32_t maxiter, char fail_if_not_converged)
 
char * lwgeom_geohash (const LWGEOM *lwgeom, int precision)
 Calculate the GeoHash (http://geohash.org) string for a geometry. More...
 
unsigned int geohash_point_as_int (POINT2D *pt)
 
int lwline_crossing_direction (const LWLINE *l1, const LWLINE *l2)
 Given two lines, characterize how (and if) they cross each other. More...
 
LWCOLLECTIONlwgeom_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). More...
 
#define LW_X3D_FLIP_XY   (1<<0)
 Macros for specifying X3D options. More...
 
#define LW_X3D_USE_GEOCOORDS   (1<<1)
 
#define X3D_USE_GEOCOORDS(x)   ((x) & LW_X3D_USE_GEOCOORDS)
 
#define LW_PARSER_CHECK_MINPOINTS   1
 Parser check flags. More...
 
#define LW_PARSER_CHECK_ODD   2
 
#define LW_PARSER_CHECK_CLOSURE   4
 
#define LW_PARSER_CHECK_ZCLOSURE   8
 
#define LW_PARSER_CHECK_NONE   0
 
#define LW_PARSER_CHECK_ALL   (LW_PARSER_CHECK_MINPOINTS | LW_PARSER_CHECK_ODD | LW_PARSER_CHECK_CLOSURE)
 
#define PARSER_ERROR_MOREPOINTS   1
 
#define PARSER_ERROR_ODDPOINTS   2
 
#define PARSER_ERROR_UNCLOSED   3
 
#define PARSER_ERROR_MIXDIMS   4
 
#define PARSER_ERROR_INVALIDGEOM   5
 
#define PARSER_ERROR_INVALIDWKBTYPE   6
 
#define PARSER_ERROR_INCONTINUOUS   7
 
#define PARSER_ERROR_TRIANGLEPOINTS   8
 
#define PARSER_ERROR_LESSPOINTS   9
 
#define PARSER_ERROR_OTHER   10
 
#define UNPARSER_ERROR_MOREPOINTS   1
 
#define UNPARSER_ERROR_ODDPOINTS   2
 
#define UNPARSER_ERROR_UNCLOSED   3
 
#define WKB_ISO   0x01
 
#define WKB_SFSQL   0x02
 
#define WKB_EXTENDED   0x04
 
#define WKB_NDR   0x08
 
#define WKB_XDR   0x10
 
#define WKB_HEX   0x20
 
#define WKB_NO_NPOINTS   0x40 /* Internal use only */
 
#define WKB_NO_SRID   0x80 /* Internal use only */
 
#define WKT_ISO   0x01
 
#define WKT_SFSQL   0x02
 
#define WKT_EXTENDED   0x04
 
#define TWKB_BBOX   0x01 /* User wants bboxes */
 
#define TWKB_SIZE   0x02 /* User wants sizes */
 
#define TWKB_ID   0x04 /* User wants id */
 
#define TWKB_NO_TYPE   0x10 /* No type because it is a sub geoemtry */
 
#define TWKB_NO_ID   0x20 /* No ID because it is a subgeoemtry */
 
#define TWKB_DEFAULT_PRECISION   0 /* Aim for 1m (or ft) rounding by default */
 
enum  LW_LINEARIZE_TOLERANCE_TYPE { LW_LINEARIZE_TOLERANCE_TYPE_SEGS_PER_QUAD = 0, LW_LINEARIZE_TOLERANCE_TYPE_MAX_DEVIATION = 1, LW_LINEARIZE_TOLERANCE_TYPE_MAX_ANGLE = 2 }
 Semantic of the tolerance argument passed to lwcurve_linearize. More...
 
enum  LW_LINEARIZE_FLAGS { LW_LINEARIZE_FLAG_SYMMETRIC = 1 << 0, LW_LINEARIZE_FLAG_RETAIN_ANGLE = 1 << 1 }
 
typedef struct LWPOINTITERATOR LWPOINTITERATOR
 
typedef struct struct_lwgeom_parser_result LWGEOM_PARSER_RESULT
 Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM. More...
 
typedef struct struct_lwgeom_unparser_result LWGEOM_UNPARSER_RESULT
 
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. More...
 
char * lwgeom_extent_to_gml2 (const LWGEOM *geom, const char *srs, int precision, const char *prefix)
 
char * lwgeom_extent_to_gml3 (const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix)
 
char * lwgeom_to_gml3 (const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix, const char *id)
 
char * lwgeom_to_kml2 (const LWGEOM *geom, int precision, const char *prefix)
 
char * lwgeom_to_geojson (const LWGEOM *geo, char *srs, int precision, int has_bbox)
 Takes a GEOMETRY and returns a GeoJson representation. More...
 
char * lwgeom_to_svg (const LWGEOM *geom, int precision, int relative)
 Takes a GEOMETRY and returns a SVG representation. More...
 
char * lwgeom_to_x3d3 (const LWGEOM *geom, char *srs, int precision, int opts, const char *defid)
 
char * lwgeom_to_encoded_polyline (const LWGEOM *geom, int precision)
 
LWGEOMlwgeom_from_geojson (const char *geojson, char **srs)
 Create an LWGEOM object from a GeoJSON representation. More...
 
LWGEOMlwgeom_from_encoded_polyline (const char *encodedpolyline, int precision)
 Create an LWGEOM object from an Encoded Polyline representation. More...
 
void spheroid_init (SPHEROID *s, double a, double b)
 Initialize a spheroid object for use in geodetic functions. More...
 
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. More...
 
LWPOINTlwgeom_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. More...
 
LWGEOMlwgeom_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) from any other vertex. More...
 
double lwgeom_azumith_spheroid (const LWPOINT *r, const LWPOINT *s, const SPHEROID *spheroid)
 Calculate the bearing between two points on a spheroid. More...
 
double lwgeom_area_sphere (const LWGEOM *lwgeom, const SPHEROID *spheroid)
 Calculate the geodetic area of a lwgeom on the sphere. More...
 
double lwgeom_area_spheroid (const LWGEOM *lwgeom, const SPHEROID *spheroid)
 Calculate the geodetic area of a lwgeom on the spheroid. More...
 
double lwgeom_length_spheroid (const LWGEOM *geom, const SPHEROID *s)
 Calculate the geodetic length of a lwgeom on the unit sphere. More...
 
int lwgeom_covers_lwgeom_sphere (const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
 Calculate covers predicate for two lwgeoms on the sphere. More...
 
void lwboundingcircle_destroy (LWBOUNDINGCIRCLE *c)
 
LWBOUNDINGCIRCLElwgeom_calculate_mbc (const LWGEOM *g)
 
LWGEOMlwgeom_remove_repeated_points (const LWGEOM *in, double tolerance)
 Remove repeated points! More...
 
char lwtriangle_is_repeated_points (LWTRIANGLE *triangle)
 
void lwgeom_swap_ordinates (LWGEOM *in, LWORD o1, LWORD o2)
 Swap ordinate values in every vertex of the geometry. More...
 
LWGEOMlwgeom_flip_coordinates (LWGEOM *in)
 Reverse the X and Y coordinate order. More...
 
LWPOINTITERATORlwpointiterator_create (const LWGEOM *g)
 Create a new LWPOINTITERATOR over supplied LWGEOM*. More...
 
LWPOINTITERATORlwpointiterator_create_rw (LWGEOM *g)
 Create a new LWPOINTITERATOR over supplied LWGEOM* Supports modification of coordinates during iteration. More...
 
void lwpointiterator_destroy (LWPOINTITERATOR *s)
 Free all memory associated with the iterator. More...
 
int lwpointiterator_has_next (LWPOINTITERATOR *s)
 Returns LW_TRUE if there is another point available in the iterator. More...
 
int lwpointiterator_modify_next (LWPOINTITERATOR *s, const POINT4D *p)
 Attempts to replace the next point int the iterator with p, and advances the iterator to the next point. More...
 
int lwpointiterator_next (LWPOINTITERATOR *s, POINT4D *p)
 Attempts to assign the next point in the iterator to p, and advances the iterator to the next point. More...
 
int lwpointiterator_peek (LWPOINTITERATOR *s, POINT4D *p)
 Attempts to assigns the next point in the iterator to p. More...
 
uint8_t parse_hex (char *str)
 Convert a single hex digit into the corresponding char. More...
 
void deparse_hex (uint8_t str, char *result)
 Convert a char into a human readable hex digit. More...
 
GBOXgserialized_calculate_gbox_geocentric (const GSERIALIZED *g)
 Calculate the geocentric bounding box directly from the serialized form of the geodetic coordinates. More...
 
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. More...
 
char * gserialized_to_string (const GSERIALIZED *g)
 Return a WKT representation of the gserialized geometry. More...
 
GSERIALIZEDgserialized_copy (const GSERIALIZED *g)
 Return a copy of the input serialized geometry. More...
 
int lwgeom_check_geodetic (const LWGEOM *geom)
 Check that coordinates of LWGEOM are all within the geodetic range (-180, -90, 180, 90) More...
 
int lwgeom_nudge_geodetic (LWGEOM *geom)
 Gently move coordinates of LWGEOM if they are close enough into geodetic range. More...
 
int lwgeom_force_geodetic (LWGEOM *geom)
 Force coordinates of LWGEOM into geodetic range (-180, -90, 180, 90) More...
 
void lwgeom_set_geodetic (LWGEOM *geom, int value)
 Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists. More...
 
int lwgeom_calculate_gbox_geodetic (const LWGEOM *geom, GBOX *gbox)
 Calculate the geodetic bounding box for an LWGEOM. More...
 
int lwgeom_calculate_gbox_cartesian (const LWGEOM *lwgeom, GBOX *gbox)
 Calculate the 2-4D bounding box of a geometry. More...
 
int lwgeom_calculate_gbox (const LWGEOM *lwgeom, GBOX *gbox)
 Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or geodetic. More...
 
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 POINTARRAY (built by de-serializing a GSERIALIZED). More...
 
int ptarray_calculate_gbox_geodetic (const POINTARRAY *pa, GBOX *gbox)
 Calculate geodetic (x/y/z) box and add values to gbox. More...
 
int ptarray_calculate_gbox_cartesian (const POINTARRAY *pa, GBOX *gbox)
 Calculate box (x/y) and add values to gbox. More...
 
int gbox_pt_outside (const GBOX *gbox, POINT2D *pt_outside)
 Calculate a spherical point that falls outside the geocentric gbox. More...
 
GBOXgbox_new (uint8_t flags)
 Create a new gbox with the dimensionality indicated by the flags. More...
 
void gbox_init (GBOX *gbox)
 Zero out all the entries in the GBOX. More...
 
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. More...
 
int gbox_union (const GBOX *g1, const GBOX *g2, GBOX *gout)
 Update the output GBOX to be large enough to include both inputs. More...
 
void gbox_expand (GBOX *g, double d)
 Move the box minimums down and the maximums up by the distance provided. More...
 
void gbox_expand_xyzm (GBOX *g, double dx, double dy, double dz, double dm)
 Move the box minimums down and the maximums up by the distances provided. More...
 
int gbox_init_point3d (const POINT3D *p, GBOX *gbox)
 Initialize a GBOX using the values of the point. More...
 
int gbox_merge_point3d (const POINT3D *p, GBOX *gbox)
 Update the GBOX to be large enough to include itself and the new point. More...
 
int gbox_contains_point3d (const GBOX *gbox, const POINT3D *pt)
 Return true if the point is inside the gbox. More...
 
char * gbox_to_string (const GBOX *gbox)
 Allocate a string representation of the GBOX, based on dimensionality of flags. More...
 
GBOXgbox_copy (const GBOX *gbox)
 Return a copy of the GBOX, based on dimensionality of flags. More...
 
GBOXgbox_from_string (const char *str)
 Warning, do not use this function, it is very particular about inputs. More...
 
int gbox_overlaps (const GBOX *g1, const GBOX *g2)
 Return LW_TRUE if the GBOX overlaps, LW_FALSE otherwise. More...
 
int gbox_overlaps_2d (const GBOX *g1, const GBOX *g2)
 Return LW_TRUE if the GBOX overlaps on the 2d plane, LW_FALSE otherwise. More...
 
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. More...
 
void gbox_duplicate (const GBOX *original, GBOX *duplicate)
 Copy the values of original GBOX into duplicate. More...
 
size_t gbox_serialized_size (uint8_t flags)
 Return the number of bytes necessary to hold a GBOX of this dimension in serialized form. More...
 
int gbox_same (const GBOX *g1, const GBOX *g2)
 Check if 2 given Gbox are the same. More...
 
int gbox_same_2d (const GBOX *g1, const GBOX *g2)
 Check if 2 given GBOX are the same in x and y. More...
 
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 serialized in GSERIALIZED. More...
 
void gbox_float_round (GBOX *gbox)
 Round given GBOX to float boundaries. More...
 
int gbox_is_valid (const GBOX *gbox)
 Return false if any of the dimensions is NaN or infinite. More...
 
uint64_t gbox_get_sortable_hash (const GBOX *g)
 Return a sortable key based on the center point of the GBOX. More...
 
int geometry_type_from_string (const char *str, uint8_t *type, int *z, int *m)
 Utility function to get type number from string. More...
 
size_t gserialized_from_lwgeom_size (const LWGEOM *geom)
 Calculate required memory segment to contain a serialized form of the LWGEOM. More...
 
GSERIALIZEDgserialized_from_lwgeom (LWGEOM *geom, size_t *size)
 Allocate a new GSERIALIZED from an LWGEOM. More...
 
LWGEOMlwgeom_from_gserialized (const GSERIALIZED *g)
 Allocate a new LWGEOM from a GSERIALIZED. More...
 
int gserialized_get_gbox_p (const GSERIALIZED *g, GBOX *gbox)
 Pull a GBOX from the header of a GSERIALIZED, if one is available. More...
 
char * lwgeom_to_wkt (const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
 WKT emitter function. More...
 
uint8_tlwgeom_to_wkb (const LWGEOM *geom, uint8_t variant, size_t *size_out)
 Convert LWGEOM to a char* in WKB format. More...
 
char * lwgeom_to_hexwkb (const LWGEOM *geom, uint8_t variant, size_t *size_out)
 
char * lwgeom_to_ewkt (const LWGEOM *lwgeom)
 Return an alloced string. More...
 
LWGEOMlwgeom_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 segment (this stops a malevolent user from declaring a one-ring polygon to have 10 rings, causing the WKB reader to walk off the end of the memory). More...
 
LWGEOMlwgeom_from_wkt (const char *wkt, const char check)
 
LWGEOMlwgeom_from_hexwkb (const char *hexwkb, const char check)
 
uint8_tbytes_from_hexbytes (const char *hexbuf, size_t hexsize)
 
char * hexbytes_from_bytes (uint8_t *bytes, size_t size)
 
int lwgeom_parse_wkt (LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
 Parse a WKT geometry string into an LWGEOM structure. More...
 
void lwgeom_parser_result_init (LWGEOM_PARSER_RESULT *parser_result)
 
void lwgeom_parser_result_free (LWGEOM_PARSER_RESULT *parser_result)
 
void * lwalloc (size_t size)
 
void * lwrealloc (void *mem, size_t size)
 
void lwfree (void *mem)
 
char * lwmessage_truncate (char *str, int startpos, int endpos, int maxlength, int truncdirection)
 
LWGEOMlwgeom_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 segment (this stops a malevolent user from declaring a one-ring polygon to have 10 rings, causing the WKB reader to walk off the end of the memory). More...
 
uint8_tlwgeom_to_twkb (const LWGEOM *geom, uint8_t variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m, size_t *twkb_size)
 
uint8_tlwgeom_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. More...
 
int lwgeom_has_arc (const LWGEOM *geom)
 
LWGEOMlwgeom_stroke (const LWGEOM *geom, uint32_t perQuad)
 
LWGEOMlwgeom_unstroke (const LWGEOM *geom)
 
LWGEOMlwcurve_linearize (const LWGEOM *geom, double tol, LW_LINEARIZE_TOLERANCE_TYPE type, int flags)
 
const char * lwgeom_geos_version (void)
 Return GEOS version string (not to be freed) More...
 
LWGEOMlwgeom_geos_noop (const LWGEOM *geom)
 Convert an LWGEOM to a GEOS Geometry and convert back – for debug only. More...
 
LWGEOMlwgeom_normalize (const LWGEOM *geom)
 
LWGEOMlwgeom_intersection (const LWGEOM *geom1, const LWGEOM *geom2)
 
LWGEOMlwgeom_difference (const LWGEOM *geom1, const LWGEOM *geom2)
 
LWGEOMlwgeom_symdifference (const LWGEOM *geom1, const LWGEOM *geom2)
 
LWGEOMlwgeom_centroid (const LWGEOM *geom)
 
LWGEOMlwgeom_union (const LWGEOM *geom1, const LWGEOM *geom2)
 
LWGEOMlwgeom_linemerge (const LWGEOM *geom1)
 
LWGEOMlwgeom_unaryunion (const LWGEOM *geom1)
 
LWGEOMlwgeom_clip_by_rect (const LWGEOM *geom1, double x0, double y0, double x1, double y1)
 
LWCOLLECTIONlwgeom_subdivide (const LWGEOM *geom, int maxvertices)
 
LWGEOMlwgeom_snap (const LWGEOM *geom1, const LWGEOM *geom2, double tolerance)
 Snap vertices and segments of a geometry to another using a given tolerance. More...
 
LWGEOMlwgeom_sharedpaths (const LWGEOM *geom1, const LWGEOM *geom2)
 
LWGEOMlwgeom_offsetcurve (const LWLINE *lwline, double size, int quadsegs, int joinStyle, double mitreLimit)
 
int lwgeom_is_simple (const LWGEOM *lwgeom)
 
projPJ lwproj_from_string (const char *txt)
 Get a projection from a string representation. More...
 
int lwgeom_transform (LWGEOM *geom, projPJ inpj, projPJ outpj)
 Transform (reproject) a geometry in-place. More...
 
int ptarray_transform (POINTARRAY *geom, projPJ inpj, projPJ outpj)
 Transform given POINTARRAY from inpj projection to outpj projection. More...
 
int point4d_transform (POINT4D *pt, projPJ srcpj, projPJ dstpj)
 
LWGEOMlwgeom_buildarea (const LWGEOM *geom)
 Take a geometry and return an areal geometry (Polygon or MultiPolygon). More...
 
LWGEOMlwgeom_make_valid (LWGEOM *geom)
 Attempts to make an invalid geometries valid w/out losing points. More...
 
LWGEOMlwgeom_split (const LWGEOM *lwgeom_in, const LWGEOM *blade_in)
 
LWGEOMlwgeom_node (const LWGEOM *lwgeom_in)
 
LWGEOMlwgeom_delaunay_triangulation (const LWGEOM *geom, double tolerance, int edgeOnly)
 Take vertices of a geometry and build a delaunay triangulation on them. More...
 
LWGEOMlwgeom_voronoi_diagram (const LWGEOM *g, const GBOX *env, double tolerance, int output_edges)
 Take vertices of a geometry and build the Voronoi diagram. More...
 
int * lwgeom_cluster_2d_kmeans (const LWGEOM **geoms, int ngeoms, int k)
 Take a list of LWGEOMs and a number of clusters and return an integer array indicating which cluster each geometry is in. More...
 

Detailed Description

This library is the generic geometry handling section of PostGIS.

The geometry objects, constructors, destructors, and a set of spatial processing functions, are implemented here.

The library is designed for use in non-PostGIS applications if necessary. The units tests at cunit/cu_tester.c and the loader/dumper programs at ../loader/shp2pgsql.c are examples of non-PostGIS applications using liblwgeom.

Programs using this library can install their custom memory managers and error handlers by calling the lwgeom_set_handlers() function, otherwise the default ones will be used.

Definition in file liblwgeom.h.