PostGIS  2.5.0dev-r@@SVN_REVISION@@
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 649 of file mvt.c.

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

Referenced by mvt_geom().

650 {
651  if (lwgeom_get_type(geom) == COLLECTIONTYPE)
652  {
653  /* MVT doesn't handle generic collections, so we */
654  /* need to strip them down to a typed collection */
655  /* by finding the largest basic type available and */
656  /* using that as the basis of a typed collection. */
657  LWCOLLECTION *g = (LWCOLLECTION*)geom;
658  uint32_t i, maxtype = 0;
659  for (i = 0; i < g->ngeoms; i++)
660  {
661  LWGEOM *sg = g->geoms[i];
662  if (sg->type > maxtype && sg->type < COLLECTIONTYPE)
663  maxtype = sg->type;
664  }
665  if (maxtype > 3) maxtype -= 3;
666  /* Force the working geometry to be a simpler version */
667  /* of itself */
668  LWCOLLECTION *gc = lwcollection_extract(g, maxtype);
669  *g = *gc;
670  }
671  return;
672 }
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
Definition: lwcollection.c:370
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
Definition: lwgeom.c:916
uint32_t ngeoms
Definition: liblwgeom.h:506
unsigned int uint32_t
Definition: uthash.h:78
LWGEOM ** geoms
Definition: liblwgeom.h:508
uint8_t type
Definition: liblwgeom.h:395
#define COLLECTIONTYPE
Definition: liblwgeom.h:90

Here is the call graph for this function:

Here is the caller graph for this function: