PostGIS  2.5.0beta1dev-r@@SVN_REVISION@@

◆ polygonize_garray()

Datum polygonize_garray ( PG_FUNCTION_ARGS  )

Definition at line 2832 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().

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