PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ polygonize_garray()

Datum polygonize_garray ( PG_FUNCTION_ARGS  )

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

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

Referenced by GEOSnoop(), pgis_abs_out(), and pgis_geometry_polygonize_finalfn().

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