PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ ARRAY2GEOS()

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

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

2849 {
2850  ArrayIterator iterator;
2851  Datum value;
2852  bool isnull;
2853  bool gotsrid = false;
2854  uint32_t i = 0;
2855 
2856  GEOSGeometry** geos_geoms = palloc(nelems * sizeof(GEOSGeometry*));
2857 
2858  iterator = array_create_iterator(array, 0, NULL);
2859 
2860  while(array_iterate(iterator, &value, &isnull))
2861  {
2862  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2863 
2864  if (isnull)
2865  continue;
2866 
2867  *is3d = *is3d || gserialized_has_z(geom);
2868 
2869  geos_geoms[i] = POSTGIS2GEOS(geom);
2870  if (!geos_geoms[i])
2871  {
2872  uint32_t j;
2873  lwpgerror("Geometry could not be converted to GEOS");
2874 
2875  for (j = 0; j < i; j++) {
2876  GEOSGeom_destroy(geos_geoms[j]);
2877  }
2878  return NULL;
2879  }
2880 
2881  if (!gotsrid)
2882  {
2883  *srid = gserialized_get_srid(geom);
2884  gotsrid = true;
2885  }
2886  else if (*srid != gserialized_get_srid(geom))
2887  {
2888  uint32_t j;
2889  for (j = 0; j <= i; j++) {
2890  GEOSGeom_destroy(geos_geoms[j]);
2891  }
2892  gserialized_error_if_srid_mismatch_reference(geom, *srid, __func__);
2893  return NULL;
2894  }
2895 
2896  i++;
2897  }
2898 
2899  array_free_iterator(iterator);
2900  return geos_geoms;
2901 }
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: