PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwtin_from_geos()

LWTIN * lwtin_from_geos ( const GEOSGeometry *  geom,
uint8_t  want3d 
)

Definition at line 1720 of file liblwgeom/lwgeom_geos.c.

1721 {
1722  int type = GEOSGeomTypeId(geom);
1723  int SRID = GEOSGetSRID(geom);
1724 
1725  /* GEOS's 0 is equivalent to our unknown as for SRID values */
1726  if (SRID == 0) SRID = SRID_UNKNOWN;
1727 
1728  if (want3d && !GEOSHasZ(geom))
1729  {
1730  LWDEBUG(3, "Geometry has no Z, won't provide one");
1731  want3d = 0;
1732  }
1733 
1734  switch (type)
1735  {
1736  LWTRIANGLE** geoms;
1737  uint32_t i, ngeoms;
1738  case GEOS_GEOMETRYCOLLECTION:
1739  LWDEBUG(4, "lwgeom_from_geometry: it's a Collection or Multi");
1740 
1741  ngeoms = GEOSGetNumGeometries(geom);
1742  geoms = NULL;
1743  if (ngeoms)
1744  {
1745  geoms = lwalloc(ngeoms * sizeof *geoms);
1746  if (!geoms)
1747  {
1748  lwerror("lwtin_from_geos: can't allocate geoms");
1749  return NULL;
1750  }
1751  for (i = 0; i < ngeoms; i++)
1752  {
1753  const GEOSGeometry *poly, *ring;
1754  const GEOSCoordSequence* cs;
1755  POINTARRAY* pa;
1756 
1757  poly = GEOSGetGeometryN(geom, i);
1758  ring = GEOSGetExteriorRing(poly);
1759  cs = GEOSGeom_getCoordSeq(ring);
1760  pa = ptarray_from_GEOSCoordSeq(cs, want3d);
1761 
1762  geoms[i] = lwtriangle_construct(SRID, NULL, pa);
1763  }
1764  }
1765  return (LWTIN*)lwcollection_construct(TINTYPE, SRID, NULL, ngeoms, (LWGEOM**)geoms);
1766  case GEOS_POLYGON:
1767  case GEOS_MULTIPOINT:
1768  case GEOS_MULTILINESTRING:
1769  case GEOS_MULTIPOLYGON:
1770  case GEOS_LINESTRING:
1771  case GEOS_LINEARRING:
1772  case GEOS_POINT:
1773  lwerror("lwtin_from_geos: invalid geometry type for tin: %d", type);
1774  break;
1775 
1776  default:
1777  lwerror("GEOS2LWGEOM: unknown geometry type: %d", type);
1778  return NULL;
1779  }
1780 
1781  /* shouldn't get here */
1782  return NULL;
1783 }
POINTARRAY * ptarray_from_GEOSCoordSeq(const GEOSCoordSequence *cs, uint8_t want3d)
#define TINTYPE
Definition: liblwgeom.h:99
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:40
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
type
Definition: ovdump.py:41
unsigned int uint32_t
Definition: uthash.h:78

References lwalloc(), lwcollection_construct(), LWDEBUG, lwerror(), lwtriangle_construct(), ptarray_from_GEOSCoordSeq(), SRID_UNKNOWN, TINTYPE, and ovdump::type.

Referenced by lwgeom_delaunay_triangulation().

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