PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_subdivide()

LWCOLLECTION* lwgeom_subdivide ( const LWGEOM geom,
int  maxvertices 

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

2055 {
2056  static int startdepth = 0;
2057  static int minmaxvertices = 8;
2058  LWCOLLECTION *col;
2059  GBOX clip;
2063  if ( lwgeom_is_empty(geom) )
2064  return col;
2066  if ( maxvertices < minmaxvertices )
2067  {
2068  lwcollection_free(col);
2069  lwerror("%s: cannot subdivide to fewer than %d vertices per output", __func__, minmaxvertices);
2070  }
2072  clip = *(lwgeom_get_bbox(geom));
2073  lwgeom_subdivide_recursive(geom, maxvertices, startdepth, col, &clip);
2074  lwgeom_set_srid((LWGEOM*)col, geom->srid);
2075  return col;
2076 }
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:892
int32_t srid
Definition: liblwgeom.h:399
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:1346
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:885
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:340
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Definition: lwgeom.c:1583
static int lwgeom_subdivide_recursive(const LWGEOM *geom, int maxvertices, int depth, LWCOLLECTION *col, const GBOX *clip)
Definition: lwgeom.c:1943
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:91
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:689
Here is the call graph for this function:
Here is the caller graph for this function: