PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ polygonize_garray()

Datum polygonize_garray ( PG_FUNCTION_ARGS  )

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

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