PostGIS  3.0.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 1181 of file lwgeom.c.

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().

1182 {
1183  assert(geom);
1184  if ( geom->type == POINTTYPE )
1185  {
1186  return LW_FALSE;
1187  }
1188  else if ( geom->type == LINETYPE )
1189  {
1190  if ( lwgeom_count_vertices(geom) <= 2 )
1191  return LW_FALSE;
1192  else
1193  return LW_TRUE;
1194  }
1195  else if ( geom->type == MULTIPOINTTYPE )
1196  {
1197  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 )
1198  return LW_FALSE;
1199  else
1200  return LW_TRUE;
1201  }
1202  else if ( geom->type == MULTILINETYPE )
1203  {
1204  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 && lwgeom_count_vertices(geom) <= 2 )
1205  return LW_FALSE;
1206  else
1207  return LW_TRUE;
1208  }
1209  else
1210  {
1211  return LW_TRUE;
1212  }
1213 }
#define LINETYPE
Definition: liblwgeom.h:85
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count points in an LWGEOM.
Definition: lwgeom.c:1219
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
uint8_t type
Definition: liblwgeom.h:398
#define MULTILINETYPE
Definition: liblwgeom.h:88
Here is the call graph for this function:
Here is the caller graph for this function: