30 #define _LIBLWGEOM_H 1
35 #define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 1
38 #if defined(PJ_VERSION) && PJ_VERSION >= 490
40 #define PROJ_GEODESIC 1
43 #define PROJ_GEODESIC 0
65 #define LIBLWGEOM_VERSION "2.5.9"
66 #define LIBLWGEOM_VERSION_MAJOR "2"
67 #define LIBLWGEOM_VERSION_MINOR "5"
68 #define LIBLWGEOM_GEOS_VERSION "38"
88 #define MULTIPOINTTYPE 4
89 #define MULTILINETYPE 5
90 #define MULTIPOLYGONTYPE 6
91 #define COLLECTIONTYPE 7
92 #define CIRCSTRINGTYPE 8
93 #define COMPOUNDTYPE 9
94 #define CURVEPOLYTYPE 10
95 #define MULTICURVETYPE 11
96 #define MULTISURFACETYPE 12
97 #define POLYHEDRALSURFACETYPE 13
98 #define TRIANGLETYPE 14
107 #define WKBZOFFSET 0x80000000
108 #define WKBMOFFSET 0x40000000
109 #define WKBSRIDFLAG 0x20000000
110 #define WKBBBOXFLAG 0x10000000
128 #define WGS84_MAJOR_AXIS 6378137.0
129 #define WGS84_INVERSE_FLATTENING 298.257223563
130 #define WGS84_MINOR_AXIS (WGS84_MAJOR_AXIS - WGS84_MAJOR_AXIS / WGS84_INVERSE_FLATTENING)
131 #define WGS84_RADIUS ((2.0 * WGS84_MAJOR_AXIS + WGS84_MINOR_AXIS ) / 3.0)
140 #define FLAGS_GET_Z(flags) ((flags) & 0x01)
141 #define FLAGS_GET_M(flags) (((flags) & 0x02)>>1)
142 #define FLAGS_GET_BBOX(flags) (((flags) & 0x04)>>2)
143 #define FLAGS_GET_GEODETIC(flags) (((flags) & 0x08)>>3)
144 #define FLAGS_GET_READONLY(flags) (((flags) & 0x10)>>4)
145 #define FLAGS_GET_SOLID(flags) (((flags) & 0x20)>>5)
146 #define FLAGS_SET_Z(flags, value) ((flags) = (value) ? ((flags) | 0x01) : ((flags) & 0xFE))
147 #define FLAGS_SET_M(flags, value) ((flags) = (value) ? ((flags) | 0x02) : ((flags) & 0xFD))
148 #define FLAGS_SET_BBOX(flags, value) ((flags) = (value) ? ((flags) | 0x04) : ((flags) & 0xFB))
149 #define FLAGS_SET_GEODETIC(flags, value) ((flags) = (value) ? ((flags) | 0x08) : ((flags) & 0xF7))
150 #define FLAGS_SET_READONLY(flags, value) ((flags) = (value) ? ((flags) | 0x10) : ((flags) & 0xEF))
151 #define FLAGS_SET_SOLID(flags, value) ((flags) = (value) ? ((flags) | 0x20) : ((flags) & 0xDF))
152 #define FLAGS_NDIMS(flags) (2 + FLAGS_GET_Z(flags) + FLAGS_GET_M(flags))
153 #define FLAGS_GET_ZM(flags) (FLAGS_GET_M(flags) + FLAGS_GET_Z(flags) * 2)
154 #define FLAGS_NDIMS_BOX(flags) (FLAGS_GET_GEODETIC(flags) ? 3 : FLAGS_NDIMS(flags))
165 #define TYPMOD_GET_SRID(typmod) ((((typmod) & 0x0FFFFF00) - ((typmod) & 0x10000000)) >> 8)
166 #define TYPMOD_SET_SRID(typmod, srid) ((typmod) = (((typmod) & 0xE00000FF) | ((srid & 0x001FFFFF)<<8)))
167 #define TYPMOD_GET_TYPE(typmod) ((typmod & 0x000000FC)>>2)
168 #define TYPMOD_SET_TYPE(typmod, type) ((typmod) = (typmod & 0xFFFFFF03) | ((type & 0x0000003F)<<2))
169 #define TYPMOD_GET_Z(typmod) ((typmod & 0x00000002)>>1)
170 #define TYPMOD_SET_Z(typmod) ((typmod) = typmod | 0x00000002)
171 #define TYPMOD_GET_M(typmod) (typmod & 0x00000001)
172 #define TYPMOD_SET_M(typmod) ((typmod) = typmod | 0x00000001)
173 #define TYPMOD_GET_NDIMS(typmod) (2+TYPMOD_GET_Z(typmod)+TYPMOD_GET_M(typmod))
179 #define SRID_MAXIMUM 999999
185 #define SRID_USER_MAXIMUM 998999
188 #define SRID_UNKNOWN 0
189 #define SRID_IS_UNKNOWN(x) ((int)x<=0)
192 #define SRID_INVALID (999999 + 2)
198 #define SRID_DEFAULT 4326
201 # define __attribute__(x)
218 typedef void* (*lwallocator)(
size_t size);
219 typedef void* (*lwreallocator)(
void *mem,
size_t size);
273 double afac, bfac, cfac, dfac, efac, ffac, gfac, hfac, ifac, xoff, yoff, zoff;
1542 #define LW_GML_IS_DIMS (1<<0)
1544 #define LW_GML_IS_DEGREE (1<<1)
1546 #define LW_GML_SHORTLINE (1<<2)
1548 #define LW_GML_EXTENT (1<<4)
1551 #define IS_DIMS(x) ((x) & LW_GML_IS_DIMS)
1552 #define IS_DEGREE(x) ((x) & LW_GML_IS_DEGREE)
1560 #define LW_X3D_FLIP_XY (1<<0)
1561 #define LW_X3D_USE_GEOCOORDS (1<<1)
1562 #define X3D_USE_GEOCOORDS(x) ((x) & LW_X3D_USE_GEOCOORDS)
2000 #define LW_PARSER_CHECK_MINPOINTS 1
2001 #define LW_PARSER_CHECK_ODD 2
2002 #define LW_PARSER_CHECK_CLOSURE 4
2003 #define LW_PARSER_CHECK_ZCLOSURE 8
2005 #define LW_PARSER_CHECK_NONE 0
2006 #define LW_PARSER_CHECK_ALL (LW_PARSER_CHECK_MINPOINTS | LW_PARSER_CHECK_ODD | LW_PARSER_CHECK_CLOSURE)
2028 #define PARSER_ERROR_MOREPOINTS 1
2029 #define PARSER_ERROR_ODDPOINTS 2
2030 #define PARSER_ERROR_UNCLOSED 3
2031 #define PARSER_ERROR_MIXDIMS 4
2032 #define PARSER_ERROR_INVALIDGEOM 5
2033 #define PARSER_ERROR_INVALIDWKBTYPE 6
2034 #define PARSER_ERROR_INCONTINUOUS 7
2035 #define PARSER_ERROR_TRIANGLEPOINTS 8
2036 #define PARSER_ERROR_LESSPOINTS 9
2037 #define PARSER_ERROR_OTHER 10
2057 #define UNPARSER_ERROR_MOREPOINTS 1
2058 #define UNPARSER_ERROR_ODDPOINTS 2
2059 #define UNPARSER_ERROR_UNCLOSED 3
2066 #define WKB_ISO 0x01
2067 #define WKB_SFSQL 0x02
2068 #define WKB_EXTENDED 0x04
2069 #define WKB_NDR 0x08
2070 #define WKB_XDR 0x10
2071 #define WKB_HEX 0x20
2072 #define WKB_NO_NPOINTS 0x40
2073 #define WKB_NO_SRID 0x80
2075 #define WKT_ISO 0x01
2076 #define WKT_SFSQL 0x02
2077 #define WKT_EXTENDED 0x04
2083 #define TWKB_BBOX 0x01
2084 #define TWKB_SIZE 0x02
2085 #define TWKB_ID 0x04
2086 #define TWKB_NO_TYPE 0x10
2087 #define TWKB_NO_ID 0x20
2088 #define TWKB_DEFAULT_PRECISION 0
2150 extern void *
lwalloc(
size_t size);
2151 extern void *
lwrealloc(
void *mem,
size_t size);
2152 extern void lwfree(
void *mem);
2155 extern char *
lwmessage_truncate(
char *str,
int startpos,
int endpos,
int maxlength,
int truncdirection);
void deparse_hex(uint8_t str, char *result)
Convert a char into a human readable hex digit.
int lwgeom_is_closed(const LWGEOM *geom)
Return true or false depending on whether a geometry is a linear feature that closes on itself.
size_t gserialized_from_lwgeom_size(const LWGEOM *geom)
Calculate required memory segment to contain a serialized form of the LWGEOM.
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.
int ptarray_remove_point(POINTARRAY *pa, uint32_t where)
Remove a point from an existing POINTARRAY.
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
LW_LINEARIZE_TOLERANCE_TYPE
Semantic of the tolerance argument passed to lwcurve_linearize.
@ LW_LINEARIZE_TOLERANCE_TYPE_MAX_ANGLE
Tolerance expresses the maximum angle between the radii generating approximation line vertices,...
@ LW_LINEARIZE_TOLERANCE_TYPE_SEGS_PER_QUAD
Tolerance expresses the number of segments to use for each quarter of circle (quadrant).
@ LW_LINEARIZE_TOLERANCE_TYPE_MAX_DEVIATION
Tolerance expresses the maximum distance between an arbitrary point on the curve and the closest poin...
char * lwgeom_to_svg(const LWGEOM *geom, int precision, int relative)
Takes a GEOMETRY and returns a SVG representation.
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWGEOM * lwcompound_as_lwgeom(const LWCOMPOUND *obj)
LWPOINT * lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, uint32_t where)
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
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.
LWPOINT * lwpoint_make2d(int srid, double x, double y)
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
int gbox_union(const GBOX *g1, const GBOX *g2, GBOX *gout)
Update the output GBOX to be large enough to include both inputs.
LWGEOM * lwgeom_centroid(const LWGEOM *geom)
void lwgeom_request_interrupt(void)
Request interruption of any running code.
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
int lwgeom_ndims(const LWGEOM *geom)
Return the number of dimensions (2, 3, 4) in a geometry.
uint32_t lwtype_get_collectiontype(uint8_t type)
Given an lwtype number, what homogeneous collection can hold it?
void lwgeom_cancel_interrupt(void)
Cancel any interruption request.
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 * lwpoly_to_points(const LWPOLY *poly, uint32_t npoints)
void lwmpoly_release(LWMPOLY *lwpoly)
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
LWGEOM * lwgeom_geos_noop(const LWGEOM *geom)
Convert an LWGEOM to a GEOS Geometry and convert back – for debug only.
void(*) typedef void(* lwdebuglogger)(int level, const char *fmt, va_list ap) __attribute__((format(printf
void gbox_duplicate(const GBOX *original, GBOX *duplicate)
Copy the values of original GBOX into duplicate.
LWGEOM * lwgeom_from_geojson(const char *geojson, char **srs)
Create an LWGEOM object from a GeoJSON representation.
LWGEOM * lwgeom_locate_along(const LWGEOM *lwin, double m, double offset)
Determine the location(s) along a measured line where m occurs and return as a multipoint.
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
LWGEOM * lwgeom_delaunay_triangulation(const LWGEOM *geom, double tolerance, int32_t edgeOnly)
Take vertices of a geometry and build a delaunay triangulation on them.
LWGEOM * lwgeom_closest_point(const LWGEOM *lw1, const LWGEOM *lw2)
GBOX * gbox_copy(const GBOX *gbox)
Return a copy of the GBOX, based on dimensionality of flags.
double lwgeom_maxdistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing max distance calculation.
int gbox_same_2d(const GBOX *g1, const GBOX *g2)
Check if 2 given GBOX are the same in x and y.
int lwgeom_startpoint(const LWGEOM *lwgeom, POINT4D *pt)
int ptarray_is_closed(const POINTARRAY *pa)
Check for ring closure using whatever dimensionality is declared on the pointarray.
int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret)
Compute the azimuth of segment AB in radians.
GBOX * box3d_to_gbox(const BOX3D *b3d)
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.
void() lwinterrupt_callback()
Install a callback to be called periodically during algorithm execution.
LWGEOM * lwgeom_node(const LWGEOM *lwgeom_in)
projPJ lwproj_from_string(const char *txt)
Get a projection from a string representation.
LWCIRCSTRING * lwcircstring_construct_empty(int srid, char hasz, char hasm)
void lwmpoint_free(LWMPOINT *mpt)
struct struct_lwgeom_unparser_result LWGEOM_UNPARSER_RESULT
void gbox_expand(GBOX *g, double d)
Move the box minimums down and the maximums up by the distance provided.
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.
LWGEOM * lwgeom_symdifference(const LWGEOM *geom1, const LWGEOM *geom2)
LWGEOM * lwgeom_segmentize_sphere(const LWGEOM *lwg_in, double max_seg_length)
Derive a new geometry with vertices added to ensure no vertex is more than max_seg_length (in radians...
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
int ptarray_append_ptarray(POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance)
Append a POINTARRAY, pa2 to the end of an existing POINTARRAY, pa1.
int gbox_contains_point3d(const GBOX *gbox, const POINT3D *pt)
Return true if the point is inside the gbox.
LWGEOM * lwgeom_force_4d(const LWGEOM *geom)
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
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)...
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
double lwpoint_get_m(const LWPOINT *point)
void lwgeom_trim_bits_in_place(LWGEOM *geom, int32_t prec_x, int32_t prec_y, int32_t prec_z, int32_t prec_m)
Trim the bits of an LWGEOM in place, to optimize it for compression.
LWLINE * lwline_segmentize2d(const LWLINE *line, double dist)
void lwpoint_free(LWPOINT *pt)
LWMPOLY * lwmpoly_construct_empty(int srid, char hasz, char hasm)
void lwgeom_longitude_shift(LWGEOM *lwgeom)
LWCURVEPOLY * lwcurvepoly_construct_empty(int srid, char hasz, char hasm)
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.
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
POINTARRAY * ptarray_substring(POINTARRAY *pa, double d1, double d2, double tolerance)
@d1 start location (distance from start / total distance) @d2 end location (distance from start / tot...
LWCOLLECTION * lwcollection_segmentize2d(const LWCOLLECTION *coll, double dist)
double distance3d_pt_seg(const POINT3D *p, const POINT3D *A, const POINT3D *B)
void lwpoint_release(LWPOINT *lwpoint)
void lwgeom_free(LWGEOM *geom)
int ptarray_is_closed_3d(const POINTARRAY *pa)
LWGEOM * lwcurve_linearize(const LWGEOM *geom, double tol, LW_LINEARIZE_TOLERANCE_TYPE type, int flags)
char * hexbytes_from_bytes(const uint8_t *bytes, size_t size)
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.
double lwgeom_maxdistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling 3d max distance calculations and dfullywithin calculations.
LWGEOM * lwgeom_split(const LWGEOM *lwgeom_in, const LWGEOM *blade_in)
int gbox_pt_outside(const GBOX *gbox, POINT2D *pt_outside)
Calculate a spherical point that falls outside the geocentric gbox.
void lwmpoly_free(LWMPOLY *mpoly)
LWGEOM * lwgeom_filter_m(LWGEOM *geom, double min, double max, int returnm)
double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
GBOX * gbox_new(uint8_t flags)
Create a new gbox with the dimensionality indicated by the flags.
void(* lwfreeor)(void *mem)
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
LWTIN * lwtin_add_lwtriangle(LWTIN *mobj, const LWTRIANGLE *obj)
LWGEOM * lwgeom_unstroke(const LWGEOM *geom)
double lwgeom_perimeter_2d(const LWGEOM *geom)
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.
LWPOINT * lwcompound_get_lwpoint(const LWCOMPOUND *lwcmp, uint32_t where)
int lwpoint_inside_circle(const LWPOINT *p, double cx, double cy, double rad)
LWMLINE * lwmline_construct_empty(int srid, char hasz, char hasm)
LWGEOM * lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2)
void interpolate_point4d(const POINT4D *A, const POINT4D *B, POINT4D *I, double F)
Find interpolation point I between point A and point B so that the len(AI) == len(AB)*F and I falls o...
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Pull a GBOX from the header of a GSERIALIZED, if one is available.
void lwtin_free(LWTIN *tin)
LWGEOM * lwgeom_from_twkb(const uint8_t *twkb, size_t twkb_size, char check)
WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory...
LWGEOM * lwcollection_getsubgeom(LWCOLLECTION *col, int gnum)
POINTARRAY * ptarray_removePoint(POINTARRAY *pa, uint32_t where)
Remove a point from a pointarray.
int ptarray_transform(POINTARRAY *pa, projPJ inpj, projPJ outpj)
Transform given POINTARRAY from inpj projection to outpj projection.
int lwpoint_getPoint3dm_p(const LWPOINT *point, POINT3DM *out)
void printLWPOLY(LWPOLY *poly)
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
LWGEOM * lwmline_as_lwgeom(const LWMLINE *obj)
LWGEOM * lwgeom_segmentize2d(const LWGEOM *line, double dist)
LWGEOM * lwgeom_offsetcurve(const LWGEOM *geom, double size, int quadsegs, int joinStyle, double mitreLimit)
void lwgeom_set_debuglogger(lwdebuglogger debuglogger)
double lwgeom_interpolate_point(const LWGEOM *lwin, const LWPOINT *lwpt)
Find the measure value at the location on the line closest to the point.
POINT3DM getPoint3dm(const POINTARRAY *pa, uint32_t n)
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
int gbox_merge_point3d(const POINT3D *p, GBOX *gbox)
Update the GBOX to be large enough to include itself and the new point.
void lwgeom_remove_repeated_points_in_place(LWGEOM *in, double tolerance)
POINTARRAY * ptarray_addPoint(const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where)
Add a point in a pointarray.
struct struct_lwgeom_parser_result LWGEOM_PARSER_RESULT
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.
LWGEOM * lwgeom_furthest_line_3d(LWGEOM *lw1, LWGEOM *lw2)
LWGEOM * lwgeom_closest_point_3d(const LWGEOM *lw1, const LWGEOM *lw2)
BOX3D * box3d_from_gbox(const GBOX *gbox)
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
const POINT4D * getPoint4d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT4D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
LWGEOM * lwmpoint_as_lwgeom(const LWMPOINT *obj)
unsigned int geohash_point_as_int(POINT2D *pt)
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
void lwline_release(LWLINE *lwline)
double lwgeom_area_spheroid(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the spheroid.
LWGEOM * lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad)
int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the 2-4D bounding box of a geometry.
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
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 ...
int gbox_overlaps(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the GBOX overlaps, LW_FALSE otherwise.
char * lwgeom_to_x3d3(const LWGEOM *geom, char *srs, int precision, int opts, const char *defid)
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result)
LWGEOM * lwgeom_force_sfs(LWGEOM *geom, int version)
char * lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection)
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
LWGEOM * lwgeom_furthest_point(const LWGEOM *lw1, const LWGEOM *lw2)
int lwline_crossing_direction(const LWLINE *l1, const LWLINE *l2)
Given two lines, characterize how (and if) they cross each other.
int lwgeom_is_simple(const LWGEOM *lwgeom)
void lwgeom_simplify_in_place(LWGEOM *igeom, double dist, int preserve_collapsed)
double lwpoint_get_x(const LWPOINT *point)
LWGEOM * lwgeom_snap(const LWGEOM *geom1, const LWGEOM *geom2, double tolerance)
Snap vertices and segments of a geometry to another using a given tolerance.
int lwpointiterator_peek(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assigns the next point in the iterator to p.
void lwtin_release(LWTIN *lwtin)
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
char * lwgeom_to_kml2(const LWGEOM *geom, int precision, const char *prefix)
void printPA(POINTARRAY *pa)
int gserialized_get_zm(const GSERIALIZED *gser)
Return a number indicating presence of Z and M coordinates.
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
LWGEOM * lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
Create an LWGEOM object from an Encoded Polyline representation.
int lwgeom_check_geodetic(const LWGEOM *geom)
Check that coordinates of LWGEOM are all within the geodetic range (-180, -90, 180,...
LWGEOM * lwgeom_difference(const LWGEOM *geom1, const LWGEOM *geom2)
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
uint8_t * lwgeom_to_wkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
Convert LWGEOM to a char* in WKB format.
const char * lwgeom_geos_version(void)
Return GEOS version string (not to be freed)
uint8_t * bytes_from_hexbytes(const char *hexbuf, size_t hexsize)
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
char * gserialized_to_string(const GSERIALIZED *g)
Return a WKT representation of the gserialized geometry.
int gbox_overlaps_2d(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the GBOX overlaps on the 2d plane, LW_FALSE otherwise.
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located)
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
LWMPOLY * lwgeom_as_lwmpoly(const LWGEOM *lwgeom)
const POINT3DZ * getPoint3dz_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT3DZ pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
int lwgeom_has_srid(const LWGEOM *geom)
Return true or false depending on whether a geometry has a valid SRID set.
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
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...
double lwgeom_length(const LWGEOM *geom)
LWGEOM * lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance)
LWPOLY * lwpoly_construct_circle(int srid, double x, double y, double radius, uint32_t segments_per_quarter, char exterior)
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.
const char * lwgeom_version(void)
Return lwgeom version string (not to be freed)
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).
GSERIALIZED * gserialized_copy(const GSERIALIZED *g)
Return a copy of the input serialized geometry.
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
LWGEOM * lwgeom_reverse(const LWGEOM *lwgeom)
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)
LWGEOM * lwpsurface_as_lwgeom(const LWPSURFACE *obj)
int lwgeom_covers_lwgeom_sphere(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
Calculate covers predicate for two lwgeoms on the sphere.
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
void printBOX3D(BOX3D *b)
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
LWPOINT * lwcompound_get_startpoint(const LWCOMPOUND *lwcmp)
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
Utility function to get type number from string.
void lwgeom_scale(LWGEOM *geom, const POINT4D *factors)
LWTRIANGLE * lwtriangle_from_lwline(const LWLINE *shell)
char * lwgeom_summary(const LWGEOM *lwgeom, int offset)
double lwgeom_tcpa(const LWGEOM *g1, const LWGEOM *g2, double *mindist)
Find the time of closest point of approach.
void lwmline_release(LWMLINE *lwline)
LWGEOM * lwgeom_pointonsurface(const LWGEOM *geom)
LWBOUNDINGCIRCLE * lwgeom_calculate_mbc(const LWGEOM *g)
int gbox_init_point3d(const POINT3D *p, GBOX *gbox)
Initialize a GBOX using the values of the point.
LWGEOM * lwgeom_sharedpaths(const LWGEOM *geom1, const LWGEOM *geom2)
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.
int pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring)
LWPOLY * lwpoly_construct_rectangle(char hasz, char hasm, POINT4D *p1, POINT4D *p2, POINT4D *p3, POINT4D *p4)
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
LWTRIANGLE * lwgeom_as_lwtriangle(const LWGEOM *lwgeom)
size_t gbox_serialized_size(uint8_t flags)
Return the number of bytes necessary to hold a GBOX of this dimension in serialized form.
void(* lwreporter)(const char *fmt, va_list ap) __attribute__((format(printf
LWMPOINT * lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
LWLINE * lwline_addpoint(LWLINE *line, LWPOINT *point, uint32_t where)
double lwgeom_area(const LWGEOM *geom)
LWCURVEPOLY * lwcurvepoly_construct(int srid, GBOX *bbox, uint32_t nrings, LWGEOM **geoms)
LWMLINE * lwgeom_as_lwmline(const LWGEOM *lwgeom)
LWMPOLY * lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj)
LWGEOM * lwgeom_voronoi_diagram(const LWGEOM *g, const GBOX *env, double tolerance, int output_edges)
Take vertices of a geometry and build the Voronoi diagram.
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where)
Insert a point into an existing POINTARRAY.
LWPSURFACE * lwpsurface_add_lwpoly(LWPSURFACE *mobj, const LWPOLY *obj)
char * lwgeom_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix, const char *id)
double distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
char * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
int gserialized_is_geodetic(const GSERIALIZED *gser)
Check if a GSERIALIZED is a geography.
int ptarray_calculate_gbox_cartesian(const POINTARRAY *pa, GBOX *gbox)
Calculate box (x/y) and add values to gbox.
void printLWTIN(LWTIN *tin)
char * lwgeom_extent_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix)
@ LW_LINEARIZE_FLAG_SYMMETRIC
Symmetric linearization means that the output vertices would be the same no matter the order of the p...
@ LW_LINEARIZE_FLAG_RETAIN_ANGLE
Retain angle instructs the engine to try its best to retain the requested angle between generating ra...
double distance3d_pt_pt(const POINT3D *p1, const POINT3D *p2)
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
int lwpointiterator_modify_next(LWPOINTITERATOR *s, const POINT4D *p)
Attempts to replace the next point int the iterator with p, and advances the iterator to the next poi...
POINTARRAY * lwline_interpolate_points(const LWLINE *line, double length_fraction, char repeat)
Interpolate one or more points along a line.
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...
LWCOLLECTION * lwgeom_subdivide(const LWGEOM *geom, uint32_t maxvertices)
LWGEOM * lwgeom_chaikin(const LWGEOM *igeom, int n_iterations, int preserve_endpoint)
void * lwrealloc(void *mem, size_t size)
LWMPOINT * lwgeom_to_points(const LWGEOM *lwgeom, uint32_t npoints)
int lwpoint_getPoint3dz_p(const LWPOINT *point, POINT3DZ *out)
LWGEOM * lwgeom_homogenize(const LWGEOM *geom)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin calculations.
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
LWGEOM * lwgeom_unaryunion(const LWGEOM *geom1)
size_t ptarray_point_size(const POINTARRAY *pa)
LWGEOM * lwgeom_as_curve(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate CURVE* type.
int ptarray_calculate_gbox_geodetic(const POINTARRAY *pa, GBOX *gbox)
Calculate geodetic (x/y/z) box and add values to gbox.
LWGEOM * lwgeom_normalize(const LWGEOM *geom)
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
void lwcircstring_free(LWCIRCSTRING *curve)
LWPOINT * lwpoint_make3dm(int srid, double x, double y, double m)
double lwgeom_mindistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling 3d min distance calculations and dwithin calculations.
void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2)
Swap ordinate values in every vertex of the geometry.
void lwgeom_affine(LWGEOM *geom, const AFFINE *affine)
LWCOLLECTION * lwgeom_clip_to_ordinate_range(const LWGEOM *lwin, char ordinate, double from, double to, double offset)
Given a geometry clip based on the from/to range of one of its ordinates (x, y, z,...
int gserialized_ndims(const GSERIALIZED *gser)
Return the number of dimensions (2, 3, 4) in a geometry.
LWGEOM * lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2)
uint8_t lwtype_multitype(uint8_t type)
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
LWGEOM * lwgeom_buildarea(const LWGEOM *geom)
Take a geometry and return an areal geometry (Polygon or MultiPolygon).
void lwtriangle_free(LWTRIANGLE *triangle)
int lwcurvepoly_add_ring(LWCURVEPOLY *poly, LWGEOM *ring)
Add a ring, allocating extra space if necessary.
void *(* lwreallocator)(void *mem, size_t size)
LWCURVEPOLY * lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom)
LWPOINTITERATOR * lwpointiterator_create_rw(LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM* Supports modification of coordinates during iterat...
CG_LINE_CROSS_TYPE
The return values of lwline_crossing_direction()
@ LINE_MULTICROSS_END_RIGHT
@ LINE_MULTICROSS_END_SAME_FIRST_LEFT
@ LINE_MULTICROSS_END_LEFT
@ LINE_MULTICROSS_END_SAME_FIRST_RIGHT
void lwboundingcircle_destroy(LWBOUNDINGCIRCLE *c)
void *(* lwallocator)(size_t size)
Global functions for memory/logging handlers.
void lwcollection_release(LWCOLLECTION *lwcollection)
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
LWCIRCSTRING * lwcircstring_construct(int srid, GBOX *bbox, POINTARRAY *points)
char * lwgeom_to_hexwkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
double lwgeom_length_2d(const LWGEOM *geom)
uint32_t lwgeom_count_rings(const LWGEOM *geom)
Count the total number of rings in any LWGEOM.
int lwgeom_force_geodetic(LWGEOM *geom)
Force coordinates of LWGEOM into geodetic range (-180, -90, 180, 90)
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing min distance calculation.
int ptarray_is_closed_z(const POINTARRAY *pa)
int clamp_srid(int srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...
char * lwpoint_to_latlon(const LWPOINT *p, const char *format)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
POINT3DZ getPoint3dz(const POINTARRAY *pa, uint32_t n)
GBOX * gserialized_calculate_gbox_geocentric(const GSERIALIZED *g)
Calculate the geocentric bounding box directly from the serialized form of the geodetic coordinates.
LWLINE * lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint)
void lwgeom_force_clockwise(LWGEOM *lwgeom)
Force Right-hand-rule on LWGEOM polygons.
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
void lwcollection_free(LWCOLLECTION *col)
void printLWLINE(LWLINE *line)
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...
GBOX * gbox_from_string(const char *str)
Warning, do not use this function, it is very particular about inputs.
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
int lwcollection_ngeoms(const LWCOLLECTION *col)
double distance2d_sqr_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
LWCOLLECTION * lwgeom_locate_between(const LWGEOM *lwin, double from, double to, double offset)
Determine the segments along a measured line that fall within the m-range given.
void ptarray_free(POINTARRAY *pa)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
int lwgeom_nudge_geodetic(LWGEOM *geom)
Gently move coordinates of LWGEOM if they are close enough into geodetic range.
LWGEOM * lwgeom_force_3dm(const LWGEOM *geom)
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
void lwcircstring_release(LWCIRCSTRING *lwcirc)
LWGEOM * lwgeom_set_effective_area(const LWGEOM *igeom, int set_area, double area)
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
LWGEOM * lwtin_as_lwgeom(const LWTIN *obj)
LWPOLY * lwpoly_segmentize2d(const LWPOLY *line, double dist)
POINT2D getPoint2d(const POINTARRAY *pa, uint32_t n)
LWGEOM * lwcurvepoly_as_lwgeom(const LWCURVEPOLY *obj)
int lwgeom_transform(LWGEOM *geom, projPJ inpj, projPJ outpj)
Transform (reproject) a geometry in-place.
LWTIN * lwgeom_as_lwtin(const LWGEOM *lwgeom)
void lwpoly_release(LWPOLY *lwpoly)
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
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...
LWGEOM * lwcircstring_as_lwgeom(const LWCIRCSTRING *obj)
char * lwgeom_extent_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
LWPSURFACE * lwgeom_as_lwpsurface(const LWGEOM *lwgeom)
void lwline_setPoint4d(LWLINE *line, uint32_t which, POINT4D *newpoint)
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
LWCOLLECTION * lwcollection_concat_in_place(LWCOLLECTION *col1, const LWCOLLECTION *col2)
Appends all geometries from col2 to col1 in place.
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,...
LWMPOINT * lwmpoint_from_lwgeom(const LWGEOM *g)
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
void expand_box3d(BOX3D *box, double d)
Expand given box of 'd' units in all directions.
void lwgeom_add_bbox_deep(LWGEOM *lwgeom, GBOX *gbox)
Compute a box for geom and all sub-geometries, if not already computed.
int lwpointiterator_has_next(LWPOINTITERATOR *s)
Returns LW_TRUE if there is another point available in the iterator.
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
double lwgeom_length_spheroid(const LWGEOM *geom, const SPHEROID *s)
Calculate the geodetic length of a lwgeom on the unit sphere.
LWPOINT * lwmpoint_median(const LWMPOINT *g, double tol, uint32_t maxiter, char fail_if_not_converged)
LWGEOM * lwgeom_linemerge(const LWGEOM *geom1)
LWGEOM * lwgeom_furthest_line(const LWGEOM *lw1, const LWGEOM *lw2)
LWMPOINT * lwmpoint_construct_empty(int srid, char hasz, char hasm)
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
void printLWPOINT(LWPOINT *point)
LWLINE * lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points)
void * lwalloc(size_t size)
int lwgeom_dimensionality(const LWGEOM *geom)
Return the dimensionality (relating to point/line/poly) of an lwgeom.
uint8_t parse_hex(char *str)
Convert a single hex digit into the corresponding char.
LWPOINT * lwpoint_make3dz(int srid, double x, double y, double z)
int lwcompound_add_lwgeom(LWCOMPOUND *comp, LWGEOM *geom)
Add a component, allocating extra space if necessary.
int ptarray_is_closed_2d(const POINTARRAY *pa)
double lwgeom_maxdistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling max distance calculations and dfullywithin calculations.
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
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.
LWGEOM * lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1)
void error_if_srid_mismatch(int srid1, int srid2)
LWGEOM * lwtriangle_as_lwgeom(const LWTRIANGLE *obj)
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
LWGEOM * lwgeom_wrapx(const LWGEOM *lwgeom, double cutx, double amount)
wrap geometry on given cut x value
void lwpsurface_free(LWPSURFACE *psurf)
float next_float_up(double d)
LWMPOINT * lwmpoint_construct(int srid, const POINTARRAY *pa)
void lwpoly_free(LWPOLY *poly)
LWPOINT * lwgeom_median(const LWGEOM *g, double tol, uint32_t maxiter, char fail_if_not_converged)
double lwpoint_get_z(const LWPOINT *point)
void lwmline_free(LWMLINE *mline)
void lwpsurface_release(LWPSURFACE *lwpsurface)
int lwline_is_trajectory(const LWLINE *geom)
void printLWTRIANGLE(LWTRIANGLE *triangle)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
int getPoint3dm_p(const POINTARRAY *pa, uint32_t n, POINT3DM *point)
double lwgeom_maxdistance3d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing 3d max distance calculation.
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.
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...
LWMLINE * lwmline_measured_from_lwmline(const LWMLINE *lwmline, double m_start, double m_end)
Re-write the measure ordinate (or add one, if it isn't already there) interpolating the measure betwe...
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
double lwgeom_perimeter(const LWGEOM *geom)
char * lwgeom_to_geojson(const LWGEOM *geo, char *srs, int precision, int has_bbox)
Takes a GEOMETRY and returns a GeoJson representation.
LWPOLY * lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes)
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...
LWPOINT * lwpoint_construct_empty(int srid, char hasz, char hasm)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
int gbox_is_valid(const GBOX *gbox)
Return false if any of the dimensions is NaN or infinite.
LWCOMPOUND * lwcompound_construct_from_lwline(const LWLINE *lwpoly)
Construct an equivalent compound curve from a linestring.
double lwgeom_azumith_spheroid(const LWPOINT *r, const LWPOINT *s, const SPHEROID *spheroid)
Calculate the bearing between two points on a spheroid.
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
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...
LWCOMPOUND * lwcompound_construct_empty(int srid, char hasz, char hasm)
uint64_t gbox_get_sortable_hash(const GBOX *g)
Return a sortable key based on the center point of the GBOX.
LWGEOM * lwgeom_force_3dz(const LWGEOM *geom)
int lwgeom_is_clockwise(LWGEOM *lwgeom)
Ensure the outer ring is clockwise oriented and all inner rings are counter-clockwise.
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
LWLINE * lwline_removepoint(LWLINE *line, uint32_t which)
POINTARRAY * ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2)
Merge two given POINTARRAY and returns a pointer on the new aggregate one.
int lwpoint_getPoint2d_p(const LWPOINT *point, POINT2D *out)
LWPOINT * lwpoint_make(int srid, int hasz, int hasm, const POINT4D *p)
LWGEOM * lwgeom_construct_empty(uint8_t type, int srid, char hasz, char hasm)
LWPOINT * lwpoint_make4d(int srid, double x, double y, double z, double m)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
float next_float_down(double d)
void lwline_free(LWLINE *line)
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".
POINTARRAY * ptarray_flip_coordinates(POINTARRAY *pa)
Reverse X and Y axis on a given POINTARRAY.
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
LWGEOM * lwgeom_union(const LWGEOM *geom1, const LWGEOM *geom2)
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
LWMPOINT * lwmpoly_to_points(const LWMPOLY *mpoly, uint32_t npoints)
LWPOLY * lwpoly_construct_envelope(int srid, double x1, double y1, double x2, double y2)
LWTRIANGLE * lwtriangle_construct_empty(int srid, char hasz, char hasm)
char * lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision)
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.
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...
int lwgeom_has_arc(const LWGEOM *geom)
void lwmpoint_release(LWMPOINT *lwpoint)
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
LWLINE * lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
LWPOINT * lwcompound_get_endpoint(const LWCOMPOUND *lwcmp)
void lwtriangle_release(LWTRIANGLE *lwtriangle)
double lwpoint_get_y(const LWPOINT *point)
double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the sphere.
int * lwgeom_cluster_2d_kmeans(const LWGEOM **geoms, uint32_t ngeoms, uint32_t k)
Take a list of LWGEOMs and a number of clusters and return an integer array indicating which cluster ...
void printLWPSURFACE(LWPSURFACE *psurf)
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
LWGEOM * lwgeom_closest_line_3d(const LWGEOM *lw1, const LWGEOM *lw2)
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, uint32_t where)
Add a LWPOINT to an LWLINE.
int getPoint2d_p_ro(const POINTARRAY *pa, uint32_t n, POINT2D **point)
New function to read doubles directly from the double* coordinate array of an aligned lwgeom POINTARR...
void lwgeom_drop_srid(LWGEOM *lwgeom)
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
lwinterrupt_callback * lwgeom_register_interrupt_callback(lwinterrupt_callback *)
void lwgeom_reverse_in_place(LWGEOM *lwgeom)
Reverse vertex order of LWGEOM.
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)
double lwgeom_mindistance3d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing 3d min distance calculation.
int lwgeom_cpa_within(const LWGEOM *g1, const LWGEOM *g2, double maxdist)
Is the closest point of approach within a distance ?
int gbox_merge(const GBOX *new_box, GBOX *merged_box)
Update the merged GBOX to be large enough to include itself and the new box.
enum LWORD_T LWORD
Ordinate names.
LWCOMPOUND * lwgeom_as_lwcompound(const LWGEOM *lwgeom)
LWPOINT * lwline_get_lwpoint(const LWLINE *line, uint32_t where)
Returns freshly allocated LWPOINT that corresponds to the index where.
Datum distance(PG_FUNCTION_ARGS)
Datum area(PG_FUNCTION_ARGS)
uint8_t * serialized_pointlist
uint8_t * serialized_lwgeom
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.
uint8_t * serialized_lwgeom