PostGIS  2.5.0dev-r@@SVN_REVISION@@
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 1190 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().

1191 {
1192  assert(geom);
1193  if ( geom->type == POINTTYPE )
1194  {
1195  return LW_FALSE;
1196  }
1197  else if ( geom->type == LINETYPE )
1198  {
1199  if ( lwgeom_count_vertices(geom) <= 2 )
1200  return LW_FALSE;
1201  else
1202  return LW_TRUE;
1203  }
1204  else if ( geom->type == MULTIPOINTTYPE )
1205  {
1206  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 )
1207  return LW_FALSE;
1208  else
1209  return LW_TRUE;
1210  }
1211  else if ( geom->type == MULTILINETYPE )
1212  {
1213  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 && lwgeom_count_vertices(geom) <= 2 )
1214  return LW_FALSE;
1215  else
1216  return LW_TRUE;
1217  }
1218  else
1219  {
1220  return LW_TRUE;
1221  }
1222 }
#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:1228
#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:395
#define MULTILINETYPE
Definition: liblwgeom.h:88

Here is the call graph for this function:

Here is the caller graph for this function: