PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ polygonize_garray()

Datum polygonize_garray ( PG_FUNCTION_ARGS  )

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

1977 {
1978  ArrayType *array;
1979  int is3d = 0;
1980  uint32 nelems, i;
1982  GEOSGeometry *geos_result;
1983  const GEOSGeometry **vgeoms;
1984  int32_t srid = SRID_UNKNOWN;
1985 
1986  if (PG_ARGISNULL(0))
1987  PG_RETURN_NULL();
1988 
1989  array = PG_GETARG_ARRAYTYPE_P(0);
1990  nelems = array_nelems_not_null(array);
1991 
1992  if (nelems == 0)
1993  PG_RETURN_NULL();
1994 
1995  POSTGIS_DEBUGF(3, "polygonize_garray: number of non-null elements: %d", nelems);
1996 
1997  /* Ok, we really need geos now ;) */
1998  initGEOS(lwpgnotice, lwgeom_geos_error);
1999 
2000  vgeoms = (const GEOSGeometry**) ARRAY2GEOS(array, nelems, &is3d, &srid);
2001 
2002  POSTGIS_DEBUG(3, "polygonize_garray: invoking GEOSpolygonize");
2003 
2004  geos_result = GEOSPolygonize(vgeoms, nelems);
2005 
2006  POSTGIS_DEBUG(3, "polygonize_garray: GEOSpolygonize returned");
2007 
2008  for (i=0; i<nelems; ++i) GEOSGeom_destroy((GEOSGeometry *)vgeoms[i]);
2009  pfree(vgeoms);
2010 
2011  if ( ! geos_result ) PG_RETURN_NULL();
2012 
2013  GEOSSetSRID(geos_result, srid);
2014  result = GEOS2POSTGIS(geos_result, is3d);
2015  GEOSGeom_destroy(geos_result);
2016  if (!result)
2017  {
2018  elog(ERROR, "%s returned an error", __func__);
2019  PG_RETURN_NULL(); /*never get here */
2020  }
2021 
2022  PG_RETURN_POINTER(result);
2023 }
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: