57 for (i=0; i<coll->
ngeoms; i++)
81 for (i=0; i < coll->
ngeoms; i++)
147 for (i=0; i<col->
ngeoms; i++)
163 if ( lwgeom == NULL )
return NULL;
172 if ( lwgeom == NULL )
return NULL;
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;
271 return (
LWTIN *)lwgeom;
287 if ( obj == NULL )
return NULL;
292 if ( obj == NULL )
return NULL;
297 if ( obj == NULL )
return NULL;
302 if ( obj == NULL )
return NULL;
307 if ( obj == NULL )
return NULL;
312 if ( obj == NULL )
return NULL;
317 if ( obj == NULL )
return NULL;
322 if ( obj == NULL )
return NULL;
327 if ( obj == NULL )
return NULL;
332 if ( obj == NULL )
return NULL;
337 if ( obj == NULL )
return NULL;
363 if (
type > 15)
return 0;
397 box = ogeoms[0]->
bbox;
398 ogeoms[0]->
bbox = NULL;
462 lwerror(
"lwgeom_release: someone called on 0x0");
469 LWDEBUGF(3,
"lwgeom_release: releasing bbox. %p", lwgeom->
bbox);
484 LWDEBUGF(2,
"lwgeom_clone called with %p, %s",
487 switch (lwgeom->
type)
522 LWDEBUGF(2,
"lwgeom_clone called with %p, %s",
525 switch (lwgeom->
type)
565 lwerror(
"Error writing geom %p to WKT", lwgeom);
584 LWDEBUGF(2,
"lwgeom_same(%s, %s) called",
588 if ( lwgeom1->
type != lwgeom2->
type )
597 LWDEBUG(3,
" ZM flags differ");
603 if ( lwgeom1->
bbox && lwgeom2->
bbox )
608 LWDEBUG(3,
" bounding boxes differ");
615 switch (lwgeom1->
type)
645 lwerror(
"lwgeom_same: unsupported geometry type: %s",
658 if ( ! p || ! p->
point )
691 if ( lwgeom->
bbox )
return;
711 if ( ! ( gbox || lwgeom->
bbox ) )
716 else if ( gbox && ! lwgeom->
bbox )
726 for ( i = 0; i < lwcol->
ngeoms; i++ )
764 switch (lwgeom->
type)
859 for ( i = 0; i < col->
ngeoms; i++ )
889 for ( i = 0; i < col->
ngeoms; i++ )
905 for ( i = 0; i < col->
ngeoms; i++ )
925 if ( ! geom )
return 0;
946 if ( ! geom )
return 0;
978 for ( i = 0; i < ply->
nrings; i++ )
986 for ( i = 0; i < col->
ngeoms; i++ )
999 switch (lwgeom->
type)
1017 for (i=0; i<poly->
nrings; i++)
1031 for (i=0; i<coll->
ngeoms; i++)
1035 lwerror(
"lwgeom_longitude_shift: unsupported geom type: %s",
1071 for ( i = 0; i < col->
ngeoms; i++ )
1148 if( ! lwgeom )
return;
1152 switch (lwgeom->
type)
1240 if( ! geom )
return 0;
1242 LWDEBUGF(4,
"lwgeom_count_vertices got type %s",
1274 lwerror(
"%s: unsupported input geometry type: %s",
1278 LWDEBUGF(3,
"counted %d vertices", result);
1291 if( ! geom )
return -1;
1293 LWDEBUGF(4,
"lwgeom_dimension got type %s",
1321 return ( closed ? 3 : 2 );
1328 for( i = 0; i < col->
ngeoms; i++ )
1331 maxdim = ( dim > maxdim ? dim : maxdim );
1336 lwerror(
"%s: unsupported input geometry type: %s",
1368 result = ((
LWPOLY *)geom)->nrings;
1381 for( i = 0; i < col->
ngeoms; i++ )
1389 LWDEBUGF(3,
"counted %d rings", result);
1396 LWDEBUGF(4,
"lwgeom_is_empty: got type %s",
1429 lwerror(
"lwgeom_is_empty: unsupported input geometry type: %s",
1448 int dimensionality = 0;
1449 for ( i = 0; i < col->
ngeoms; i++ )
1452 if ( d > dimensionality )
1455 return dimensionality;
1462 LWDEBUGF(3,
"lwgeom_dimensionality got type %s",
1496 lwerror(
"lwgeom_dimensionality: unsupported input geometry type: %s",
1520 LWDEBUGF(4,
"lwgeom_flip_coordinates, got type: %s",
1539 for (i=0; i<poly->
nrings; i++)
1560 for (i=0; i<col->
ngeoms; i++)
1567 lwerror(
"lwgeom_swap_ordinates: unsupported geometry type: %s",
1573 if ( in->
bbox && (o1 < 2 || o2 < 2) )
1583 LWDEBUGF(4,
"entered with srid=%d",srid);
1591 for ( i = 0; i < col->
ngeoms; i++ )
1629 for (i = 0; i < g->
nrings; i++)
1651 static uint32_t out_stack_size = 32;
1652 double tolsq = tolerance*tolerance;
1656 LWPOINT *out_stack[out_stack_size];
1657 int use_heap = (mpt->
ngeoms > out_stack_size);
1660 if (mpt->
ngeoms == 0)
return;
1671 for (i = 0; i < mpt->
ngeoms; i++)
1676 for (j = 0; j < n; j++)
1698 if (use_heap)
lwfree(out);
1720 for (i = 0; i < col->
ngeoms; i++)
1731 col->
geoms[j++] = g;
1759 if (preserve_collapsed)
1778 if (preserve_collapsed)
1790 if (pa->
npoints == 2 && !preserve_collapsed)
1801 for (i = 0; i < g->
nrings; i++)
1805 int minpoints = (preserve_collapsed && i == 0) ? 4 : 0;
1831 for (i = 0; i < col->
ngeoms; i++)
1842 col->
geoms[j++] = g;
1887 for ( i = 0; i < col->
ngeoms; i++ )
1906 double perimeter = 0.0;
1909 for ( i = 0; i < col->
ngeoms; i++ )
1928 double perimeter = 0.0;
1931 for ( i = 0; i < col->
ngeoms; i++ )
1950 double length = 0.0;
1953 for ( i = 0; i < col->
ngeoms; i++ )
1972 double length = 0.0;
1975 for ( i = 0; i < col->
ngeoms; i++ )
2004 for( i = 0; i < p->
nrings; i++ )
2011 for( i = 0; i < c->
nrings; i++ )
2020 for( i = 0; i < c->
ngeoms; i++ )
2058 for( i = 0; i < p->
nrings; i++ )
2065 for( i = 0; i < c->
nrings; i++ )
2074 for( i = 0; i < c->
ngeoms; i++ )
2115 lwerror(
"lwgeom_construct_empty: unsupported geometry type: %s",
2127 switch( lwgeom->
type )
2145 lwerror(
"int: unsupported geometry type: %s",
2156 switch ( geom->
type )
2178 if (!ply->
rings)
return;
2187 for (i = 0; i < ply->
nrings; i++)
2197 for (i = 1; i < ply->
nrings; i++)
2205 ply->
rings[j++] = pa;
2225 if (!col->
geoms)
return;
2226 for (i = 0; i < col->
ngeoms; i++)
2237 col->
geoms[j++] = g;
2244 lwerror(
"%s: Unsupported geometry type: %s", __func__,
2268 GBOX clip, subbox1, subbox2;
2274 double pivot = DBL_MAX;
2275 double center = DBL_MAX;
2279 if (!geom)
return 0;
2281 if (!box_in)
return 0;
2289 if ( width == 0.0 && height == 0.0 )
2320 for ( i = 0; i < incol->
ngeoms; i++ )
2334 if ( depth > maxdepth )
2343 if (nvertices == 0)
return 0;
2346 if (nvertices <= maxvertices)
2352 split_ordinate = (width > height) ? 0 : 1;
2353 if (split_ordinate == 0)
2354 center = (clip.
xmin + clip.
xmax) / 2;
2356 center = (clip.
ymin + clip.
ymax) / 2;
2361 double ring_area = 0;
2362 double pivot_eps = DBL_MAX;
2363 double pt_eps = DBL_MAX;
2372 for (i = 1; i < lwpoly->
nrings; i++)
2375 if (current_ring_area >= ring_area)
2377 ring_area = current_ring_area;
2383 pa = lwpoly->
rings[ring_to_trim];
2386 for (i = 0; i < pa->
npoints; i++)
2389 if (split_ordinate == 0)
2393 pt_eps = fabs(pt - center);
2394 if (pivot_eps > pt_eps)
2407 if (split_ordinate == 0)
2412 subbox1.
xmax = subbox2.
xmin = center;
2419 subbox1.
ymax = subbox2.
ymin = center;
2451 static uint32_t minmaxvertices = 5;
2459 if ( maxvertices < minmaxvertices )
2462 lwerror(
"%s: cannot subdivide to fewer than %d vertices per output", __func__, minmaxvertices);
2478 lwnotice(
"Geometry is not a LINESTRING");
2487 int32_t bits_needed = ceil(significant_digits / log10(2));
2489 if (bits_needed > 52)
2493 else if (bits_needed < 1)
2506 int digits_left_of_decimal = (int) (1 + log10(fabs(d)));
2508 uint64_t mask = 0xffffffffffffffffULL << (52 - bits_needed);
2510 size_t dsz =
sizeof(d) <
sizeof(dint) ?
sizeof(d) :
sizeof(dint);
2512 memcpy(&dint, &d, dsz);
2514 memcpy(&d, &dint, dsz);
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.
GBOX * gbox_new(uint8_t flags)
Create a new gbox with the dimensionality indicated by the flags.
int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the 2-4D bounding box of a geometry.
GBOX * gbox_clone(const GBOX *gbox)
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
LWCIRCSTRING * lwcircstring_construct_empty(int srid, char hasz, char hasm)
void lwmpoint_free(LWMPOINT *mpt)
LWLINE * lwline_segmentize2d(const LWLINE *line, double dist)
void lwpoint_free(LWPOINT *pt)
LWCURVEPOLY * lwcurvepoly_construct_empty(int srid, char hasz, char hasm)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
LWCOLLECTION * lwcollection_segmentize2d(const LWCOLLECTION *coll, double dist)
void lwmpoly_free(LWMPOLY *mpoly)
double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
LWCURVEPOLY * lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
Construct an equivalent curve polygon from a polygon.
LWGEOM * lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2)
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)
#define FLAGS_SET_BBOX(flags, value)
int lwpointiterator_peek(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assigns the next point in the iterator to p.
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
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...
#define FLAGS_NDIMS(flags)
void lwcircstring_free(LWCIRCSTRING *curve)
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...
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)
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)
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
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)
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)
#define SRID_UNKNOWN
Unknown SRID value.
LWPOLY * lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes)
LWPOINT * lwpoint_construct_empty(int srid, char hasz, char hasm)
LWCOMPOUND * lwcompound_construct_from_lwline(const LWLINE *lwpoly)
Construct an equivalent compound curve from a linestring.
void lwline_free(LWLINE *line)
LWPOLY * lwpoly_construct_empty(int srid, char hasz, char hasm)
LWPOLY * lwpoly_construct_envelope(int srid, double x1, double y1, double x2, double y2)
LWTRIANGLE * lwtriangle_construct_empty(int srid, char hasz, char hasm)
#define FLAGS_GET_GEODETIC(flags)
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
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)
uint32_t lwpoly_count_vertices(LWPOLY *poly)
int lwline_is_empty(const LWLINE *line)
double ptarray_signed_area(const POINTARRAY *pa)
Returns the area in cartesian units.
int lwline_is_closed(const LWLINE *line)
char lwtriangle_same(const LWTRIANGLE *p1, const LWTRIANGLE *p2)
int lwpoly_startpoint(const LWPOLY *lwpoly, POINT4D *pt)
int lwcollection_startpoint(const LWCOLLECTION *col, POINT4D *pt)
void ptarray_simplify_in_place(POINTARRAY *pa, double epsilon, uint32_t minpts)
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)
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)
int lwpoint_is_empty(const LWPOINT *point)
double lwcompound_length(const LWCOMPOUND *comp)
LWCOLLECTION * lwcollection_clone_deep(const LWCOLLECTION *lwgeom)
Deep clone LWCOLLECTION object.
void lwtriangle_force_clockwise(LWTRIANGLE *triangle)
LWPOINT * lwpoint_force_dims(const LWPOINT *lwpoint, int hasz, int hasm)
#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)
int lwtriangle_is_empty(const LWTRIANGLE *triangle)
LWPOLY * lwpoly_force_dims(const LWPOLY *lwpoly, int hasz, int hasm)
double lwcurvepoly_perimeter(const LWCURVEPOLY *poly)
LWCOLLECTION * lwcollection_force_dims(const LWCOLLECTION *lwcol, int hasz, int hasm)
int lwpoly_is_empty(const LWPOLY *poly)
char lwpoly_same(const LWPOLY *p1, const LWPOLY *p2)
double lwline_length(const LWLINE *line)
void lwpoly_force_clockwise(LWPOLY *poly)
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)
uint32_t lwcollection_count_vertices(LWCOLLECTION *col)
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)
LWLINE * lwline_force_dims(const LWLINE *lwline, int hasz, int hasm)
LWPOLY * lwpoly_clone(const LWPOLY *lwgeom)
void ptarray_copy_point(POINTARRAY *pa, uint32_t from, uint32_t to)
int lwcircstring_is_empty(const LWCIRCSTRING *circ)
int lwcollection_is_empty(const LWCOLLECTION *col)
uint32_t lwline_count_vertices(LWLINE *line)
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)
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_simplify_in_place(LWGEOM *geom, double epsilon, int preserve_collapsed)
LWGEOM * lwgeom_force_dims(const LWGEOM *geom, int hasz, int hasm)
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
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)
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.
LWGEOM * lwgeom_force_4d(const LWGEOM *geom)
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
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)
LWGEOM * lwmline_as_lwgeom(const LWMLINE *obj)
static uint8_t bits_for_precision(int32_t significant_digits)
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)
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep-clone an LWGEOM object.
LWMPOLY * lwgeom_as_lwmpoly(const LWGEOM *lwgeom)
int lwgeom_has_srid(const LWGEOM *geom)
Return true or false depending on whether a geometry has a valid SRID set.
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.
LWGEOM * lwpsurface_as_lwgeom(const LWPSURFACE *obj)
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.
static int lwcollection_dimensionality(const LWCOLLECTION *col)
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
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)
void lwgeom_remove_repeated_points_in_place(LWGEOM *geom, double tolerance)
uint8_t lwtype_multitype(uint8_t type)
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.
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_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
LWGEOM * lwgeom_force_3dm(const LWGEOM *geom)
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 int lwgeom_subdivide_recursive(const LWGEOM *geom, uint8_t dimension, uint32_t maxvertices, uint32_t depth, LWCOLLECTION *col)
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)
LWGEOM * lwgeom_force_3dz(const LWGEOM *geom)
LWGEOM * lwgeom_grid(const LWGEOM *lwgeom, const gridspec *grid)
int lwgeom_is_clockwise(LWGEOM *lwgeom)
Check clockwise orientation on LWGEOM polygons.
LWGEOM * lwgeom_construct_empty(uint8_t type, int srid, char hasz, char hasm)
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)
Datum area(PG_FUNCTION_ARGS)
#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 double pivot(double *left, double *right)