PostGIS  2.4.9dev-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 1152 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().

1153 {
1154  assert(geom);
1155  if ( geom->type == POINTTYPE )
1156  {
1157  return LW_FALSE;
1158  }
1159  else if ( geom->type == LINETYPE )
1160  {
1161  if ( lwgeom_count_vertices(geom) <= 2 )
1162  return LW_FALSE;
1163  else
1164  return LW_TRUE;
1165  }
1166  else if ( geom->type == MULTIPOINTTYPE )
1167  {
1168  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 )
1169  return LW_FALSE;
1170  else
1171  return LW_TRUE;
1172  }
1173  else if ( geom->type == MULTILINETYPE )
1174  {
1175  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 && lwgeom_count_vertices(geom) <= 2 )
1176  return LW_FALSE;
1177  else
1178  return LW_TRUE;
1179  }
1180  else
1181  {
1182  return LW_TRUE;
1183  }
1184 }
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
int lwgeom_count_vertices(const LWGEOM *geom)
Count points in an LWGEOM.
Definition: lwgeom.c:1189
#define LW_FALSE
Definition: liblwgeom.h:77
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
#define MULTILINETYPE
Definition: liblwgeom.h:89
Here is the call graph for this function:
Here is the caller graph for this function: