PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ lwgeom_subdivide()

LWCOLLECTION* lwgeom_subdivide ( const LWGEOM geom,
uint32_t  maxvertices 

Definition at line 2360 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().

2361 {
2362  static uint32_t startdepth = 0;
2363  static uint32_t minmaxvertices = 8;
2364  LWCOLLECTION *col;
2365  GBOX clip;
2369  if ( lwgeom_is_empty(geom) )
2370  return col;
2372  if ( maxvertices < minmaxvertices )
2373  {
2374  lwcollection_free(col);
2375  lwerror("%s: cannot subdivide to fewer than %d vertices per output", __func__, minmaxvertices);
2376  }
2378  clip = *(lwgeom_get_bbox(geom));
2379  lwgeom_subdivide_recursive(geom, maxvertices, startdepth, col, &clip);
2380  lwgeom_set_srid((LWGEOM*)col, geom->srid);
2381  return col;
2382 }
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:930
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:2249
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:1386
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:923
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:342
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Definition: lwgeom.c:1572
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:727
Here is the call graph for this function:
Here is the caller graph for this function: