PostGIS  3.4.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 1208 of file lwgeom.c.

1209 {
1210  assert(geom);
1211  if ( geom->type == POINTTYPE )
1212  {
1213  return LW_FALSE;
1214  }
1215  else if ( geom->type == LINETYPE )
1216  {
1217  if ( lwgeom_count_vertices(geom) <= 2 )
1218  return LW_FALSE;
1219  else
1220  return LW_TRUE;
1221  }
1222  else if ( geom->type == MULTIPOINTTYPE )
1223  {
1224  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 )
1225  return LW_FALSE;
1226  else
1227  return LW_TRUE;
1228  }
1229  else if ( geom->type == MULTILINETYPE )
1230  {
1231  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 && lwgeom_count_vertices(geom) <= 2 )
1232  return LW_FALSE;
1233  else
1234  return LW_TRUE;
1235  }
1236  else
1237  {
1238  return LW_TRUE;
1239  }
1240 }
#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:1246
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: