PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ ARRAY2GEOS()

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

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

1900 {
1901  ArrayIterator iterator;
1902  Datum value;
1903  bool isnull;
1904  bool gotsrid = false;
1905  uint32_t i = 0;
1906 
1907  GEOSGeometry** geos_geoms = palloc(nelems * sizeof(GEOSGeometry*));
1908 
1909  iterator = array_create_iterator(array, 0, NULL);
1910 
1911  while(array_iterate(iterator, &value, &isnull))
1912  {
1913  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
1914 
1915  if (isnull)
1916  continue;
1917 
1918  *is3d = *is3d || gserialized_has_z(geom);
1919 
1920  geos_geoms[i] = POSTGIS2GEOS(geom);
1921  if (!geos_geoms[i])
1922  {
1923  uint32_t j;
1924  lwpgerror("Geometry could not be converted to GEOS");
1925 
1926  for (j = 0; j < i; j++) {
1927  GEOSGeom_destroy(geos_geoms[j]);
1928  }
1929  return NULL;
1930  }
1931 
1932  if (!gotsrid)
1933  {
1934  *srid = gserialized_get_srid(geom);
1935  gotsrid = true;
1936  }
1937  else if (*srid != gserialized_get_srid(geom))
1938  {
1939  uint32_t j;
1940  for (j = 0; j <= i; j++) {
1941  GEOSGeom_destroy(geos_geoms[j]);
1942  }
1943  gserialized_error_if_srid_mismatch_reference(geom, *srid, __func__);
1944  return NULL;
1945  }
1946 
1947  i++;
1948  }
1949 
1950  array_free_iterator(iterator);
1951  return geos_geoms;
1952 }
void gserialized_error_if_srid_mismatch_reference(const GSERIALIZED *g1, const int32_t srid2, const char *funcname)
Definition: gserialized.c:447
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:155
int gserialized_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
Definition: gserialized.c:203
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: