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

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

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

Referenced by clusterintersecting_garray(), and polygonize_garray().

3056 {
3057  ArrayIterator iterator;
3058  Datum value;
3059  bool isnull;
3060  bool gotsrid = false;
3061  uint32_t i = 0;
3062 
3063  GEOSGeometry** geos_geoms = palloc(nelems * sizeof(GEOSGeometry*));
3064 
3065 #if POSTGIS_PGSQL_VERSION >= 95
3066  iterator = array_create_iterator(array, 0, NULL);
3067 #else
3068  iterator = array_create_iterator(array, 0);
3069 #endif
3070 
3071  while(array_iterate(iterator, &value, &isnull))
3072  {
3073  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
3074 
3075  if (isnull)
3076  {
3077  continue;
3078  }
3079 
3080  *is3d = *is3d || gserialized_has_z(geom);
3081 
3082  geos_geoms[i] = (GEOSGeometry*) POSTGIS2GEOS(geom);
3083  if (!geos_geoms[i]) /* exception thrown at construction */
3084  {
3085  uint32_t j;
3086  lwpgerror("Geometry could not be converted to GEOS");
3087 
3088  for (j = 0; j < i; j++) {
3089  GEOSGeom_destroy(geos_geoms[j]);
3090  }
3091  return NULL;
3092  }
3093 
3094  if (!gotsrid)
3095  {
3096  *srid = gserialized_get_srid(geom);
3097  gotsrid = true;
3098  }
3099  else if (*srid != gserialized_get_srid(geom))
3100  {
3101  uint32_t j;
3103 
3104  for (j = 0; j <= i; j++) {
3105  GEOSGeom_destroy(geos_geoms[j]);
3106  }
3107  return NULL;
3108  }
3109 
3110  i++;
3111  }
3112 
3113  array_free_iterator(iterator);
3114  return geos_geoms;
3115 }
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:338
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:45
unsigned int uint32_t
Definition: uthash.h:78
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:99

Here is the call graph for this function:

Here is the caller graph for this function: