PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ ARRAY2GEOS()

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

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

2746 {
2747  ArrayIterator iterator;
2748  Datum value;
2749  bool isnull;
2750  bool gotsrid = false;
2751  uint32_t i = 0;
2752 
2753  GEOSGeometry** geos_geoms = palloc(nelems * sizeof(GEOSGeometry*));
2754 
2755 #if POSTGIS_PGSQL_VERSION >= 95
2756  iterator = array_create_iterator(array, 0, NULL);
2757 #else
2758  iterator = array_create_iterator(array, 0);
2759 #endif
2760 
2761  while(array_iterate(iterator, &value, &isnull))
2762  {
2763  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2764 
2765  if (isnull)
2766  {
2767  continue;
2768  }
2769 
2770  *is3d = *is3d || gserialized_has_z(geom);
2771 
2772  geos_geoms[i] = POSTGIS2GEOS(geom);
2773  if (!geos_geoms[i])
2774  {
2775  uint32_t j;
2776  lwpgerror("Geometry could not be converted to GEOS");
2777 
2778  for (j = 0; j < i; j++) {
2779  GEOSGeom_destroy(geos_geoms[j]);
2780  }
2781  return NULL;
2782  }
2783 
2784  if (!gotsrid)
2785  {
2786  *srid = gserialized_get_srid(geom);
2787  gotsrid = true;
2788  }
2789  else if (*srid != gserialized_get_srid(geom))
2790  {
2791  uint32_t j;
2793 
2794  for (j = 0; j <= i; j++) {
2795  GEOSGeom_destroy(geos_geoms[j]);
2796  }
2797  return NULL;
2798  }
2799 
2800  i++;
2801  }
2802 
2803  array_free_iterator(iterator);
2804  return geos_geoms;
2805 }
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:100
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:45
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:338
int value
Definition: genraster.py:61
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)
unsigned int uint32_t
Definition: uthash.h:78

References error_if_srid_mismatch(), 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: