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

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

2900 {
2901  ArrayIterator iterator;
2902  Datum value;
2903  bool isnull;
2904  bool gotsrid = false;
2905  uint32_t i = 0;
2906 
2907  GEOSGeometry** geos_geoms = palloc(nelems * sizeof(GEOSGeometry*));
2908 
2909 #if POSTGIS_PGSQL_VERSION >= 95
2910  iterator = array_create_iterator(array, 0, NULL);
2911 #else
2912  iterator = array_create_iterator(array, 0);
2913 #endif
2914 
2915  while(array_iterate(iterator, &value, &isnull))
2916  {
2917  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2918 
2919  if (isnull)
2920  {
2921  continue;
2922  }
2923 
2924  *is3d = *is3d || gserialized_has_z(geom);
2925 
2926  geos_geoms[i] = (GEOSGeometry*) POSTGIS2GEOS(geom);
2927  if (!geos_geoms[i])
2928  {
2929  uint32_t j;
2930  lwpgerror("Geometry could not be converted to GEOS");
2931 
2932  for (j = 0; j < i; j++) {
2933  GEOSGeom_destroy(geos_geoms[j]);
2934  }
2935  return NULL;
2936  }
2937 
2938  if (!gotsrid)
2939  {
2940  *srid = gserialized_get_srid(geom);
2941  gotsrid = true;
2942  }
2943  else if (*srid != gserialized_get_srid(geom))
2944  {
2945  uint32_t j;
2947 
2948  for (j = 0; j <= i; j++) {
2949  GEOSGeom_destroy(geos_geoms[j]);
2950  }
2951  return NULL;
2952  }
2953 
2954  i++;
2955  }
2956 
2957  array_free_iterator(iterator);
2958  return geos_geoms;
2959 }
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: