PostGIS  2.5.7dev-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 1197 of file lwgeom.c.

1198 {
1199  assert(geom);
1200  if ( geom->type == POINTTYPE )
1201  {
1202  return LW_FALSE;
1203  }
1204  else if ( geom->type == LINETYPE )
1205  {
1206  if ( lwgeom_count_vertices(geom) <= 2 )
1207  return LW_FALSE;
1208  else
1209  return LW_TRUE;
1210  }
1211  else if ( geom->type == MULTIPOINTTYPE )
1212  {
1213  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 )
1214  return LW_FALSE;
1215  else
1216  return LW_TRUE;
1217  }
1218  else if ( geom->type == MULTILINETYPE )
1219  {
1220  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 && lwgeom_count_vertices(geom) <= 2 )
1221  return LW_FALSE;
1222  else
1223  return LW_TRUE;
1224  }
1225  else
1226  {
1227  return LW_TRUE;
1228  }
1229 }
#define LW_FALSE
Definition: liblwgeom.h:77
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count points in an LWGEOM.
Definition: lwgeom.c:1235
uint8_t type
Definition: liblwgeom.h:399

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

Referenced by GEOS2POSTGIS(), gserialized_from_lwgeom(), lwgeom_from_gserialized(), LWGEOM_from_WKB(), LWGEOM_in(), LWGEOM_recv(), LWGEOMFromEWKB(), LWGEOMFromTWKB(), and SFCGALGeometry2POSTGIS().

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