PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ lwgeom_to_basic_type()

static LWGEOM* lwgeom_to_basic_type ( LWGEOM geom,
uint8_t  original_type 
)
inlinestatic

In place process a collection to find a concrete geometry object and expose that as the actual object.

Will some geom be lost? Sure, but your MVT renderer couldn't draw it anyways.

Definition at line 787 of file mvt.c.

788 {
789  LWGEOM *geom_out = geom;
790  if (lwgeom_get_type(geom) == COLLECTIONTYPE)
791  {
792  LWCOLLECTION *g = (LWCOLLECTION*)geom;
793  geom_out = (LWGEOM *)lwcollection_extract(g, original_type);
794  }
795 
796  /* If a collection only contains 1 geometry return than instead */
797  if (lwgeom_is_collection(geom_out))
798  {
799  LWCOLLECTION *g = (LWCOLLECTION *)geom_out;
800  if (g->ngeoms == 1)
801  {
802  geom_out = g->geoms[0];
803  }
804  }
805 
806  geom_out->srid = geom->srid;
807  return geom_out;
808 }
#define COLLECTIONTYPE
Definition: liblwgeom.h:122
LWCOLLECTION * lwcollection_extract(const LWCOLLECTION *col, uint32_t type)
Definition: lwcollection.c:432
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1080
static uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
Definition: lwinline.h:145
uint32_t ngeoms
Definition: liblwgeom.h:594
LWGEOM ** geoms
Definition: liblwgeom.h:589
int32_t srid
Definition: liblwgeom.h:474

References COLLECTIONTYPE, LWCOLLECTION::geoms, lwcollection_extract(), lwgeom_get_type(), lwgeom_is_collection(), LWCOLLECTION::ngeoms, and LWGEOM::srid.

Referenced by mvt_clip_and_validate(), mvt_geom(), mvt_grid_and_validate_geos(), and mvt_iterate_clip_by_box_geos().

Here is the call graph for this function:
Here is the caller graph for this function: