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

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

2009 {
2010  static int startdepth = 0;
2011  static int minmaxvertices = 8;
2012  LWCOLLECTION *col;
2013  GBOX clip;
2014 
2016 
2017  if ( lwgeom_is_empty(geom) )
2018  return col;
2019 
2020  if ( maxvertices < minmaxvertices )
2021  {
2022  lwcollection_free(col);
2023  lwerror("%s: cannot subdivide to fewer than %d vertices per output", __func__, minmaxvertices);
2024  }
2025 
2026  clip = *(lwgeom_get_bbox(geom));
2027  lwgeom_subdivide_recursive(geom, maxvertices, startdepth, col, &clip);
2028  lwgeom_set_srid((LWGEOM*)col, geom->srid);
2029  return col;
2030 }
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:843
int32_t srid
Definition: liblwgeom.h:383
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:1297
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:836
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:326
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Definition: lwgeom.c:1539
static int lwgeom_subdivide_recursive(const LWGEOM *geom, int maxvertices, int depth, LWCOLLECTION *col, const GBOX *clip)
Definition: lwgeom.c:1899
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:81
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
#define COLLECTIONTYPE
Definition: liblwgeom.h:76
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:640

Here is the call graph for this function:

Here is the caller graph for this function: