PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ ARRAY2GEOS()

GEOSGeometry** ARRAY2GEOS ( ArrayType *  array,
uint32_t  nelems,
int *  is3d,
int *  srid 
)

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

2918 {
2919  ArrayIterator iterator;
2920  Datum value;
2921  bool isnull;
2922  bool gotsrid = false;
2923  uint32_t i = 0;
2924 
2925  GEOSGeometry** geos_geoms = palloc(nelems * sizeof(GEOSGeometry*));
2926 
2927  iterator = array_create_iterator(array, 0, NULL);
2928 
2929  while(array_iterate(iterator, &value, &isnull))
2930  {
2931  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2932 
2933  if (isnull)
2934  continue;
2935 
2936  *is3d = *is3d || gserialized_has_z(geom);
2937 
2938  geos_geoms[i] = POSTGIS2GEOS(geom);
2939  if (!geos_geoms[i])
2940  {
2941  uint32_t j;
2942  lwpgerror("Geometry could not be converted to GEOS");
2943 
2944  for (j = 0; j < i; j++) {
2945  GEOSGeom_destroy(geos_geoms[j]);
2946  }
2947  return NULL;
2948  }
2949 
2950  if (!gotsrid)
2951  {
2952  *srid = gserialized_get_srid(geom);
2953  gotsrid = true;
2954  }
2955  else if (*srid != gserialized_get_srid(geom))
2956  {
2957  uint32_t j;
2958  for (j = 0; j <= i; j++) {
2959  GEOSGeom_destroy(geos_geoms[j]);
2960  }
2961  gserialized_error_if_srid_mismatch_reference(geom, *srid, __func__);
2962  return NULL;
2963  }
2964 
2965  i++;
2966  }
2967 
2968  array_free_iterator(iterator);
2969  return geos_geoms;
2970 }
void gserialized_error_if_srid_mismatch_reference(const GSERIALIZED *g1, const int32_t srid2, const char *funcname)
Definition: gserialized.c:419
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: gserialized.c:126
int gserialized_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
Definition: gserialized.c:174
int value
Definition: genraster.py:62
GEOSGeometry * POSTGIS2GEOS(const GSERIALIZED *pglwgeom)

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

Referenced by clusterintersecting_garray(), and polygonize_garray().

Here is the call graph for this function:
Here is the caller graph for this function: