PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ ARRAY2GEOS()

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

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

2821 {
2822  ArrayIterator iterator;
2823  Datum value;
2824  bool isnull;
2825  bool gotsrid = false;
2826  uint32_t i = 0;
2827 
2828  GEOSGeometry** geos_geoms = palloc(nelems * sizeof(GEOSGeometry*));
2829 
2830  iterator = array_create_iterator(array, 0, NULL);
2831 
2832  while(array_iterate(iterator, &value, &isnull))
2833  {
2834  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2835 
2836  if (isnull)
2837  continue;
2838 
2839  *is3d = *is3d || gserialized_has_z(geom);
2840 
2841  geos_geoms[i] = POSTGIS2GEOS(geom);
2842  if (!geos_geoms[i])
2843  {
2844  uint32_t j;
2845  lwpgerror("Geometry could not be converted to GEOS");
2846 
2847  for (j = 0; j < i; j++) {
2848  GEOSGeom_destroy(geos_geoms[j]);
2849  }
2850  return NULL;
2851  }
2852 
2853  if (!gotsrid)
2854  {
2855  *srid = gserialized_get_srid(geom);
2856  gotsrid = true;
2857  }
2858  else if (*srid != gserialized_get_srid(geom))
2859  {
2860  uint32_t j;
2861  for (j = 0; j <= i; j++) {
2862  GEOSGeom_destroy(geos_geoms[j]);
2863  }
2864  gserialized_error_if_srid_mismatch_reference(geom, *srid, __func__);
2865  return NULL;
2866  }
2867 
2868  i++;
2869  }
2870 
2871  array_free_iterator(iterator);
2872  return geos_geoms;
2873 }
void gserialized_error_if_srid_mismatch_reference(const GSERIALIZED *g1, const int32_t srid2, const char *funcname)
Definition: gserialized.c:418
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: