PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ polygonize_garray()

Datum polygonize_garray ( PG_FUNCTION_ARGS  )

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

2830 {
2831  ArrayType *array;
2832  int is3d = 0;
2833  uint32 nelems, i;
2834  GSERIALIZED *result;
2835  GEOSGeometry *geos_result;
2836  const GEOSGeometry **vgeoms;
2837  int srid=SRID_UNKNOWN;
2838 #if POSTGIS_DEBUG_LEVEL >= 3
2839  static int call=1;
2840 #endif
2841 
2842 #if POSTGIS_DEBUG_LEVEL >= 3
2843  call++;
2844 #endif
2845 
2846  if (PG_ARGISNULL(0))
2847  PG_RETURN_NULL();
2848 
2849  array = PG_GETARG_ARRAYTYPE_P(0);
2850  nelems = array_nelems_not_null(array);
2851 
2852  if (nelems == 0)
2853  PG_RETURN_NULL();
2854 
2855  POSTGIS_DEBUGF(3, "polygonize_garray: number of non-null elements: %d", nelems);
2856 
2857  /* Ok, we really need geos now ;) */
2858  initGEOS(lwpgnotice, lwgeom_geos_error);
2859 
2860  vgeoms = (const GEOSGeometry**) ARRAY2GEOS(array, nelems, &is3d, &srid);
2861 
2862  POSTGIS_DEBUG(3, "polygonize_garray: invoking GEOSpolygonize");
2863 
2864  geos_result = GEOSPolygonize(vgeoms, nelems);
2865 
2866  POSTGIS_DEBUG(3, "polygonize_garray: GEOSpolygonize returned");
2867 
2868  for (i=0; i<nelems; ++i) GEOSGeom_destroy((GEOSGeometry *)vgeoms[i]);
2869  pfree(vgeoms);
2870 
2871  if ( ! geos_result ) PG_RETURN_NULL();
2872 
2873  GEOSSetSRID(geos_result, srid);
2874  result = GEOS2POSTGIS(geos_result, is3d);
2875  GEOSGeom_destroy(geos_result);
2876  if (!result)
2877  {
2878  elog(ERROR, "%s returned an error", __func__);
2879  PG_RETURN_NULL(); /*never get here */
2880  }
2881 
2882  PG_RETURN_POINTER(result);
2883 }
void lwgeom_geos_error(const char *fmt,...)
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
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(), 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: