PostGIS  2.2.7dev-r@@SVN_REVISION@@
GEOSGeometry** ARRAY2GEOS ( ArrayType *  array,
uint32_t  nelems,
int *  is3d,
int *  srid 
)

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

References error_if_srid_mismatch(), gserialized_get_srid(), gserialized_has_z(), POSTGIS2GEOS(), and genraster::value.

Referenced by clusterintersecting_garray(), and polygonize_garray().

3289 {
3290  ArrayIterator iterator;
3291  Datum value;
3292  bool isnull;
3293  bool gotsrid = false;
3294  uint32_t i = 0;
3295 
3296  GEOSGeometry** geos_geoms = palloc(nelems * sizeof(GEOSGeometry*));
3297 
3298 #if POSTGIS_PGSQL_VERSION >= 95
3299  iterator = array_create_iterator(array, 0, NULL);
3300 #else
3301  iterator = array_create_iterator(array, 0);
3302 #endif
3303 
3304  while(array_iterate(iterator, &value, &isnull))
3305  {
3306  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
3307 
3308  if (isnull)
3309  {
3310  continue;
3311  }
3312 
3313  *is3d = *is3d || gserialized_has_z(geom);
3314 
3315  geos_geoms[i] = (GEOSGeometry*) POSTGIS2GEOS(geom);
3316  if (!geos_geoms[i]) /* exception thrown at construction */
3317  {
3318  uint32_t j;
3319  lwpgerror("Geometry could not be converted to GEOS");
3320 
3321  for (j = 0; j < i; j++) {
3322  GEOSGeom_destroy(geos_geoms[j]);
3323  }
3324  return NULL;
3325  }
3326 
3327  if (!gotsrid)
3328  {
3329  *srid = gserialized_get_srid(geom);
3330  gotsrid = true;
3331  }
3332  else if (*srid != gserialized_get_srid(geom))
3333  {
3334  uint32_t j;
3336 
3337  for (j = 0; j <= i; j++) {
3338  GEOSGeom_destroy(geos_geoms[j]);
3339  }
3340  return NULL;
3341  }
3342 
3343  i++;
3344  }
3345 
3346  array_free_iterator(iterator);
3347  return geos_geoms;
3348 }
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:341
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:24
LWGEOM * geom
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: g_serialized.c:69

Here is the call graph for this function:

Here is the caller graph for this function: