PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ lwgeom_to_basic_type()

static void lwgeom_to_basic_type ( LWGEOM geom)
static

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 798 of file mvt.c.

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

Referenced by mvt_geom().

799 {
800  if (lwgeom_get_type(geom) == COLLECTIONTYPE)
801  {
802  /* MVT doesn't handle generic collections, so we */
803  /* need to strip them down to a typed collection */
804  /* by finding the largest basic type available and */
805  /* using that as the basis of a typed collection. */
806  LWCOLLECTION *g = (LWCOLLECTION*)geom;
807  LWCOLLECTION *gc;
808  uint32_t i, maxtype = 0;
809  for (i = 0; i < g->ngeoms; i++)
810  {
811  LWGEOM *sg = g->geoms[i];
812  if (sg->type > maxtype && sg->type < COLLECTIONTYPE)
813  maxtype = sg->type;
814  }
815  if (maxtype > 3) maxtype -= 3;
816  /* Force the working geometry to be a simpler version */
817  /* of itself */
818  gc = lwcollection_extract(g, maxtype);
819  *g = *gc;
820  }
821 }
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
Definition: lwcollection.c:386
uint32_t ngeoms
Definition: liblwgeom.h:509
unsigned int uint32_t
Definition: uthash.h:78
LWGEOM ** geoms
Definition: liblwgeom.h:511
uint8_t type
Definition: liblwgeom.h:398
static uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
Definition: lwinline.h:114
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
Here is the call graph for this function:
Here is the caller graph for this function: