30 #define _LIBLWGEOM_H 1
36 #include "../postgis_config.h"
38 #if POSTGIS_PROJ_VERSION < 60
69 #if POSTGIS_PROJ_VERSION < 49
96 #define LIBLWGEOM_VERSION "3.0.12dev"
97 #define LIBLWGEOM_VERSION_MAJOR "3"
98 #define LIBLWGEOM_VERSION_MINOR "0"
99 #define LIBLWGEOM_GEOS_VERSION "38"
118 #define POLYGONTYPE 3
119 #define MULTIPOINTTYPE 4
120 #define MULTILINETYPE 5
121 #define MULTIPOLYGONTYPE 6
122 #define COLLECTIONTYPE 7
123 #define CIRCSTRINGTYPE 8
124 #define COMPOUNDTYPE 9
125 #define CURVEPOLYTYPE 10
126 #define MULTICURVETYPE 11
127 #define MULTISURFACETYPE 12
128 #define POLYHEDRALSURFACETYPE 13
129 #define TRIANGLETYPE 14
138 #define WKBZOFFSET 0x80000000
139 #define WKBMOFFSET 0x40000000
140 #define WKBSRIDFLAG 0x20000000
141 #define WKBBBOXFLAG 0x10000000
159 #define WGS84_MAJOR_AXIS 6378137.0
160 #define WGS84_INVERSE_FLATTENING 298.257223563
161 #define WGS84_MINOR_AXIS (WGS84_MAJOR_AXIS - WGS84_MAJOR_AXIS / WGS84_INVERSE_FLATTENING)
162 #define WGS84_RADIUS ((2.0 * WGS84_MAJOR_AXIS + WGS84_MINOR_AXIS ) / 3.0)
163 #define WGS84_SRID 4326
172 #define LWFLAG_Z 0x01
173 #define LWFLAG_M 0x02
174 #define LWFLAG_BBOX 0x04
175 #define LWFLAG_GEODETIC 0x08
176 #define LWFLAG_READONLY 0x10
177 #define LWFLAG_SOLID 0x20
179 #define FLAGS_GET_Z(flags) ((flags) & LWFLAG_Z)
180 #define FLAGS_GET_M(flags) (((flags) & LWFLAG_M)>>1)
181 #define FLAGS_GET_BBOX(flags) (((flags) & LWFLAG_BBOX)>>2)
182 #define FLAGS_GET_GEODETIC(flags) (((flags) & LWFLAG_GEODETIC)>>3)
183 #define FLAGS_GET_READONLY(flags) (((flags) & LWFLAG_READONLY)>>4)
184 #define FLAGS_GET_SOLID(flags) (((flags) & LWFLAG_SOLID)>>5)
186 #define FLAGS_SET_Z(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_Z) : ((flags) & ~LWFLAG_Z))
187 #define FLAGS_SET_M(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_M) : ((flags) & ~LWFLAG_M))
188 #define FLAGS_SET_BBOX(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_BBOX) : ((flags) & ~LWFLAG_BBOX))
189 #define FLAGS_SET_GEODETIC(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_GEODETIC) : ((flags) & ~LWFLAG_GEODETIC))
190 #define FLAGS_SET_READONLY(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_READONLY) : ((flags) & ~LWFLAG_READONLY))
191 #define FLAGS_SET_SOLID(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_SOLID) : ((flags) & ~LWFLAG_SOLID))
193 #define FLAGS_NDIMS(flags) (2 + FLAGS_GET_Z(flags) + FLAGS_GET_M(flags))
194 #define FLAGS_GET_ZM(flags) (FLAGS_GET_M(flags) + FLAGS_GET_Z(flags) * 2)
195 #define FLAGS_NDIMS_BOX(flags) (FLAGS_GET_GEODETIC(flags) ? 3 : FLAGS_NDIMS(flags))
206 #define TYPMOD_GET_SRID(typmod) ((((typmod) & 0x0FFFFF00) - ((typmod) & 0x10000000)) >> 8)
207 #define TYPMOD_SET_SRID(typmod, srid) ((typmod) = (((typmod) & 0xE00000FF) | ((srid & 0x001FFFFF)<<8)))
208 #define TYPMOD_GET_TYPE(typmod) ((typmod & 0x000000FC)>>2)
209 #define TYPMOD_SET_TYPE(typmod, type) ((typmod) = (typmod & 0xFFFFFF03) | ((type & 0x0000003F)<<2))
210 #define TYPMOD_GET_Z(typmod) ((typmod & 0x00000002)>>1)
211 #define TYPMOD_SET_Z(typmod) ((typmod) = typmod | 0x00000002)
212 #define TYPMOD_GET_M(typmod) (typmod & 0x00000001)
213 #define TYPMOD_SET_M(typmod) ((typmod) = typmod | 0x00000001)
214 #define TYPMOD_GET_NDIMS(typmod) (2+TYPMOD_GET_Z(typmod)+TYPMOD_GET_M(typmod))
220 #define SRID_MAXIMUM 999999
226 #define SRID_USER_MAXIMUM 998999
229 #define SRID_UNKNOWN 0
230 #define SRID_IS_UNKNOWN(x) ((int)x<=0)
233 #define SRID_INVALID (999999 + 2)
239 #define SRID_DEFAULT 4326
242 # define __attribute__(x)
256 typedef void* (*lwallocator)(
size_t size);
257 typedef void* (*lwreallocator)(
void *mem,
size_t size);
318 double afac, bfac, cfac, dfac, efac, ffac, gfac, hfac, ifac, xoff, yoff, zoff;
1648 #define LW_GML_IS_DIMS (1<<0)
1650 #define LW_GML_IS_DEGREE (1<<1)
1652 #define LW_GML_SHORTLINE (1<<2)
1654 #define LW_GML_EXTENT (1<<4)
1657 #define IS_DIMS(x) ((x) & LW_GML_IS_DIMS)
1658 #define IS_DEGREE(x) ((x) & LW_GML_IS_DEGREE)
1666 #define LW_X3D_FLIP_XY (1<<0)
1667 #define LW_X3D_USE_GEOCOORDS (1<<1)
1668 #define X3D_USE_GEOCOORDS(x) ((x) & LW_X3D_USE_GEOCOORDS)
2055 #define LW_PARSER_CHECK_MINPOINTS 1
2056 #define LW_PARSER_CHECK_ODD 2
2057 #define LW_PARSER_CHECK_CLOSURE 4
2058 #define LW_PARSER_CHECK_ZCLOSURE 8
2060 #define LW_PARSER_CHECK_NONE 0
2061 #define LW_PARSER_CHECK_ALL (LW_PARSER_CHECK_MINPOINTS | LW_PARSER_CHECK_ODD | LW_PARSER_CHECK_CLOSURE)
2083 #define PARSER_ERROR_MOREPOINTS 1
2084 #define PARSER_ERROR_ODDPOINTS 2
2085 #define PARSER_ERROR_UNCLOSED 3
2086 #define PARSER_ERROR_MIXDIMS 4
2087 #define PARSER_ERROR_INVALIDGEOM 5
2088 #define PARSER_ERROR_INVALIDWKBTYPE 6
2089 #define PARSER_ERROR_INCONTINUOUS 7
2090 #define PARSER_ERROR_TRIANGLEPOINTS 8
2091 #define PARSER_ERROR_LESSPOINTS 9
2092 #define PARSER_ERROR_OTHER 10
2112 #define UNPARSER_ERROR_MOREPOINTS 1
2113 #define UNPARSER_ERROR_ODDPOINTS 2
2114 #define UNPARSER_ERROR_UNCLOSED 3
2121 #define WKB_ISO 0x01
2122 #define WKB_SFSQL 0x02
2123 #define WKB_EXTENDED 0x04
2124 #define WKB_NDR 0x08
2125 #define WKB_XDR 0x10
2126 #define WKB_HEX 0x20
2127 #define WKB_NO_NPOINTS 0x40
2128 #define WKB_NO_SRID 0x80
2130 #define WKT_ISO 0x01
2131 #define WKT_SFSQL 0x02
2132 #define WKT_EXTENDED 0x04
2138 #define TWKB_BBOX 0x01
2139 #define TWKB_SIZE 0x02
2140 #define TWKB_ID 0x04
2141 #define TWKB_NO_TYPE 0x10
2142 #define TWKB_NO_ID 0x20
2143 #define TWKB_DEFAULT_PRECISION 0
2205 extern void *
lwalloc(
size_t size);
2206 extern void *
lwrealloc(
void *mem,
size_t size);
2207 extern void lwfree(
void *mem);
2210 extern char *
lwmessage_truncate(
char *
str,
int startpos,
int endpos,
int maxlength,
int truncdirection);
2227 extern uint8_t*
lwgeom_to_twkb(
const LWGEOM *geom, uint8_t
variant, int8_t precision_xy, int8_t precision_z, int8_t precision_m,
size_t *twkb_size);
2388 #if POSTGIS_PROJ_VERSION < 60
2394 projPJ projpj_from_string(
const char* txt);
2405 #if POSTGIS_PROJ_VERSION >= 60
LWPOINT * lwpoint_construct_empty(int32_t srid, char hasz, char hasm)
void deparse_hex(uint8_t str, char *result)
Convert a char into a human readable hex digit.
LWPOLY * lwpoly_construct_circle(int32_t srid, double x, double y, double radius, uint32_t segments_per_quarter, char exterior)
int lwgeom_is_closed(const LWGEOM *geom)
Return true or false depending on whether a geometry is a linear feature that closes on itself.
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 * lwline_interpolate_point_3d(const LWLINE *line, double distance)
Interpolate one point along a line in 3D.
LWPOINT * lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, uint32_t where)
LWCURVEPOLY * lwcurvepoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, LWGEOM **geoms)
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
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.
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)
Simplification.
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.
size_t gbox_serialized_size(lwflags_t flags)
Return the number of bytes necessary to hold a GBOX of this dimension in serialized form.
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.
LWPOINT * lwpoint_make4d(int32_t srid, double x, double y, double z, double m)
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)
int lwgeom_simplify_in_place(LWGEOM *igeom, double dist, int preserve_collapsed)
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)
LWPOINT * lwpoint_make2d(int32_t srid, double x, double y)
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)
int ptarray_transform(POINTARRAY *pa, LWPROJ *pj)
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
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)
LWLINE * lwline_from_ptarray(int32_t srid, uint32_t npoints, LWPOINT **points)
void lwpoint_free(LWPOINT *pt)
void lwgeom_longitude_shift(LWGEOM *lwgeom)
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.
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)
int lwgeom_transform(LWGEOM *geom, LWPROJ *pj)
Transform (reproject) a geometry in-place.
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)
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)
LWPOINT * lwpoint_make3dm(int32_t srid, double x, double y, double m)
uint32_t gserialized_get_version(const GSERIALIZED *g)
Return the serialization version.
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)
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...
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 lwpoint_getPoint3dm_p(const LWPOINT *point, POINT3DM *out)
void printLWPOLY(LWPOLY *poly)
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.
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_peek_first_point(const GSERIALIZED *g, POINT4D *out_point)
Pull the first point values of a GSERIALIZED.
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
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.
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)
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)
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.
GBOX * gbox_new(lwflags_t flags)
Create a new gbox with the dimensionality indicated by the flags.
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.
int gbox_overlaps_2d(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the GBOX overlaps on the 2d plane, LW_FALSE otherwise.
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)
int lwgeom_remove_repeated_points_in_place(LWGEOM *in, double tolerance)
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)
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)
const float * gserialized_get_float_box_p(const GSERIALIZED *g, size_t *ndims)
Access to the float bounding box, if there is one.
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).
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
LWMLINE * lwmline_construct_empty(int32_t srid, char hasz, char hasm)
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *box)
Pull a GBOX from the header of a GSERIALIZED, if one is available.
LWGEOM * lwgeom_reverse(const LWGEOM *lwgeom)
LWMPOINT * lwpoly_to_points(const LWPOLY *poly, uint32_t npoints, int32_t seed)
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)
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.
int lwgeom_isfinite(const LWGEOM *lwgeom)
Check if a LWGEOM has any non-finite (NaN or Inf) coordinates.
LWPOINT * lwcompound_get_startpoint(const LWCOMPOUND *lwcmp)
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
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_construct_empty(int32_t srid, char hasz, char hasm)
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)
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)
LWTRIANGLE * lwgeom_as_lwtriangle(const LWGEOM *lwgeom)
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)
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.
LWPOLY * lwpoly_construct_envelope(int32_t srid, double x1, double y1, double x2, double y2)
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)
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)
int lwpoint_getPoint3dz_p(const LWPOINT *point, POINT3DZ *out)
uint64_t gbox_get_sortable_hash(const GBOX *g, const int32_t srid)
Return a sortable key based on the center point of the GBOX.
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.
LWGEOM * lwgeom_unaryunion(const LWGEOM *geom1)
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.
LWPOINT * lwpoint_make3dz(int32_t srid, double x, double y, double z)
void lwcircstring_free(LWCIRCSTRING *curve)
LWMPOINT * lwmpoint_construct_empty(int32_t srid, char hasz, char hasm)
uint64_t gserialized_get_sortable_hash(const GSERIALIZED *g)
Return a sortable key based on gserialized.
double lwgeom_mindistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling 3d min distance calculations and dwithin calculations.
int gserialized_fast_gbox_p(const GSERIALIZED *g, GBOX *box)
Pull a GBOX from the header of a GSERIALIZED, if one is available.
void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2)
Swap ordinate values in every vertex of the geometry.
int lwgeom_transform_from_str(LWGEOM *geom, const char *instr, const char *outstr)
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.
LWMPOINT * lwmpoly_to_points(const LWMPOLY *mpoly, uint32_t npoints, int32_t seed)
LWGEOM * lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2)
uint8_t lwtype_multitype(uint8_t type)
LWPOINT * lwpoint_construct(int32_t srid, GBOX *bbox, POINTARRAY *point)
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,...
LWPROJ * lwproj_from_PJ(PJ *pj, int8_t extra_geography_data)
Allocate a new LWPROJ containing the reference to the PROJ's PJ If extra_geography_data is true,...
GSERIALIZED * gserialized_set_gbox(GSERIALIZED *g, GBOX *gbox)
Copy a new bounding box into an existing gserialized.
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.
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
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)
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)
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)
int lwgeom_is_solid(const LWGEOM *geom)
Return LW_TRUE if geometry has SOLID flag.
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 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)
LWLINE * lwline_from_lwmpoint(int32_t srid, const LWMPOINT *mpoint)
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)
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
GSERIALIZED * gserialized_drop_gbox(GSERIALIZED *g)
Remove the bounding box from a GSERIALIZED.
void lwcircstring_release(LWCIRCSTRING *lwcirc)
LWGEOM * lwgeom_set_effective_area(const LWGEOM *igeom, int set_area, double area)
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)
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)
void printLWPOINT(LWPOINT *point)
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.
LWCOMPOUND * lwcompound_construct_empty(int32_t srid, char hasz, char hasm)
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
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)
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)
void lwpoly_free(LWPOLY *poly)
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
LWPOINT * lwgeom_median(const LWGEOM *g, double tol, uint32_t maxiter, char fail_if_not_converged)
LWMPOINT * lwgeom_to_points(const LWGEOM *lwgeom, uint32_t npoints, int32_t seed)
double lwpoint_get_z(const LWPOINT *point)
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...
LWCURVEPOLY * lwcurvepoly_construct_empty(int32_t srid, char hasz, char hasm)
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...
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.
struct gridspec_t gridspec
Snap-to-grid.
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.
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
lwflags_t gserialized_get_lwflags(const GSERIALIZED *g)
Read standard lwflags from gserialized.
LWGEOM * lwgeom_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
LWGEOM * lwgeom_force_3dz(const LWGEOM *geom)
LWGEOM * lwgeom_grid(const LWGEOM *lwgeom, const gridspec *grid)
int lwgeom_is_clockwise(LWGEOM *lwgeom)
Ensure the outer ring is clockwise oriented and all inner rings are counter-clockwise.
LWCIRCSTRING * lwcircstring_construct_empty(int32_t srid, char hasz, char hasm)
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
LWLINE * lwline_removepoint(LWLINE *line, uint32_t which)
LWMPOINT * lwmpoint_construct(int32_t srid, const POINTARRAY *pa)
int32_t gserialized_hash(const GSERIALIZED *g)
Returns a hash code for the srid/type/geometry information in the GSERIALIZED.
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)
LWMPOLY * lwmpoly_construct_empty(int32_t srid, char hasz, char hasm)
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".
LWCIRCSTRING * lwcircstring_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
POINTARRAY * ptarray_flip_coordinates(POINTARRAY *pa)
Reverse X and Y axis on a given POINTARRAY.
LWGEOM * lwgeom_union(const LWGEOM *geom1, const LWGEOM *geom2)
LWLINE * lwline_construct_empty(int32_t srid, char hasz, char hasm)
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
LWTRIANGLE * lwtriangle_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
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.
LWLINE * lwline_from_lwgeom_array(int32_t srid, uint32_t ngeoms, LWGEOM **geoms)
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)
int32_t clamp_srid(int32_t srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...
void lwmpoint_release(LWMPOINT *lwpoint)
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
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)
void lwgeom_grid_in_place(LWGEOM *lwgeom, const gridspec *grid)
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.
LWPOINT * lwpoint_make(int32_t srid, int hasz, int hasm, const POINT4D *p)
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.
static double distance(double x1, double y1, double x2, double y2)
uint8_t source_is_latlong
double source_semi_major_metre
double source_semi_minor_metre
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