PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_to_basic_type()

static LWGEOM* lwgeom_to_basic_type ( LWGEOM geom,
uint8  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 681 of file mvt.c.

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

Referenced by mvt_geom().

682 {
683  LWGEOM *geom_out = geom;
684  if (lwgeom_get_type(geom) == COLLECTIONTYPE)
685  {
686  LWCOLLECTION *g = (LWCOLLECTION*)geom;
687  geom_out = (LWGEOM *)lwcollection_extract(g, original_type);
688  }
689 
690  /* If a collection only contains 1 geometry return than instead */
691  if (lwgeom_is_collection(geom_out))
692  {
693  LWCOLLECTION *g = (LWCOLLECTION *)geom_out;
694  if (g->ngeoms == 1)
695  {
696  geom_out = g->geoms[0];
697  }
698  }
699 
700  geom_out->srid = geom->srid;
701  return geom_out;
702 }
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1040
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
Definition: lwcollection.c:369
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
Definition: lwgeom.c:878
int32_t srid
Definition: liblwgeom.h:399
LWGEOM ** geoms
Definition: liblwgeom.h:509
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: