From: Sandro Santilli Date: Tue, 14 Dec 2004 09:47:00 +0000 (+0000) Subject: Added SRID check in collect_garray(); X-Git-Tag: pgis_1_0_0RC1~158 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b84efd6501efbcdf32ab1f34bdd26dfcc14ce69;p=postgis Added SRID check in collect_garray(); git-svn-id: http://svn.osgeo.org/postgis/trunk@1142 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/lwgeom/lwgeom_functions_basic.c b/lwgeom/lwgeom_functions_basic.c index e474d4a61..b69b70227 100644 --- a/lwgeom/lwgeom_functions_basic.c +++ b/lwgeom/lwgeom_functions_basic.c @@ -1740,6 +1740,7 @@ Datum LWGEOM_collect_garray(PG_FUNCTION_ARGS) size_t size; unsigned int outtype; int i; + int SRID; #ifdef DEBUG elog(NOTICE, "LWGEOM_collect_garray called"); @@ -1775,6 +1776,9 @@ Datum LWGEOM_collect_garray(PG_FUNCTION_ARGS) /* Get pointer to GEOMETRY pointers array */ geoms = (PG_LWGEOM **)ARR_DATA_PTR(array); + /* Get first geometry SRID */ + SRID = lwgeom_getSRID(geoms[0]); + /* * Deserialize all geometries in array into the lwgeoms pointers * array. Check input types to form output type. @@ -1786,6 +1790,19 @@ Datum LWGEOM_collect_garray(PG_FUNCTION_ARGS) unsigned int intype = TYPE_GETTYPE(geoms[i]->type); lwgeoms[i] = lwgeom_deserialize(SERIALIZED_FORM(geoms[i])); + // Check SRID homogeneity + if ( i ) { + if ( lwgeoms[i]->SRID != SRID ) + { + elog(ERROR, + "Operation on mixed SRID geometries"); + PG_RETURN_NULL(); + } + } + + lwgeom_dropSRID(lwgeoms[i]); + lwgeom_dropBBOX(lwgeoms[i]); + // Output type not initialized if ( ! outtype ) { // Input is single, make multi @@ -1804,8 +1821,7 @@ Datum LWGEOM_collect_garray(PG_FUNCTION_ARGS) } outlwg = (LWGEOM *)lwcollection_construct( - outtype, - lwgeom_getSRID(geoms[0]), + outtype, SRID, NULL, nelems, lwgeoms); size = lwgeom_serialize_size(outlwg);