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.4.9dev" 66 #define LIBLWGEOM_VERSION_MAJOR "2" 67 #define LIBLWGEOM_VERSION_MINOR "4" 68 #define LIBLWGEOM_GEOS_VERSION "37" 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) 195 #define SRID_DEFAULT 4326 198 # define __attribute__(x) 215 typedef void* (*lwallocator)(
size_t size);
216 typedef void* (*lwreallocator)(
void *mem,
size_t size);
270 double afac, bfac, cfac, dfac, efac, ffac, gfac, hfac, ifac, xoff, yoff,
zoff;
1535 #define LW_GML_IS_DIMS (1<<0) 1537 #define LW_GML_IS_DEGREE (1<<1) 1539 #define LW_GML_SHORTLINE (1<<2) 1541 #define LW_GML_EXTENT (1<<4) 1544 #define IS_DIMS(x) ((x) & LW_GML_IS_DIMS) 1545 #define IS_DEGREE(x) ((x) & LW_GML_IS_DEGREE) 1553 #define LW_X3D_FLIP_XY (1<<0) 1554 #define LW_X3D_USE_GEOCOORDS (1<<1) 1555 #define X3D_USE_GEOCOORDS(x) ((x) & LW_X3D_USE_GEOCOORDS) 2008 #define LW_PARSER_CHECK_MINPOINTS 1 2009 #define LW_PARSER_CHECK_ODD 2 2010 #define LW_PARSER_CHECK_CLOSURE 4 2011 #define LW_PARSER_CHECK_ZCLOSURE 8 2013 #define LW_PARSER_CHECK_NONE 0 2014 #define LW_PARSER_CHECK_ALL (LW_PARSER_CHECK_MINPOINTS | LW_PARSER_CHECK_ODD | LW_PARSER_CHECK_CLOSURE) 2036 #define PARSER_ERROR_MOREPOINTS 1 2037 #define PARSER_ERROR_ODDPOINTS 2 2038 #define PARSER_ERROR_UNCLOSED 3 2039 #define PARSER_ERROR_MIXDIMS 4 2040 #define PARSER_ERROR_INVALIDGEOM 5 2041 #define PARSER_ERROR_INVALIDWKBTYPE 6 2042 #define PARSER_ERROR_INCONTINUOUS 7 2043 #define PARSER_ERROR_TRIANGLEPOINTS 8 2044 #define PARSER_ERROR_LESSPOINTS 9 2045 #define PARSER_ERROR_OTHER 10 2065 #define UNPARSER_ERROR_MOREPOINTS 1 2066 #define UNPARSER_ERROR_ODDPOINTS 2 2067 #define UNPARSER_ERROR_UNCLOSED 3 2074 #define WKB_ISO 0x01 2075 #define WKB_SFSQL 0x02 2076 #define WKB_EXTENDED 0x04 2077 #define WKB_NDR 0x08 2078 #define WKB_XDR 0x10 2079 #define WKB_HEX 0x20 2080 #define WKB_NO_NPOINTS 0x40 2081 #define WKB_NO_SRID 0x80 2083 #define WKT_ISO 0x01 2084 #define WKT_SFSQL 0x02 2085 #define WKT_EXTENDED 0x04 2091 #define TWKB_BBOX 0x01 2092 #define TWKB_SIZE 0x02 2093 #define TWKB_ID 0x04 2094 #define TWKB_NO_TYPE 0x10 2095 #define TWKB_NO_ID 0x20 2096 #define TWKB_DEFAULT_PRECISION 0 2160 extern void lwfree(
void *mem);
2163 extern char *
lwmessage_truncate(
char *str,
int startpos,
int endpos,
int maxlength,
int truncdirection);
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
LWCOMPOUND * lwcompound_construct_empty(int srid, char hasz, char hasm)
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
char * lwgeom_to_hexwkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
double lwgeom_mindistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling 3d min distance calculations and dwithin calculations.
int lwtriangle_is_clockwise(LWTRIANGLE *triangle)
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...
int clamp_srid(int srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...
LWGEOM * lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad)
LWGEOM * lwgeom_set_effective_area(const LWGEOM *igeom, int set_area, double area)
char * lwgeom_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
VERSION GML 2 takes a GEOMETRY and returns a GML2 representation.
int gbox_overlaps(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the GBOX overlaps, LW_FALSE otherwise.
size_t gserialized_from_lwgeom_size(const LWGEOM *geom)
Calculate required memory segment to contain a serialized form of the LWGEOM.
GBOX * gbox_from_string(const char *str)
Warning, do not use this function, it is very particular about inputs.
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(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
void lwgeom_add_bbox_deep(LWGEOM *lwgeom, GBOX *gbox)
Compute a box for geom and all sub-geometries, if not already computed.
LWTIN * lwtin_add_lwtriangle(LWTIN *mobj, const LWTRIANGLE *obj)
POINT2D getPoint2d(const POINTARRAY *pa, int n)
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
void printLWPSURFACE(LWPSURFACE *psurf)
int lwtype_get_collectiontype(uint8_t type)
Given an lwtype number, what homogeneous collection can hold it?
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 ...
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
uint8_t * serialized_pointlist
int lwgeom_has_srid(const LWGEOM *geom)
Return true or false depending on whether a geometry has a valid SRID set.
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_closest_point(const LWGEOM *lw1, const LWGEOM *lw2)
void lwmpoly_release(LWMPOLY *lwpoly)
uint8_t * bytes_from_hexbytes(const char *hexbuf, size_t hexsize)
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
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...
void lwtin_release(LWTIN *lwtin)
LWGEOM * lwgeom_sharedpaths(const LWGEOM *geom1, const LWGEOM *geom2)
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
double lwgeom_azumith_spheroid(const LWPOINT *r, const LWPOINT *s, const SPHEROID *spheroid)
Calculate the bearing between two points on a spheroid.
Tolerance expresses the maximum angle between the radii generating approximation line vertices...
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...
int gserialized_get_zm(const GSERIALIZED *gser)
Return a number indicating presence of Z and M coordinates.
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
char * lwgeom_to_x3d3(const LWGEOM *geom, char *srs, int precision, int opts, const char *defid)
int lwcollection_ngeoms(const LWCOLLECTION *col)
void lwmline_free(LWMLINE *mline)
LWLINE * lwline_segmentize2d(LWLINE *line, double dist)
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
LWTRIANGLE * lwtriangle_construct_empty(int srid, char hasz, char hasm)
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
double lwgeom_maxdistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling max distance calculations and dfyllywithin calculations.
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin calculations.
LWGEOM * lwgeom_force_4d(const LWGEOM *geom)
struct struct_lwgeom_unparser_result LWGEOM_UNPARSER_RESULT
uint8_t * serialized_lwgeom
int gbox_same_2d(const GBOX *g1, const GBOX *g2)
Check if 2 given GBOX are the same in x and y.
void lwgeom_cancel_interrupt(void)
Cancel any interruption request.
void deparse_hex(uint8_t str, char *result)
Convert a char into a human readable hex digit.
double lwgeom_mindistance3d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing 3d min distance calculation.
LWGEOM * lwcollection_getsubgeom(LWCOLLECTION *col, int gnum)
int lwline_crossing_direction(const LWLINE *l1, const LWLINE *l2)
Given two lines, characterize how (and if) they cross each other.
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
int ptarray_is_closed_3d(const POINTARRAY *pa)
void lwcircstring_free(LWCIRCSTRING *curve)
LWPSURFACE * lwpsurface_add_lwpoly(LWPSURFACE *mobj, const LWPOLY *obj)
char * lwgeom_to_svg(const LWGEOM *geom, int precision, int relative)
Takes a GEOMETRY and returns a SVG representation.
int lwgeom_covers_lwgeom_sphere(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
Calculate covers predicate for two lwgeoms on the sphere.
GSERIALIZED * gserialized_copy(const GSERIALIZED *g)
Return a copy of the input serialized geometry.
int lwgeom_startpoint(const LWGEOM *lwgeom, POINT4D *pt)
LWPOINT * lwpoint_make2d(int srid, double x, double y)
Datum area(PG_FUNCTION_ARGS)
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
LWGEOM * lwgeom_force_3dz(const LWGEOM *geom)
void lwtin_free(LWTIN *tin)
int lwpoint_getPoint2d_p(const LWPOINT *point, POINT2D *out)
LWLINE * lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points)
char * lwpoint_to_latlon(const LWPOINT *p, const char *format)
LWGEOM * lwcircstring_as_lwgeom(const LWCIRCSTRING *obj)
int lwgeom_check_geodetic(const LWGEOM *geom)
Check that coordinates of LWGEOM are all within the geodetic range (-180, -90, 180, 90)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
void lwpoint_free(LWPOINT *pt)
void lwgeom_free(LWGEOM *geom)
void ptarray_free(POINTARRAY *pa)
void printLWTIN(LWTIN *tin)
LWGEOM * lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1)
POINTARRAY * ptarray_substring(POINTARRAY *pa, double d1, double d2, double tolerance)
start location (distance from start / total distance) end location (distance from start / total dist...
LWGEOM * lwgeom_geos_noop(const LWGEOM *geom)
Convert an LWGEOM to a GEOS Geometry and convert back – for debug only.
LWMPOINT * lwmpoint_construct(int srid, const POINTARRAY *pa)
void lwpoint_release(LWPOINT *lwpoint)
LWGEOM * lwgeom_offsetcurve(const LWLINE *lwline, double size, int quadsegs, int joinStyle, double mitreLimit)
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)
int lwgeom_dimensionality(LWGEOM *geom)
Return the dimensionality (relating to point/line/poly) of an lwgeom.
void lwline_free(LWLINE *line)
LWGEOM * lwgeom_wrapx(const LWGEOM *lwgeom, double cutx, double amount)
wrap geometry on given cut x value
void() lwinterrupt_callback()
Install a callback to be called periodically during algorithm execution.
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 pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring)
LWLINE * lwline_addpoint(LWLINE *line, LWPOINT *point, uint32_t where)
void lwgeom_scale(LWGEOM *geom, const POINT4D *factors)
LWMPOLY * lwmpoly_construct_empty(int srid, char hasz, char hasm)
LWPOINT * lwcompound_get_startpoint(const LWCOMPOUND *lwcmp)
int ptarray_is_closed_z(const POINTARRAY *pa)
void lwgeom_swap_ordinates(LWGEOM *in, LWORD o1, LWORD o2)
Swap ordinate values in every vertex of the geometry.
LWGEOM * lwgeom_centroid(const LWGEOM *geom)
LWCURVEPOLY * lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom)
LWGEOM * lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
Create an LWGEOM object from an Encoded Polyline representation.
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
LWGEOM * lwmline_as_lwgeom(const LWMLINE *obj)
void lwtriangle_reverse(LWTRIANGLE *triangle)
int lwgeom_transform(LWGEOM *geom, projPJ inpj, projPJ outpj)
Transform (reproject) a geometry in-place.
int lwline_is_trajectory(const LWLINE *geom)
LWGEOM * lwgeom_closest_line_3d(const LWGEOM *lw1, const LWGEOM *lw2)
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.
LWMPOINT * lwmpoint_from_lwgeom(const LWGEOM *g)
void printBOX3D(BOX3D *b)
int lwpoint_inside_circle(const LWPOINT *p, double cx, double cy, double rad)
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int lwgeom_nudge_geodetic(LWGEOM *geom)
Gently move coordinates of LWGEOM if they are close enough into geodetic range.
LWPOINTITERATOR * lwpointiterator_create_rw(LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM* Supports modification of coordinates during iterat...
void lwtriangle_force_clockwise(LWTRIANGLE *triangle)
LWGEOM * lwgeom_furthest_point(const LWGEOM *lw1, const LWGEOM *lw2)
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
int gbox_contains_point3d(const GBOX *gbox, const POINT3D *pt)
Return true if the point is inside the gbox.
char * hexbytes_from_bytes(uint8_t *bytes, size_t size)
int getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *point)
int gbox_init_point3d(const POINT3D *p, GBOX *gbox)
Initialize a GBOX using the values of the point.
LW_LINEARIZE_TOLERANCE_TYPE
Semantic of the tolerance argument passed to lwcurve_linearize.
int gbox_merge_point3d(const POINT3D *p, GBOX *gbox)
Update the GBOX to be large enough to include itself and the new point.
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
float next_float_down(double d)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
void error_if_srid_mismatch(int srid1, int srid2)
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
Tolerance expresses the maximum distance between an arbitrary point on the curve and the closest poin...
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
LWPOINT * lwpoint_construct_empty(int srid, char hasz, char hasm)
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
void lwpoly_force_clockwise(LWPOLY *poly)
double lwgeom_length_spheroid(const LWGEOM *geom, const SPHEROID *s)
Calculate the geodetic length of a lwgeom on the unit sphere.
LWGEOM * lwgeom_furthest_line_3d(LWGEOM *lw1, LWGEOM *lw2)
void lwgeom_request_interrupt(void)
Request interruption of any running code.
LWGEOM * lwgeom_force_sfs(LWGEOM *geom, int version)
double distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
double lwgeom_length_2d(const LWGEOM *geom)
LWMLINE * lwmline_construct_empty(int srid, char hasz, char hasm)
int lwpoly_is_clockwise(LWPOLY *poly)
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Pull a GBOX from the header of a GSERIALIZED, if one is available.
int ptarray_is_closed_2d(const POINTARRAY *pa)
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
void interpolate_point4d(POINT4D *A, POINT4D *B, POINT4D *I, double F)
Find interpolation point I between point A and point B so that the len(AI) == len(AB)*F and I falls o...
uint8_t * serialized_lwgeom
void lwline_setPoint4d(LWLINE *line, uint32_t which, POINT4D *newpoint)
char * lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision)
POINT3DZ getPoint3dz(const POINTARRAY *pa, int n)
int lwgeom_ndims(const LWGEOM *geom)
Return the number of dimensions (2, 3, 4) in a geometry.
double lwgeom_interpolate_point(const LWGEOM *lwin, const LWPOINT *lwpt)
Find the measure value at the location on the line closest to the point.
void lwgeom_longitude_shift(LWGEOM *lwgeom)
LWGEOM * lwgeom_flip_coordinates(LWGEOM *in)
Reverse the X and Y coordinate order.
double distance3d_pt_seg(const POINT3D *p, const POINT3D *A, const POINT3D *B)
GBOX * box3d_to_gbox(const BOX3D *b3d)
double lwgeom_perimeter(const LWGEOM *geom)
void lwtriangle_release(LWTRIANGLE *lwtriangle)
LWMPOLY * lwgeom_as_lwmpoly(const LWGEOM *lwgeom)
int lwgeom_cpa_within(const LWGEOM *g1, const LWGEOM *g2, double maxdist)
Is the closest point of approach within a distance ?
double lwgeom_maxdistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling 3d max distance calculations and dfullywithin calculations.
POINTARRAY * ptarray_flip_coordinates(POINTARRAY *pa)
Reverse X and Y axis on a given POINTARRAY.
char lwcollection_same(const LWCOLLECTION *p1, const LWCOLLECTION *p2)
check for same geometry composition
LWGEOM * lwgeom_closest_point_3d(const LWGEOM *lw1, const LWGEOM *lw2)
float next_float_up(double d)
LWPOINT * lwpoint_make3dm(int srid, double x, double y, double m)
void lwmpoint_release(LWMPOINT *lwpoint)
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 lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
void(* lwfreeor)(void *mem)
void printLWPOLY(LWPOLY *poly)
int lwpointiterator_has_next(LWPOINTITERATOR *s)
Returns LW_TRUE if there is another point available in the iterator.
double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located)
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
LWTRIANGLE * lwtriangle_from_lwline(const LWLINE *shell)
int gbox_union(const GBOX *g1, const GBOX *g2, GBOX *gout)
Update the output GBOX to be large enough to include both inputs.
double lwpoint_get_x(const LWPOINT *point)
LWPOLY * lwpoly_construct_envelope(int srid, double x1, double y1, double x2, double y2)
void lwgeom_force_clockwise(LWGEOM *lwgeom)
Ensure the outer ring is clockwise oriented and all inner rings are counter-clockwise.
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
Utility function to get type number from string.
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.
LWBOUNDINGCIRCLE * lwgeom_calculate_mbc(const LWGEOM *g)
POINTARRAY * ptarray_addPoint(const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where)
Add a point in a pointarray.
void lwmpoly_free(LWMPOLY *mpoly)
void lwmpoint_free(LWMPOINT *mpt)
void expand_box3d(BOX3D *box, double d)
Expand given box of 'd' units in all directions.
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
LWGEOM * lwgeom_homogenize(const LWGEOM *geom)
void *(* lwallocator)(size_t size)
Global functions for memory/logging handlers.
void lwpoly_release(LWPOLY *lwpoly)
POINT4D getPoint4d(const POINTARRAY *pa, int n)
char lwcircstring_same(const LWCIRCSTRING *p1, const LWCIRCSTRING *p2)
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 ptarray_isccw(const POINTARRAY *pa)
uint8_t * lwgeom_to_wkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
Convert LWGEOM to a char* in WKB format.
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
LWCIRCSTRING * lwcircstring_construct_empty(int srid, char hasz, char hasm)
LWCURVEPOLY * lwcurvepoly_construct(int srid, GBOX *bbox, uint32_t nrings, LWGEOM **geoms)
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE, then a duplicate point will not be added.
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
LWGEOM * lwgeom_node(const LWGEOM *lwgeom_in)
projPJ lwproj_from_string(const char *txt)
Get a projection from a string representation.
char lwtriangle_same(const LWTRIANGLE *p1, const LWTRIANGLE *p2)
LWTIN * lwgeom_as_lwtin(const LWGEOM *lwgeom)
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
void lwcircstring_release(LWCIRCSTRING *lwcirc)
POINT3DM getPoint3dm(const POINTARRAY *pa, int n)
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
void lwpoly_free(LWPOLY *poly)
const char * lwgeom_version(void)
Return lwgeom version string (not to be freed)
int gserialized_is_geodetic(const GSERIALIZED *gser)
Check if a GSERIALIZED is a geography.
LWPOINT * lwpoint_clone(const LWPOINT *lwgeom)
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM...
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
LWLINE * lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint)
int lwpoint_getPoint3dz_p(const LWPOINT *point, POINT3DZ *out)
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
char * lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection)
int lwgeom_force_geodetic(LWGEOM *geom)
Force coordinates of LWGEOM into geodetic range (-180, -90, 180, 90)
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
LWGEOM * lwgeom_delaunay_triangulation(const LWGEOM *geom, double tolerance, int edgeOnly)
Take vertices of a geometry and build a delaunay triangulation on them.
LWGEOM * lwgeom_simplify(const LWGEOM *igeom, double dist, int preserve_collapsed)
LWPOINT * lwcompound_get_endpoint(const LWCOMPOUND *lwcmp)
void lwpsurface_release(LWPSURFACE *lwpsurface)
GBOX * gserialized_calculate_gbox_geocentric(const GSERIALIZED *g)
Calculate the geocentric bounding box directly from the serialized form of the geodetic coordinates...
LWGEOM * lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2)
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
int ptarray_point_size(const POINTARRAY *pa)
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.
char * lwgeom_to_geojson(const LWGEOM *geo, char *srs, int precision, int has_bbox)
Takes a GEOMETRY and returns a GeoJson representation.
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
LWMLINE * lwgeom_as_lwmline(const LWGEOM *lwgeom)
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
int ptarray_append_ptarray(POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance)
Append a POINTARRAY, pa2 to the end of an existing POINTARRAY, pa1.
LWPOINT * lwpoint_make(int srid, int hasz, int hasm, const POINT4D *p)
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
LWGEOM * lwcompound_as_lwgeom(const LWCOMPOUND *obj)
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.
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
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 ...
LWPOINT * lwpoint_make3dz(int srid, double x, double y, double z)
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
double lwgeom_maxdistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initialazing max distance calculation.
LWGEOM * lwgeom_difference(const LWGEOM *geom1, const LWGEOM *geom2)
LWCURVEPOLY * lwcurvepoly_construct_empty(int srid, char hasz, char hasm)
size_t gbox_serialized_size(uint8_t flags)
Return the number of bytes necessary to hold a GBOX of this dimension in serialized form...
LWCOMPOUND * lwgeom_as_lwcompound(const LWGEOM *lwgeom)
LWMPOINT * lwmpoint_construct_empty(int srid, char hasz, char hasm)
void gbox_expand(GBOX *g, double d)
Move the box minimums down and the maximums up by the distance provided.
int lwgeom_has_arc(const LWGEOM *geom)
LWGEOM * lwgeom_furthest_line(const LWGEOM *lw1, const LWGEOM *lw2)
void printLWLINE(LWLINE *line)
LWGEOM * lwtriangle_as_lwgeom(const LWTRIANGLE *obj)
enum LWORD_T LWORD
Ordinate names.
LWGEOM * lwgeom_normalize(const LWGEOM *geom)
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where)
Insert a point into an existing POINTARRAY.
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
void(* lwreporter)(const char *fmt, va_list ap) __attribute__((format(printf
LWGEOM * lwgeom_construct_empty(uint8_t type, int srid, char hasz, char hasm)
LWCOLLECTION * lwgeom_clip_to_ordinate_range(const LWGEOM *lwin, char ordinate, double from, double to, double offset)
Given a geometry clip based on the from/to range of one of its ordinates (x, y, z, m).
char * lwgeom_extent_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
LWCOMPOUND * lwcompound_construct_from_lwline(const LWLINE *lwpoly)
Construct an equivalent compound curve from a linestring.
int point4d_transform(POINT4D *pt, projPJ srcpj, projPJ dstpj)
LWMLINE * lwmline_measured_from_lwmline(const LWMLINE *lwmline, double m_start, double m_end)
Re-write the measure ordinate (or add one, if it isn't already there) interpolating the measure betwe...
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Datum distance(PG_FUNCTION_ARGS)
BOX3D * box3d_from_gbox(const GBOX *gbox)
double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the sphere.
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWCIRCSTRING * lwcircstring_construct(int srid, GBOX *bbox, POINTARRAY *points)
LWCOLLECTION * lwgeom_subdivide(const LWGEOM *geom, int maxvertices)
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
char * gserialized_to_string(const GSERIALIZED *g)
Return a WKT representation of the gserialized geometry.
void lwtriangle_free(LWTRIANGLE *triangle)
LWCOLLECTION * lwcollection_segmentize2d(LWCOLLECTION *coll, double dist)
void *(* lwreallocator)(void *mem, size_t size)
void lwpsurface_free(LWPSURFACE *psurf)
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"...
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
unsigned int geohash_point_as_int(POINT2D *pt)
int lwgeom_count_rings(const LWGEOM *geom)
Count the total number of rings in any LWGEOM.
double lwgeom_tcpa(const LWGEOM *g1, const LWGEOM *g2, double *mindist)
Find the time of closest point of approach.
LWPOINT * lwmpoint_median(const LWMPOINT *g, double tol, uint32_t maxiter, char fail_if_not_converged)
LWGEOM * lwgeom_locate_along(const LWGEOM *lwin, double m, double offset)
Determine the location(s) along a measured line where m occurs and return as a multipoint.
int gbox_merge(const GBOX *new_box, GBOX *merged_box)
Update the merged GBOX to be large enough to include itself and the new box.
LWGEOM * lwgeom_snap(const LWGEOM *geom1, const LWGEOM *geom2, double tolerance)
Snap vertices and segments of a geometry to another using a given tolerance.
Symmetric linearization means that the output vertices would be the same no matter the order of the p...
void lwcollection_release(LWCOLLECTION *lwcollection)
GBOX * gbox_copy(const GBOX *gbox)
Return a copy of the GBOX, based on dimensionality of flags.
uint8_t parse_hex(char *str)
Convert a single hex digit into the corresponding char.
char * lwgeom_extent_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix)
void lwpoly_reverse(LWPOLY *poly)
double ptarray_length(const POINTARRAY *pts)
Find the 3d/2d length of the given POINTARRAY (depending on its dimensionality)
int ptarray_calculate_gbox_geodetic(const POINTARRAY *pa, GBOX *gbox)
Calculate geodetic (x/y/z) box and add values to gbox.
char lwtriangle_is_repeated_points(LWTRIANGLE *triangle)
double lwgeom_perimeter_2d(const LWGEOM *geom)
void lwgeom_reverse(LWGEOM *lwgeom)
Reverse vertex order of LWGEOM.
LWTRIANGLE * lwgeom_as_lwtriangle(const LWGEOM *lwgeom)
LWPOLY * lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes)
LWLINE * lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
double lwpoint_get_m(const LWPOINT *point)
Tolerance expresses the number of segments to use for each quarter of circle (quadrant).
void lwline_reverse(LWLINE *line)
int gbox_is_valid(const GBOX *gbox)
Return false if any of the dimensions is NaN or infinite.
char * lwgeom_geohash(const LWGEOM *lwgeom, int precision)
Calculate the GeoHash (http://geohash.org) string for a geometry.
int getPoint2d_p_ro(const POINTARRAY *pa, int n, POINT2D **point)
New function to read doubles directly from the double* coordinate array of an aligned lwgeom POINTARR...
lwinterrupt_callback * lwgeom_register_interrupt_callback(lwinterrupt_callback *)
const POINT3DZ * getPoint3dz_cp(const POINTARRAY *pa, int n)
Returns a POINT3DZ pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
void printPA(POINTARRAY *pa)
void ptarray_longitude_shift(POINTARRAY *pa)
Longitude shift for a pointarray.
LWGEOM * lwgeom_buildarea(const LWGEOM *geom)
Take a geometry and return an areal geometry (Polygon or MultiPolygon).
const char * lwgeom_geos_version(void)
Return GEOS version string (not to be freed)
void lwgeom_drop_srid(LWGEOM *lwgeom)
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...
LWPOINT * lwpoint_make4d(int srid, double x, double y, double z, double m)
int lwpoint_getPoint3dm_p(const LWPOINT *point, POINT3DM *out)
char ptarray_same(const POINTARRAY *pa1, const POINTARRAY *pa2)
LWGEOM * lwpsurface_as_lwgeom(const LWPSURFACE *obj)
LWMPOINT * lwmpoly_to_points(const LWMPOLY *mpoly, int npoints)
LWGEOM * lwgeom_unaryunion(const LWGEOM *geom1)
LWMPOINT * lwpoly_to_points(const LWPOLY *poly, int npoints)
int ptarray_remove_point(POINTARRAY *pa, int where)
Remove a point from an existing POINTARRAY.
void(*) typedef void(* lwdebuglogger)(int level, const char *fmt, va_list ap) __attribute__((format(printf
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
LWGEOM * lwgeom_from_twkb(uint8_t *twkb, size_t twkb_size, char check)
WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory...
double lwgeom_area(const LWGEOM *geom)
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...
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...
double distance3d_pt_pt(const POINT3D *p1, const POINT3D *p2)
int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the 2-4D bounding box of a geometry.
void gbox_duplicate(const GBOX *original, GBOX *duplicate)
Copy the values of original GBOX into duplicate.
int lwgeom_is_simple(const LWGEOM *lwgeom)
void gserialized_set_srid(GSERIALIZED *g, int32_t srid)
Write the SRID into the serialized form (it is packed into three bytes so this is a handy function)...
LWGEOM * lwgeom_symdifference(const LWGEOM *geom1, const LWGEOM *geom2)
void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result)
void(*) typedef void(*) voi lwgeom_set_handlers)(lwallocator allocator, lwreallocator reallocator, lwfreeor freeor, lwreporter errorreporter, lwreporter noticereporter)
Install custom memory management and error handling functions you want your application to use...
LWMPOINT * lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
double ptarray_arc_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY, using circular arc interpolation between each coordinate ...
double lwgeom_length(const LWGEOM *geom)
void * lwrealloc(void *mem, size_t size)
LWGEOM * lwgeom_segmentize2d(LWGEOM *line, double dist)
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
void printLWPOINT(LWPOINT *point)
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initialazing min distance calculation.
LWMPOINT * lwgeom_to_points(const LWGEOM *lwgeom, int npoints)
const POINT4D * getPoint4d_cp(const POINTARRAY *pa, int n)
Returns a POINT4D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
void ptarray_reverse(POINTARRAY *pa)
LWPSURFACE * lwgeom_as_lwpsurface(const LWGEOM *lwgeom)
Retain angle instructs the engine to try its best to retain the requested angle between generating ra...
int ptarray_calculate_gbox_cartesian(const POINTARRAY *pa, GBOX *gbox)
Calculate box (x/y) and add values to gbox.
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
uint64_t gbox_get_sortable_hash(const GBOX *g)
Return a sortable key based on the center point of the GBOX.
LWPOINT * lwline_get_lwpoint(const LWLINE *line, int where)
Returns freshly allocated LWPOINT that corresponds to the index where.
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
int gbox_pt_outside(const GBOX *gbox, POINT2D *pt_outside)
Calculate a spherical point that falls outside the geocentric gbox.
int gserialized_ndims(const GSERIALIZED *gser)
Return the number of dimensions (2, 3, 4) in a geometry.
int lwcurvepoly_add_ring(LWCURVEPOLY *poly, LWGEOM *ring)
Add a ring, allocating extra space if necessary.
double lwpoint_get_y(const LWPOINT *point)
void lwcollection_free(LWCOLLECTION *col)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
void lwgeom_set_debuglogger(lwdebuglogger debuglogger)
LWGEOM * lwtin_as_lwgeom(const LWTIN *obj)
struct struct_lwgeom_parser_result LWGEOM_PARSER_RESULT
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM...
LWPOLY * lwpoly_construct_circle(int srid, double x, double y, double radius, uint32_t segments_per_quarter, char exterior)
void lwgeom_set_srid(LWGEOM *geom, int srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
LWGEOM * lwgeom_force_3dm(const LWGEOM *geom)
double lwgeom_area_spheroid(const LWGEOM *lwgeom, const SPHEROID *spheroid)
Calculate the geodetic area of a lwgeom on the spheroid.
CG_LINE_CROSS_TYPE
The return values of lwline_crossing_direction()
LWGEOM * lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance)
Remove repeated points!
double lwgeom_maxdistance3d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing 3d max distance calculation.
LWGEOM * lwcurvepoly_as_lwgeom(const LWCURVEPOLY *obj)
LWGEOM * lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2)
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
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.
double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
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...
LWGEOM * lwgeom_as_curve(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate CURVE* type.
LWPOLY * lwpoly_segmentize2d(LWPOLY *line, double dist)
int lwgeom_is_clockwise(LWGEOM *lwgeom)
Check clockwise orientation on LWGEOM polygons.
LWGEOM * lwgeom_union(const LWGEOM *geom1, const LWGEOM *geom2)
LWPOINT * lwgeom_median(const LWGEOM *g, double tol, uint32_t maxiter, char fail_if_not_converged)
POINTARRAY * ptarray_removePoint(POINTARRAY *pa, uint32_t where)
Remove a point from a pointarray.
char * lwgeom_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix, const char *id)
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
void * lwalloc(size_t size)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
void lwmline_release(LWMLINE *lwline)
int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, int where)
Add a LWPOINT to an LWLINE.
int lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
LWGEOM * lwgeom_unstroke(const LWGEOM *geom)
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 * lwcompound_get_lwpoint(const LWCOMPOUND *lwcmp, int where)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
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.
double distance2d_sqr_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
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...
int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret)
Compute the azimuth of segment AB in radians.
LWGEOM * lwcurve_linearize(const LWGEOM *geom, double tol, LW_LINEARIZE_TOLERANCE_TYPE type, int flags)
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)
LWLINE * lwline_removepoint(LWLINE *line, uint32_t which)
void lwline_release(LWLINE *lwline)
GBOX * gbox_new(uint8_t flags)
Create a new gbox with the dimensionality indicated by the flags.
char * lwgeom_summary(const LWGEOM *lwgeom, int offset)
char lwpoly_same(const LWPOLY *p1, const LWPOLY *p2)
int ptarray_transform(POINTARRAY *geom, projPJ inpj, projPJ outpj)
Transform given POINTARRAY from inpj projection to outpj projection.
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)
char lwline_same(const LWLINE *p1, const LWLINE *p2)
LWMPOLY * lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj)
int lwpointiterator_peek(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assigns the next point in the iterator to p.
double lwpoint_get_z(const LWPOINT *point)
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...
void lwboundingcircle_destroy(LWBOUNDINGCIRCLE *c)
LWPOINT * lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, int where)
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
LWPOLY * lwpoly_construct_rectangle(char hasz, char hasm, POINT4D *p1, POINT4D *p2, POINT4D *p3, POINT4D *p4)
int lwcompound_add_lwgeom(LWCOMPOUND *comp, LWGEOM *geom)
Add a component, allocating extra space if necessary.
int ptarray_is_closed(const POINTARRAY *pa)
Check for ring closure using whatever dimensionality is declared on the pointarray.
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
void lwgeom_affine(LWGEOM *geom, const AFFINE *affine)
char * lwgeom_to_kml2(const LWGEOM *geom, int precision, const char *prefix)
LWGEOM * lwgeom_linemerge(const LWGEOM *geom1)
void printLWTRIANGLE(LWTRIANGLE *triangle)
LWGEOM * lwgeom_split(const LWGEOM *lwgeom_in, const LWGEOM *blade_in)
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)...
LWGEOM * lwgeom_from_geojson(const char *geojson, char **srs)
Create an LWGEOM object from a GeoJSON representation.
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
LWGEOM * lwmpoint_as_lwgeom(const LWMPOINT *obj)
POINTARRAY * ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2)
Merge two given POINTARRAY and returns a pointer on the new aggregate one.