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;
void gbox_duplicate(const GBOX *original, GBOX *duplicate)
Copy the values of original GBOX into duplicate.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
LWPOLY * lwpoly_construct_envelope(int32_t srid, double x1, double y1, double x2, double y2)
#define POLYHEDRALSURFACETYPE
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
LWGEOM * lwgeom_intersection_prec(const LWGEOM *geom1, const LWGEOM *geom2, double gridSize)
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
#define LW_TRUE
Return types for functions with status returns.
double ptarray_signed_area(const POINTARRAY *pa)
Returns the area in cartesian units.
#define LW_ON_INTERRUPT(x)
#define FP_TOLERANCE
Floating point comparators.
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep-clone an LWGEOM object.
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count points in an LWGEOM.
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...
const GBOX * lwgeom_get_bbox(const LWGEOM *lwg)
Get a non-empty geometry bounding box, computing and caching it if not already there.
void lwgeom_free(LWGEOM *lwgeom)
static void lwgeom_subdivide_recursive(const LWGEOM *geom, uint8_t dimension, uint32_t maxvertices, uint32_t depth, LWCOLLECTION *col, double gridSize)
int lwgeom_simplify_in_place(LWGEOM *geom, double epsilon, int preserve_collapsed)
void lwerror(const char *fmt,...)
Write a notice out to the error 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 int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
static double pivot(double *left, double *right)