PostGIS  2.3.7dev-r@@SVN_REVISION@@
LWCOLLECTION* lwgeom_subdivide ( const LWGEOM geom,
int  maxvertices 
)

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

2024 {
2025  static int startdepth = 0;
2026  static int minmaxvertices = 8;
2027  LWCOLLECTION *col;
2028  GBOX clip;
2029 
2031 
2032  if ( lwgeom_is_empty(geom) )
2033  return col;
2034 
2035  if ( maxvertices < minmaxvertices )
2036  {
2037  lwcollection_free(col);
2038  lwerror("%s: cannot subdivide to fewer than %d vertices per output", __func__, minmaxvertices);
2039  }
2040 
2041  clip = *(lwgeom_get_bbox(geom));
2042  lwgeom_subdivide_recursive(geom, maxvertices, startdepth, col, &clip);
2043  lwgeom_set_srid((LWGEOM*)col, geom->srid);
2044  return col;
2045 }
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:856
int32_t srid
Definition: liblwgeom.h:398
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:1310
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:849
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:339
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Definition: lwgeom.c:1552
static int lwgeom_subdivide_recursive(const LWGEOM *geom, int maxvertices, int depth, LWCOLLECTION *col, const GBOX *clip)
Definition: lwgeom.c:1912
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:102
#define COLLECTIONTYPE
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:653

Here is the call graph for this function:

Here is the caller graph for this function: