34 #define out_stack_size 32
58 for (i=0; i<coll->
ngeoms; i++)
82 for (i=0; i < coll->
ngeoms; i++)
144 for (i=0; i<ngeoms; i++)
146 for (i=0; i<col->
ngeoms/2; i++) {
149 col->
geoms[ngeoms-i-1] = tmp;
165 for (i=0; i<col->
ngeoms; i++)
181 if ( lwgeom == NULL )
return NULL;
190 if ( lwgeom == NULL )
return NULL;
199 if ( lwgeom == NULL )
return NULL;
208 if ( lwgeom == NULL )
return NULL;
217 if ( lwgeom == NULL )
return NULL;
226 if ( lwgeom == NULL )
return NULL;
235 if ( lwgeom == NULL )
return NULL;
244 if ( lwgeom == NULL )
return NULL;
253 if ( lwgeom == NULL )
return NULL;
262 if ( lwgeom == NULL )
return NULL;
280 return (
LWTIN *)lwgeom;
296 if ( obj == NULL )
return NULL;
301 if ( obj == NULL )
return NULL;
306 if ( obj == NULL )
return NULL;
311 if ( obj == NULL )
return NULL;
316 if ( obj == NULL )
return NULL;
321 if ( obj == NULL )
return NULL;
326 if ( obj == NULL )
return NULL;
331 if ( obj == NULL )
return NULL;
336 if ( obj == NULL )
return NULL;
341 if ( obj == NULL )
return NULL;
346 if ( obj == NULL )
return NULL;
372 if (
type > 15)
return 0;
406 box = ogeoms[0]->
bbox;
407 ogeoms[0]->
bbox = NULL;
471 lwerror(
"lwgeom_release: someone called on 0x0");
478 LWDEBUGF(3,
"lwgeom_release: releasing bbox. %p", lwgeom->
bbox);
493 LWDEBUGF(2,
"lwgeom_clone called with %p, %s",
496 switch (lwgeom->
type)
531 LWDEBUGF(2,
"lwgeom_clone called with %p, %s",
534 switch (lwgeom->
type)
574 lwerror(
"Error writing geom %p to WKT", lwgeom);
593 LWDEBUGF(2,
"lwgeom_same(%s, %s) called",
597 if ( lwgeom1->
type != lwgeom2->
type )
606 LWDEBUG(3,
" ZM flags differ");
612 if ( lwgeom1->
bbox && lwgeom2->
bbox )
617 LWDEBUG(3,
" bounding boxes differ");
624 switch (lwgeom1->
type)
654 lwerror(
"lwgeom_same: unsupported geometry type: %s",
667 if ( ! p || ! p->
point )
700 if ( lwgeom->
bbox )
return;
720 if ( ! ( gbox || lwgeom->
bbox ) )
725 else if ( gbox && ! lwgeom->
bbox )
735 for ( i = 0; i < lwcol->
ngeoms; i++ )
773 switch (lwgeom->
type)
870 for ( i = 0; i < col->
ngeoms; i++ )
900 for ( i = 0; i < col->
ngeoms; i++ )
916 for ( i = 0; i < col->
ngeoms; i++ )
957 if ( ! geom )
return 0;
990 for ( i = 0; i < ply->
nrings; i++ )
998 for ( i = 0; i < col->
ngeoms; i++ )
1011 switch (lwgeom->
type)
1029 for (i=0; i<poly->
nrings; i++)
1043 for (i=0; i<coll->
ngeoms; i++)
1047 lwerror(
"lwgeom_longitude_shift: unsupported geom type: %s",
1083 for ( i = 0; i < col->
ngeoms; i++ )
1159 if( ! lwgeom )
return;
1163 switch (lwgeom->
type)
1251 if( ! geom )
return 0;
1253 LWDEBUGF(4,
"lwgeom_count_vertices got type %s",
1285 lwerror(
"%s: unsupported input geometry type: %s",
1302 if( ! geom )
return -1;
1304 LWDEBUGF(4,
"lwgeom_dimension got type %s",
1332 return ( closed ? 3 : 2 );
1339 for( i = 0; i < col->
ngeoms; i++ )
1342 maxdim = ( dim > maxdim ? dim : maxdim );
1347 lwerror(
"%s: unsupported input geometry type: %s",
1392 for( i = 0; i < col->
ngeoms; i++ )
1416 int dimensionality = 0;
1417 for ( i = 0; i < col->
ngeoms; i++ )
1420 if ( d > dimensionality )
1423 return dimensionality;
1430 LWDEBUGF(3,
"lwgeom_dimensionality got type %s",
1464 lwerror(
"lwgeom_dimensionality: unsupported input geometry type: %s",
1488 LWDEBUGF(4,
"lwgeom_flip_coordinates, got type: %s",
1507 for (i=0; i<poly->
nrings; i++)
1528 for (i=0; i<col->
ngeoms; i++)
1535 lwerror(
"lwgeom_swap_ordinates: unsupported geometry type: %s",
1541 if ( in->
bbox && (o1 < 2 || o2 < 2) )
1551 LWDEBUGF(4,
"entered with srid=%d",srid);
1559 for ( i = 0; i < col->
ngeoms; i++ )
1578 return (pt1->
x > pt2->
x) ? 1 : ((pt1->
x < pt2->
x) ? -1 : 0);
1590 return (pt1->
y > pt2->
y) ? 1 : ((pt1->
y < pt2->
y) ? -1 : 0);
1602 return geometry_modified;
1606 uint32_t npoints = pa->
npoints;
1608 geometry_modified = npoints != pa->
npoints;
1620 for (uint32_t i = 0; i < g->
nrings; i++)
1623 uint32_t npoints = pa->
npoints;
1625 geometry_modified |= npoints != pa->
npoints;
1640 double tolsq = tolerance * tolerance;
1643 for (uint8_t dim = 0; dim < 2; dim++)
1647 for (uint32_t i = 0; i < mpt->
ngeoms; i++)
1655 for (uint32_t j = i + 1; j < mpt->
ngeoms; j++)
1663 if ((dim ? ptj->
x - pti->
x : ptj->
y - pti->
y) > tolerance)
1670 mpt->
geoms[j] = NULL;
1678 for (uint32_t j = 0; j < mpt->
ngeoms; j++)
1689 return geometry_modified;
1704 for (i = 0; i < col->
ngeoms; i++)
1716 col->
geoms[j++] = g;
1728 if (geometry_modified)
1730 return geometry_modified;
1747 if (preserve_collapsed)
1763 uint32_t in_npoints = pa->
npoints;
1765 modified = in_npoints != pa->
npoints;
1770 if (preserve_collapsed)
1782 if (pa->
npoints == 2 && !preserve_collapsed)
1793 for (i = 0; i < g->
nrings; i++)
1797 int minpoints = (preserve_collapsed && i == 0) ? 4 : 0;
1801 uint32_t in_npoints = pa->
npoints;
1803 modified |= in_npoints != pa->
npoints;
1810 for (i = 0; i < g->
nrings; i++)
1839 for (i = 0; i < col->
ngeoms; i++)
1850 col->
geoms[j++] = g;
1900 for ( i = 0; i < col->
ngeoms; i++ )
1919 double perimeter = 0.0;
1922 for ( i = 0; i < col->
ngeoms; i++ )
1941 double perimeter = 0.0;
1944 for ( i = 0; i < col->
ngeoms; i++ )
1963 double length = 0.0;
1966 for ( i = 0; i < col->
ngeoms; i++ )
1985 double length = 0.0;
1988 for ( i = 0; i < col->
ngeoms; i++ )
2017 for( i = 0; i < p->
nrings; i++ )
2024 for( i = 0; i < c->
nrings; i++ )
2033 for( i = 0; i < c->
ngeoms; i++ )
2071 for( i = 0; i < p->
nrings; i++ )
2078 for( i = 0; i < c->
nrings; i++ )
2087 for( i = 0; i < c->
ngeoms; i++ )
2128 lwerror(
"lwgeom_construct_empty: unsupported geometry type: %s",
2140 switch( lwgeom->
type )
2170 switch ( geom->
type )
2192 if (!ply->
rings)
return;
2201 for (i = 0; i < ply->
nrings; i++)
2211 for (i = 1; i < ply->
nrings; i++)
2219 ply->
rings[j++] = pa;
2239 if (!col->
geoms)
return;
2240 for (i = 0; i < col->
ngeoms; i++)
2251 col->
geoms[j++] = g;
2258 lwerror(
"%s: Unsupported geometry type: %s", __func__,
2278 uint32_t maxvertices,
2286 uint32_t maxvertices,
2291 const uint32_t maxdepth = 50;
2304 double width = clip.
xmax - clip.
xmin;
2305 double height = clip.
ymax - clip.
ymin;
2310 if ( width == 0.0 && height == 0.0 )
2336 for (uint32_t i = 0; i < incol->
ngeoms; i++ )
2350 if ( depth > maxdepth )
2363 if (nvertices <= maxvertices)
2369 uint8_t split_ordinate = (width > height) ? 0 : 1;
2370 double center = (split_ordinate == 0) ? (clip.
xmin + clip.
xmax) / 2 : (clip.
ymin + clip.
ymax) / 2;
2371 double pivot = DBL_MAX;
2374 uint32_t ring_to_trim = 0;
2375 double ring_area = 0;
2376 double pivot_eps = DBL_MAX;
2377 double pt_eps = DBL_MAX;
2385 for (uint32_t i = 1; i < lwpoly->
nrings; i++)
2388 if (current_ring_area >= ring_area)
2390 ring_area = current_ring_area;
2396 pa = lwpoly->
rings[ring_to_trim];
2399 for (uint32_t i = 0; i < pa->
npoints; i++)
2402 if (split_ordinate == 0)
2406 pt_eps = fabs(pt - center);
2407 if (pivot_eps > pt_eps)
2414 GBOX subbox1, subbox2;
2418 if (
pivot == DBL_MAX)
2421 if (split_ordinate == 0)
2426 subbox1.
xmax = subbox2.
xmin = center;
2433 subbox1.
ymax = subbox2.
ymin = center;
2467 static uint32_t startdepth = 0;
2468 static uint32_t minmaxvertices = 5;
2476 if ( maxvertices < minmaxvertices )
2479 lwerror(
"%s: cannot subdivide to fewer than %d vertices per output", __func__, minmaxvertices);
2502 lwnotice(
"Geometry is not a LINESTRING");
2508 #define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(COND)?1:-1]
2514 memcpy(&dint, &d,
sizeof(
double));
2517 const int exponent = (int)((dint >> 52) & 2047) - 1023;
2519 int bits_needed = 1 + exponent + (decimal_digits * 851 + 255) / 256;
2522 if (decimal_digits < 0)
2527 if (bits_needed >= 52)
2531 if (bits_needed < 1 )
2533 const uint64_t mask = 0xffffffffffffffffULL << (52 - bits_needed);
2535 memcpy(&d, &dint,
sizeof(
double));
2566 switch (lwgeom->
type)
2586 return (
LWGEOM *)lwmpoint;
2595 for (uint32_t i = 0; i < lwmline->
ngeoms; i++)
2601 for (uint32_t k = 0; k < points->
ngeoms; k++)
2606 for (uint32_t j = 0; j < n; j++)
2608 if (memcmp(&(out[j]), &pt,
sizeof(
POINT4D)) == 0)
2624 for (uint32_t i = 0; i < n; i++)
2629 return (
LWGEOM *)lwmpoint;
2640 for (uint32_t i = 0; i < lwpoly->
nrings; i++)
2655 for (uint32_t i = 0; i < lwcurvepoly->
nrings; i++)
2666 for (uint32_t i = 0; i < lwcol->
ngeoms; i++)
2691 int finite = isfinite(p.
x) &&
2693 (hasz ? isfinite(p.
z) : 1) &&
2694 (hasm ? isfinite(p.
m) : 1);
char result[OUT_DOUBLE_BUFFER_SIZE]
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
void gbox_duplicate(const GBOX *original, GBOX *duplicate)
Copy the values of original GBOX into duplicate.
int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the 2-4D bounding box of a geometry.
GBOX * gbox_new(lwflags_t flags)
Create a new gbox with the dimensionality indicated by the flags.
GBOX * gbox_clone(const GBOX *gbox)
LWPOINT * lwpoint_construct_empty(int32_t srid, char hasz, char hasm)
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
void lwmpoint_free(LWMPOINT *mpt)
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
LWLINE * lwline_segmentize2d(const LWLINE *line, double dist)
void lwpoint_free(LWPOINT *pt)
LWCOLLECTION * lwcollection_segmentize2d(const LWCOLLECTION *coll, double dist)
void lwmpoly_free(LWMPOLY *mpoly)
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
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_free(LWTIN *tin)
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
LWGEOM * lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad)
Convert type with arcs into equivalent linearized type.
#define FLAGS_SET_BBOX(flags, value)
int lwpointiterator_peek(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assigns the next point in the iterator to p.
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
LWMLINE * lwmline_construct_empty(int32_t srid, char hasz, char hasm)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define FLAGS_GET_Z(flags)
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
LWTRIANGLE * lwtriangle_construct_empty(int32_t srid, char hasz, char hasm)
LWMPOINT * lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
LWPOLY * lwpoly_construct_envelope(int32_t srid, double x1, double y1, double x2, double y2)
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...
LWGEOM * lwgeom_homogenize(const LWGEOM *geom)
#define FLAGS_NDIMS(flags)
void lwcircstring_free(LWCIRCSTRING *curve)
LWMPOINT * lwmpoint_construct_empty(int32_t srid, char hasz, char hasm)
void lwtriangle_free(LWTRIANGLE *triangle)
#define POLYHEDRALSURFACETYPE
LWPOINTITERATOR * lwpointiterator_create_rw(LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM* Supports modification of coordinates during iterat...
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
#define FLAGS_GET_M(flags)
void lwcollection_free(LWCOLLECTION *col)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
LWGEOM * lwgeom_intersection_prec(const LWGEOM *geom1, const LWGEOM *geom2, double gridSize)
void ptarray_free(POINTARRAY *pa)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
#define FLAGS_GET_ZM(flags)
LWPOLY * lwpoly_segmentize2d(const LWPOLY *line, double dist)
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.
#define FLAGS_SET_GEODETIC(flags, value)
void * lwalloc(size_t size)
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
void lwpsurface_free(LWPSURFACE *psurf)
void lwpoly_free(LWPOLY *poly)
void lwmline_free(LWMLINE *mline)
#define LW_TRUE
Return types for functions with status returns.
int lwline_is_trajectory(const LWLINE *geom)
LWCURVEPOLY * lwcurvepoly_construct_empty(int32_t srid, char hasz, char hasm)
#define SRID_UNKNOWN
Unknown SRID value.
LWPOLY * lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes)
LWCOMPOUND * lwcompound_construct_from_lwline(const LWLINE *lwpoly)
Construct an equivalent compound curve from a linestring.
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
LWCIRCSTRING * lwcircstring_construct_empty(int32_t srid, char hasz, char hasm)
void lwline_free(LWLINE *line)
LWLINE * lwline_construct_empty(int32_t srid, char hasz, char hasm)
#define FLAGS_GET_GEODETIC(flags)
LWPOINT * lwpoint_make(int32_t srid, int hasz, int hasm, const POINT4D *p)
enum LWORD_T LWORD
Ordinate names.
double lwline_length_2d(const LWLINE *line)
void ptarray_longitude_shift(POINTARRAY *pa)
Longitude shift for a pointarray.
LWLINE * lwline_clone_deep(const LWLINE *lwgeom)
double lwcircstring_length_2d(const LWCIRCSTRING *circ)
LWPOINT * lwpoint_clone(const LWPOINT *lwgeom)
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
void ptarray_reverse_in_place(POINTARRAY *pa)
LWLINE * lwline_clone(const LWLINE *lwgeom)
char lwcollection_same(const LWCOLLECTION *p1, const LWCOLLECTION *p2)
check for same geometry composition
double lwtriangle_area(const LWTRIANGLE *triangle)
Find the area of the outer ring.
double lwcompound_length_2d(const LWCOMPOUND *comp)
double ptarray_signed_area(const POINTARRAY *pa)
Returns the area in cartesian units.
#define LW_ON_INTERRUPT(x)
int lwline_is_closed(const LWLINE *line)
uint32_t lwline_count_vertices(const LWLINE *line)
char lwtriangle_same(const LWTRIANGLE *p1, const LWTRIANGLE *p2)
int lwpoly_startpoint(const LWPOLY *lwpoly, POINT4D *pt)
LWPOINT * lwpoint_force_dims(const LWPOINT *lwpoint, int hasz, int hasm, double zval, double mval)
int lwcollection_startpoint(const LWCOLLECTION *col, POINT4D *pt)
int ptarray_startpoint(const POINTARRAY *pa, POINT4D *pt)
int lwcompound_is_closed(const LWCOMPOUND *curve)
double lwtriangle_perimeter_2d(const LWTRIANGLE *triangle)
int lwpoly_is_clockwise(LWPOLY *poly)
void ptarray_grid_in_place(POINTARRAY *pa, const gridspec *grid)
Snap to grid.
double lwpoly_area(const LWPOLY *poly)
Find the area of the outer ring - sum (area of inner rings).
int lwtriangle_is_clockwise(LWTRIANGLE *triangle)
char lwline_same(const LWLINE *p1, const LWLINE *p2)
void ptarray_remove_repeated_points_in_place(POINTARRAY *pa, double tolerance, uint32_t min_points)
double lwtriangle_perimeter(const LWTRIANGLE *triangle)
void ptarray_simplify_in_place(POINTARRAY *pa, double tolerance, uint32_t minpts)
LWLINE * lwline_force_dims(const LWLINE *lwline, int hasz, int hasm, double zval, double mval)
double lwcompound_length(const LWCOMPOUND *comp)
LWCOLLECTION * lwcollection_clone_deep(const LWCOLLECTION *lwgeom)
Deep clone LWCOLLECTION object.
LWCOLLECTION * lwcollection_force_dims(const LWCOLLECTION *lwcol, int hasz, int hasm, double zval, double mval)
void lwtriangle_force_clockwise(LWTRIANGLE *triangle)
#define FP_TOLERANCE
Floating point comparators.
void ptarray_scale(POINTARRAY *pa, const POINT4D *factor)
WARNING, make sure you send in only 16-member double arrays or obviously things will go pear-shaped f...
void ptarray_affine(POINTARRAY *pa, const AFFINE *affine)
Affine transform a pointarray.
int lwpsurface_is_closed(const LWPSURFACE *psurface)
double lwcurvepoly_perimeter(const LWCURVEPOLY *poly)
uint32_t lwpoly_count_vertices(const LWPOLY *poly)
char lwpoly_same(const LWPOLY *p1, const LWPOLY *p2)
double lwline_length(const LWLINE *line)
void lwpoly_force_clockwise(LWPOLY *poly)
uint32_t lwcollection_count_vertices(const LWCOLLECTION *col)
void ptarray_swap_ordinates(POINTARRAY *pa, LWORD o1, LWORD o2)
Swap ordinate values o1 and o2 on a given POINTARRAY.
double lwpoly_perimeter_2d(const LWPOLY *poly)
Compute the sum of polygon rings length (forcing 2d computation).
int lwtin_is_closed(const LWTIN *tin)
char lwcircstring_same(const LWCIRCSTRING *p1, const LWCIRCSTRING *p2)
LWPOLY * lwpoly_clone_deep(const LWPOLY *lwgeom)
double lwcircstring_length(const LWCIRCSTRING *circ)
double lwcurvepoly_area(const LWCURVEPOLY *curvepoly)
This should be rewritten to make use of the curve itself.
LWCOLLECTION * lwcollection_clone(const LWCOLLECTION *lwgeom)
Clone LWCOLLECTION object.
int lwpoly_is_closed(const LWPOLY *poly)
LWPOLY * lwpoly_clone(const LWPOLY *lwgeom)
void ptarray_copy_point(POINTARRAY *pa, uint32_t from, uint32_t to)
double lwcurvepoly_perimeter_2d(const LWCURVEPOLY *poly)
double lwpoly_perimeter(const LWPOLY *poly)
Compute the sum of polygon rings length.
LWTRIANGLE * lwtriangle_clone(const LWTRIANGLE *lwgeom)
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
LWCIRCSTRING * lwcircstring_clone(const LWCIRCSTRING *curve)
LWPOLY * lwpoly_force_dims(const LWPOLY *lwpoly, int hasz, int hasm, double zval, double mval)
int p2d_same(const POINT2D *p1, const POINT2D *p2)
int lwgeom_is_closed(const LWGEOM *geom)
Return true or false depending on whether a geometry is a linear feature that closes on itself.
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
LWGEOM * lwgeom_force_dims(const LWGEOM *geom, int hasz, int hasm, double zval, double mval)
static double trim_preserve_decimal_digits(double d, int32_t decimal_digits)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWGEOM * lwcompound_as_lwgeom(const LWCOMPOUND *obj)
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
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
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?
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
int lwgeom_startpoint(const LWGEOM *lwgeom, POINT4D *pt)
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
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...
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.
void lwgeom_longitude_shift(LWGEOM *lwgeom)
LWGEOM * lwgeom_segmentize2d(const LWGEOM *lwgeom, double dist)
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
double lwgeom_perimeter_2d(const LWGEOM *geom)
int lwpoint_inside_circle(const LWPOINT *p, double cx, double cy, double rad)
static int cmp_point_x(const void *pa, const void *pb)
LWGEOM * lwmline_as_lwgeom(const LWMLINE *obj)
LWGEOM * lwmpoint_as_lwgeom(const LWMPOINT *obj)
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
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 ...
LWGEOM * lwgeom_force_sfs(LWGEOM *geom, int version)
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep-clone an LWGEOM object.
LWMPOLY * lwgeom_as_lwmpoly(const LWGEOM *lwgeom)
LWGEOM * lwgeom_force_3dm(const LWGEOM *geom, double mval)
int lwgeom_has_srid(const LWGEOM *geom)
Return true or false depending on whether a geometry has a valid SRID set.
LWGEOM * lwgeom_force_4d(const LWGEOM *geom, double zval, double mval)
double lwgeom_length(const LWGEOM *geom)
LWGEOM * lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance)
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
int lwgeom_remove_repeated_points_in_place(LWGEOM *geom, double tolerance)
LWGEOM * lwpsurface_as_lwgeom(const LWPSURFACE *obj)
LWGEOM * lwgeom_force_3dz(const LWGEOM *geom, double zval)
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)
Return TRUE if the geometry may contain sub-geometries, i.e.
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
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.
static int lwcollection_dimensionality(const LWCOLLECTION *col)
LWTRIANGLE * lwgeom_as_lwtriangle(const LWGEOM *lwgeom)
double lwgeom_area(const LWGEOM *geom)
LWMLINE * lwgeom_as_lwmline(const LWGEOM *lwgeom)
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count points in an LWGEOM.
LWGEOM * lwgeom_reverse(const LWGEOM *geom)
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 * lwpoint_as_lwgeom(const LWPOINT *obj)
LWGEOM * lwgeom_as_curve(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate CURVE* type.
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)
uint8_t lwtype_multitype(uint8_t type)
LWGEOM * lwgeom_boundary(LWGEOM *lwgeom)
LWCURVEPOLY * lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom)
const GBOX * lwgeom_get_bbox(const LWGEOM *lwg)
Get a non-empty geometry bounding box, computing and caching it if not already there.
static int cmp_point_y(const void *pa, const void *pb)
double lwgeom_length_2d(const LWGEOM *geom)
uint32_t lwgeom_count_rings(const LWGEOM *geom)
Count rings in an LWGEOM.
void lwgeom_reverse_in_place(LWGEOM *geom)
Reverse vertex order of LWGEOM.
void lwgeom_force_clockwise(LWGEOM *lwgeom)
Force Right-hand-rule on LWGEOM polygons.
int lwgeom_is_solid(const LWGEOM *geom)
Return LW_TRUE if geometry has SOLID flag.
#define STATIC_ASSERT(COND, MSG)
LWGEOM * lwtin_as_lwgeom(const LWTIN *obj)
LWGEOM * lwcurvepoly_as_lwgeom(const LWCURVEPOLY *obj)
uint8_t MULTITYPE[NUMTYPES]
Look-up for the correct MULTI* type promotion for singleton types.
LWTIN * lwgeom_as_lwtin(const LWGEOM *lwgeom)
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the gbox for this geometry, a cartesian box or geodetic box, depending on how it is flagged...
LWGEOM * lwcircstring_as_lwgeom(const LWCIRCSTRING *obj)
LWPSURFACE * lwgeom_as_lwpsurface(const LWGEOM *lwgeom)
void lwgeom_add_bbox_deep(LWGEOM *lwgeom, GBOX *gbox)
Compute a box for geom and all sub-geometries, if not already computed.
int lwgeom_dimensionality(const LWGEOM *geom)
Return the dimensionality (relating to point/line/poly) of an lwgeom.
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
void lwgeom_free(LWGEOM *lwgeom)
LWGEOM * lwtriangle_as_lwgeom(const LWTRIANGLE *obj)
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
static void lwgeom_subdivide_recursive(const LWGEOM *geom, uint8_t dimension, uint32_t maxvertices, uint32_t depth, LWCOLLECTION *col, double gridSize)
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
double lwgeom_perimeter(const LWGEOM *geom)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
void lwgeom_scale(LWGEOM *geom, const POINT4D *factor)
LWCOLLECTION * lwgeom_subdivide_prec(const LWGEOM *geom, uint32_t maxvertices, double gridSize)
LWGEOM * lwgeom_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
LWGEOM * lwgeom_grid(const LWGEOM *lwgeom, const gridspec *grid)
int lwgeom_is_clockwise(LWGEOM *lwgeom)
Check clockwise orientation on LWGEOM polygons.
int lwgeom_simplify_in_place(LWGEOM *geom, double epsilon, int preserve_collapsed)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Ensure there's a box in the LWGEOM.
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
void lwgeom_drop_srid(LWGEOM *lwgeom)
void lwgeom_grid_in_place(LWGEOM *geom, const gridspec *grid)
LWCOMPOUND * lwgeom_as_lwcompound(const LWGEOM *lwgeom)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
static double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
static double pivot(double *left, double *right)