PostGIS  2.5.0beta1dev-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 658 of file mvt.c.

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

Referenced by mvt_geom().

659 {
660  if (lwgeom_get_type(geom) == COLLECTIONTYPE)
661  {
662  /* MVT doesn't handle generic collections, so we */
663  /* need to strip them down to a typed collection */
664  /* by finding the largest basic type available and */
665  /* using that as the basis of a typed collection. */
666  LWCOLLECTION *g = (LWCOLLECTION*)geom;
667  LWCOLLECTION *gc;
668  uint32_t i, maxtype = 0;
669  for (i = 0; i < g->ngeoms; i++)
670  {
671  LWGEOM *sg = g->geoms[i];
672  if (sg->type > maxtype && sg->type < COLLECTIONTYPE)
673  maxtype = sg->type;
674  }
675  if (maxtype > 3) maxtype -= 3;
676  /* Force the working geometry to be a simpler version */
677  /* of itself */
678  gc = lwcollection_extract(g, maxtype);
679  *g = *gc;
680  }
681  return;
682 }
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 lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
Definition: lwgeom.c:923
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
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
Here is the call graph for this function:
Here is the caller graph for this function: