PostGIS  3.6.1dev-r@@SVN_REVISION@@

◆ polygonize_garray()

Datum polygonize_garray ( PG_FUNCTION_ARGS  )

Definition at line 1977 of file postgis/lwgeom_geos.c.

1978 {
1979  ArrayType *array;
1980  int is3d = 0;
1981  uint32 nelems, i;
1983  GEOSGeometry *geos_result;
1984  const GEOSGeometry **vgeoms;
1985  int32_t srid = SRID_UNKNOWN;
1986 
1987  if (PG_ARGISNULL(0))
1988  PG_RETURN_NULL();
1989 
1990  array = PG_GETARG_ARRAYTYPE_P(0);
1991  nelems = array_nelems_not_null(array);
1992 
1993  if (nelems == 0)
1994  PG_RETURN_NULL();
1995 
1996  POSTGIS_DEBUGF(3, "polygonize_garray: number of non-null elements: %d", nelems);
1997 
1998  /* Ok, we really need geos now ;) */
1999  initGEOS(lwpgnotice, lwgeom_geos_error);
2000 
2001  vgeoms = (const GEOSGeometry**) ARRAY2GEOS(array, nelems, &is3d, &srid);
2002 
2003  POSTGIS_DEBUG(3, "polygonize_garray: invoking GEOSpolygonize");
2004 
2005  geos_result = GEOSPolygonize(vgeoms, nelems);
2006 
2007  POSTGIS_DEBUG(3, "polygonize_garray: GEOSpolygonize returned");
2008 
2009  for (i=0; i<nelems; ++i) GEOSGeom_destroy((GEOSGeometry *)vgeoms[i]);
2010  pfree(vgeoms);
2011 
2012  if ( ! geos_result ) PG_RETURN_NULL();
2013 
2014  GEOSSetSRID(geos_result, srid);
2015  result = GEOS2POSTGIS(geos_result, is3d);
2016  GEOSGeom_destroy(geos_result);
2017  if (!result)
2018  {
2019  elog(ERROR, "%s returned an error", __func__);
2020  PG_RETURN_NULL(); /*never get here */
2021  }
2022 
2023  PG_RETURN_POINTER(result);
2024 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
void lwgeom_geos_error(const char *fmt,...)
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:215
static uint32_t array_nelems_not_null(ArrayType *array)
GSERIALIZED * GEOS2POSTGIS(GEOSGeom geom, char want3d)
GEOSGeometry ** ARRAY2GEOS(ArrayType *array, uint32_t nelems, int *is3d, int *srid)

References ARRAY2GEOS(), array_nelems_not_null(), GEOS2POSTGIS(), lwgeom_geos_error(), result, and SRID_UNKNOWN.

Referenced by pgis_geometry_polygonize_finalfn().

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