PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ lwgeom_subdivide()

LWCOLLECTION* lwgeom_subdivide ( const LWGEOM geom,
uint32_t  maxvertices 

Definition at line 2366 of file lwgeom.c.

References COLLECTIONTYPE, lwcollection_construct_empty(), lwcollection_free(), lwerror(), lwgeom_get_bbox(), lwgeom_has_m(), lwgeom_has_z(), lwgeom_is_empty(), lwgeom_set_srid(), lwgeom_subdivide_recursive(), and LWGEOM::srid.

Referenced by ST_Subdivide(), and test_geos_subdivide().

2367 {
2368  static uint32_t startdepth = 0;
2369  static uint32_t minmaxvertices = 8;
2370  LWCOLLECTION *col;
2371  GBOX clip;
2375  if ( lwgeom_is_empty(geom) )
2376  return col;
2378  if ( maxvertices < minmaxvertices )
2379  {
2380  lwcollection_free(col);
2381  lwerror("%s: cannot subdivide to fewer than %d vertices per output", __func__, minmaxvertices);
2382  }
2384  clip = *(lwgeom_get_bbox(geom));
2385  lwgeom_subdivide_recursive(geom, maxvertices, startdepth, col, &clip);
2386  lwgeom_set_srid((LWGEOM*)col, geom->srid);
2387  return col;
2388 }
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:936
int32_t srid
Definition: liblwgeom.h:398
unsigned int uint32_t
Definition: uthash.h:78
static int lwgeom_subdivide_recursive(const LWGEOM *geom, uint32_t maxvertices, uint32_t depth, LWCOLLECTION *col, const GBOX *clip)
Definition: lwgeom.c:2255
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1392
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:929
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:342
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Definition: lwgeom.c:1578
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:94
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
Definition: liblwgeom.h:90
const GBOX * lwgeom_get_bbox(const LWGEOM *lwg)
Get a non-empty geometry bounding box, computing and caching it if not already there.
Definition: lwgeom.c:733
Here is the call graph for this function:
Here is the caller graph for this function: