PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ polygonize_garray()

Datum polygonize_garray ( PG_FUNCTION_ARGS  )

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

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