PostGIS  2.3.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 1116 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().

1117 {
1118  assert(geom);
1119  if ( geom->type == POINTTYPE )
1120  {
1121  return LW_FALSE;
1122  }
1123  else if ( geom->type == LINETYPE )
1124  {
1125  if ( lwgeom_count_vertices(geom) <= 2 )
1126  return LW_FALSE;
1127  else
1128  return LW_TRUE;
1129  }
1130  else if ( geom->type == MULTIPOINTTYPE )
1131  {
1132  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 )
1133  return LW_FALSE;
1134  else
1135  return LW_TRUE;
1136  }
1137  else if ( geom->type == MULTILINETYPE )
1138  {
1139  if ( ((LWCOLLECTION*)geom)->ngeoms == 1 && lwgeom_count_vertices(geom) <= 2 )
1140  return LW_FALSE;
1141  else
1142  return LW_TRUE;
1143  }
1144  else
1145  {
1146  return LW_TRUE;
1147  }
1148 }
#define LINETYPE
Definition: liblwgeom.h:85
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
int lwgeom_count_vertices(const LWGEOM *geom)
Count points in an LWGEOM.
Definition: lwgeom.c:1153
#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: