PostGIS  2.5.0dev-r@@SVN_REVISION@@
Datum polygonize_garray ( PG_FUNCTION_ARGS  )

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

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

Referenced by pgis_geometry_polygonize_finalfn().

2984 {
2985  ArrayType *array;
2986  int is3d = 0;
2987  uint32 nelems, i;
2988  GSERIALIZED *result;
2989  GEOSGeometry *geos_result;
2990  const GEOSGeometry **vgeoms;
2991  int srid=SRID_UNKNOWN;
2992 #if POSTGIS_DEBUG_LEVEL >= 3
2993  static int call=1;
2994 #endif
2995 
2996 #if POSTGIS_DEBUG_LEVEL >= 3
2997  call++;
2998 #endif
2999 
3000  if (PG_ARGISNULL(0))
3001  PG_RETURN_NULL();
3002 
3003  array = PG_GETARG_ARRAYTYPE_P(0);
3004  nelems = array_nelems_not_null(array);
3005 
3006  if (nelems == 0)
3007  PG_RETURN_NULL();
3008 
3009  POSTGIS_DEBUGF(3, "polygonize_garray: number of non-null elements: %d", nelems);
3010 
3011  /* Ok, we really need geos now ;) */
3012  initGEOS(lwpgnotice, lwgeom_geos_error);
3013 
3014  vgeoms = (const GEOSGeometry**) ARRAY2GEOS(array, nelems, &is3d, &srid);
3015 
3016  POSTGIS_DEBUG(3, "polygonize_garray: invoking GEOSpolygonize");
3017 
3018  geos_result = GEOSPolygonize(vgeoms, nelems);
3019 
3020  POSTGIS_DEBUG(3, "polygonize_garray: GEOSpolygonize returned");
3021 
3022  for (i=0; i<nelems; ++i) GEOSGeom_destroy((GEOSGeometry *)vgeoms[i]);
3023  pfree(vgeoms);
3024 
3025  if ( ! geos_result ) PG_RETURN_NULL();
3026 
3027  GEOSSetSRID(geos_result, srid);
3028  result = GEOS2POSTGIS(geos_result, is3d);
3029  GEOSGeom_destroy(geos_result);
3030  if (!result)
3031  {
3032  elog(ERROR, "%s returned an error", __func__);
3033  PG_RETURN_NULL(); /*never get here */
3034  }
3035 
3036  PG_RETURN_POINTER(result);
3037 }
GEOSGeometry ** ARRAY2GEOS(ArrayType *array, uint32_t nelems, int *is3d, int *srid)
uint32_t array_nelems_not_null(ArrayType *array)
void lwgeom_geos_error(const char *fmt,...)
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:187
GSERIALIZED * GEOS2POSTGIS(GEOSGeom geom, char want3d)

Here is the call graph for this function:

Here is the caller graph for this function: