PostGIS  2.5.0rc1dev-r@@SVN_REVISION@@

◆ lwgeom_subdivide()

LWCOLLECTION* lwgeom_subdivide ( const LWGEOM geom,
uint32_t  maxvertices 
)

Definition at line 2425 of file lwgeom.c.

References COLLECTIONTYPE, lwcollection_construct_empty(), lwcollection_free(), lwerror(), lwgeom_dimension(), 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().

2426 {
2427  static uint32_t startdepth = 0;
2428  static uint32_t minmaxvertices = 5;
2429  LWCOLLECTION *col;
2430 
2432 
2433  if ( lwgeom_is_empty(geom) )
2434  return col;
2435 
2436  if ( maxvertices < minmaxvertices )
2437  {
2438  lwcollection_free(col);
2439  lwerror("%s: cannot subdivide to fewer than %d vertices per output", __func__, minmaxvertices);
2440  }
2441 
2442  lwgeom_subdivide_recursive(geom, lwgeom_dimension(geom), maxvertices, startdepth, col);
2443  lwgeom_set_srid((LWGEOM*)col, geom->srid);
2444  return col;
2445 }
static int lwgeom_subdivide_recursive(const LWGEOM *geom, uint8_t dimension, uint32_t maxvertices, uint32_t depth, LWCOLLECTION *col)
Definition: lwgeom.c:2255
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:937
int32_t srid
Definition: liblwgeom.h:401
unsigned int uint32_t
Definition: uthash.h:78
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:1393
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...
Definition: lwgeom.c:1287
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:930
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:356
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Definition: lwgeom.c:1579
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
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
Here is the call graph for this function:
Here is the caller graph for this function: