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

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

2978 {
2979  ArrayIterator iterator;
2980  Datum value;
2981  bool isnull;
2982  bool gotsrid = false;
2983  uint32_t i = 0;
2984 
2985  GEOSGeometry** geos_geoms = palloc(nelems * sizeof(GEOSGeometry*));
2986 
2987 #if POSTGIS_PGSQL_VERSION >= 95
2988  iterator = array_create_iterator(array, 0, NULL);
2989 #else
2990  iterator = array_create_iterator(array, 0);
2991 #endif
2992 
2993  while(array_iterate(iterator, &value, &isnull))
2994  {
2995  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2996 
2997  if (isnull)
2998  {
2999  continue;
3000  }
3001 
3002  *is3d = *is3d || gserialized_has_z(geom);
3003 
3004  geos_geoms[i] = (GEOSGeometry*) POSTGIS2GEOS(geom);
3005  if (!geos_geoms[i]) /* exception thrown at construction */
3006  {
3007  uint32_t j;
3008  lwpgerror("Geometry could not be converted to GEOS");
3009 
3010  for (j = 0; j < i; j++) {
3011  GEOSGeom_destroy(geos_geoms[j]);
3012  }
3013  return NULL;
3014  }
3015 
3016  if (!gotsrid)
3017  {
3018  *srid = gserialized_get_srid(geom);
3019  gotsrid = true;
3020  }
3021  else if (*srid != gserialized_get_srid(geom))
3022  {
3023  uint32_t j;
3025 
3026  for (j = 0; j <= i; j++) {
3027  GEOSGeom_destroy(geos_geoms[j]);
3028  }
3029  return NULL;
3030  }
3031 
3032  i++;
3033  }
3034 
3035  array_free_iterator(iterator);
3036  return geos_geoms;
3037 }
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:369
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:38
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:83

Here is the call graph for this function:

Here is the caller graph for this function: