PostGIS  2.2.8dev-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 1103 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().

1104 {
1105  assert(geom);
1106  if ( geom->type == POINTTYPE )
1107  {
1108  return LW_FALSE;
1109  }
1110  else if ( geom->type == LINETYPE )
1111  {
1112  if ( lwgeom_count_vertices(geom) <= 2 )
1113  return LW_FALSE;
1114  else
1115  return LW_TRUE;
1116  }
1117  else if ( geom->type == MULTIPOINTTYPE )
1118  {
1119  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 )
1120  return LW_FALSE;
1121  else
1122  return LW_TRUE;
1123  }
1124  else if ( geom->type == MULTILINETYPE )
1125  {
1126  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 && lwgeom_count_vertices(geom) <= 2 )
1127  return LW_FALSE;
1128  else
1129  return LW_TRUE;
1130  }
1131  else
1132  {
1133  return LW_TRUE;
1134  }
1135 }
#define LINETYPE
Definition: liblwgeom.h:71
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
int lwgeom_count_vertices(const LWGEOM *geom)
Count points in an LWGEOM.
Definition: lwgeom.c:1140
#define LW_FALSE
Definition: liblwgeom.h:62
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
uint8_t type
Definition: liblwgeom.h:380
#define MULTILINETYPE
Definition: liblwgeom.h:74
Here is the call graph for this function:
Here is the caller graph for this function: