2029{
2030 Datum* result_array_data;
2031 ArrayType *array, *
result;
2032 int is3d = 0;
2033 uint32 nelems, nclusters, i;
2034 GEOSGeometry **geos_inputs, **geos_results;
2036
2037
2038 int16 elmlen;
2039 bool elmbyval;
2040 char elmalign;
2041
2042
2043 if (PG_ARGISNULL(0))
2044 PG_RETURN_NULL();
2045
2046 array = PG_GETARG_ARRAYTYPE_P(0);
2048
2049 POSTGIS_DEBUGF(3, "clusterintersecting_garray: number of non-null elements: %d", nelems);
2050
2051 if ( nelems == 0 ) PG_RETURN_NULL();
2052
2053
2054
2055
2057
2058 geos_inputs =
ARRAY2GEOS(array, nelems, &is3d, &srid);
2059 if(!geos_inputs)
2060 {
2061 PG_RETURN_NULL();
2062 }
2063
2065 {
2066 elog(ERROR, "clusterintersecting: Error performing clustering");
2067 PG_RETURN_NULL();
2068 }
2069 pfree(geos_inputs);
2070
2071 if (!geos_results) PG_RETURN_NULL();
2072
2073 result_array_data = palloc(nclusters * sizeof(Datum));
2074 for (i=0; i<nclusters; ++i)
2075 {
2076 result_array_data[i] = PointerGetDatum(
GEOS2POSTGIS(geos_results[i], is3d));
2077 GEOSGeom_destroy(geos_results[i]);
2078 }
2080
2081 get_typlenbyvalalign(array->elemtype, &elmlen, &elmbyval, &elmalign);
2082 result = construct_array(result_array_data, nclusters, array->elemtype, elmlen, elmbyval, elmalign);
2083
2085 {
2086 elog(ERROR, "clusterintersecting: Error constructing return-array");
2087 PG_RETURN_NULL();
2088 }
2089
2090 PG_RETURN_POINTER(
result);
2091}
char result[OUT_DOUBLE_BUFFER_SIZE]
void lwgeom_geos_error(const char *fmt,...)
int cluster_intersecting(GEOSGeometry **geoms, uint32_t num_geoms, GEOSGeometry ***clusterGeoms, uint32_t *num_clusters)
Takes an array of GEOSGeometry* and constructs an array of GEOSGeometry*, where each element in the c...
#define SRID_UNKNOWN
Unknown SRID value.
GSERIALIZED * GEOS2POSTGIS(GEOSGeom geom, char want3d)
static uint32_t array_nelems_not_null(ArrayType *array)
GEOSGeometry ** ARRAY2GEOS(ArrayType *array, uint32_t nelems, int *is3d, int *srid)