PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ lwgeom_needs_bbox()

int lwgeom_needs_bbox ( const LWGEOM geom)

Check whether or not a lwgeom is big enough to warrant a bounding box.

Check whether or not a lwgeom is big enough to warrant a bounding box when stored in the serialized form on disk. Currently only points are considered small enough to not require a bounding box, because the index operations can generate a large number of box-retrieval operations when scanning keys.

Definition at line 1299 of file lwgeom.c.

1300 {
1301  assert(geom);
1302  if ( geom->type == POINTTYPE )
1303  {
1304  return LW_FALSE;
1305  }
1306  else if ( geom->type == LINETYPE )
1307  {
1308  if ( lwgeom_count_vertices(geom) <= 2 )
1309  return LW_FALSE;
1310  else
1311  return LW_TRUE;
1312  }
1313  else if ( geom->type == MULTIPOINTTYPE )
1314  {
1315  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 )
1316  return LW_FALSE;
1317  else
1318  return LW_TRUE;
1319  }
1320  else if ( geom->type == MULTILINETYPE )
1321  {
1322  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 && lwgeom_count_vertices(geom) <= 2 )
1323  return LW_FALSE;
1324  else
1325  return LW_TRUE;
1326  }
1327  else
1328  {
1329  return LW_TRUE;
1330  }
1331 }
#define LW_FALSE
Definition: liblwgeom.h:94
#define MULTILINETYPE
Definition: liblwgeom.h:106
#define LINETYPE
Definition: liblwgeom.h:103
#define MULTIPOINTTYPE
Definition: liblwgeom.h:105
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:102
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count points in an LWGEOM.
Definition: lwgeom.c:1337
uint8_t type
Definition: liblwgeom.h:462

References LINETYPE, LW_FALSE, LW_TRUE, lwgeom_count_vertices(), MULTILINETYPE, MULTIPOINTTYPE, POINTTYPE, and LWGEOM::type.

Referenced by GEOS2POSTGIS(), gserialized1_from_lwgeom(), gserialized2_from_lwgeom(), lwgeom_from_gserialized1(), lwgeom_from_gserialized2(), LWGEOM_in(), LWGEOM_recv(), LWGEOMFromEWKB(), and LWGEOMFromTWKB().

Here is the call graph for this function:
Here is the caller graph for this function: