PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ ARRAY2GEOS()

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

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

2760{
2761 ArrayIterator iterator;
2762 Datum value;
2763 bool isnull;
2764 bool gotsrid = false;
2765 uint32_t i = 0;
2766
2767 GEOSGeometry** geos_geoms = palloc(nelems * sizeof(GEOSGeometry*));
2768
2769 iterator = array_create_iterator(array, 0, NULL);
2770
2771 while(array_iterate(iterator, &value, &isnull))
2772 {
2773 GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2774
2775 if (isnull)
2776 continue;
2777
2778 *is3d = *is3d || gserialized_has_z(geom);
2779
2780 geos_geoms[i] = POSTGIS2GEOS(geom);
2781 if (!geos_geoms[i])
2782 {
2783 uint32_t j;
2784 lwpgerror("Geometry could not be converted to GEOS");
2785
2786 for (j = 0; j < i; j++) {
2787 GEOSGeom_destroy(geos_geoms[j]);
2788 }
2789 return NULL;
2790 }
2791
2792 if (!gotsrid)
2793 {
2794 *srid = gserialized_get_srid(geom);
2795 gotsrid = true;
2796 }
2797 else if (*srid != gserialized_get_srid(geom))
2798 {
2799 uint32_t j;
2800 for (j = 0; j <= i; j++) {
2801 GEOSGeom_destroy(geos_geoms[j]);
2802 }
2803 gserialized_error_if_srid_mismatch_reference(geom, *srid, __func__);
2804 return NULL;
2805 }
2806
2807 i++;
2808 }
2809
2810 array_free_iterator(iterator);
2811 return geos_geoms;
2812}
void gserialized_error_if_srid_mismatch_reference(const GSERIALIZED *g1, const int32_t srid2, const char *funcname)
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)...
int gserialized_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
int value
Definition genraster.py:62
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)

References gserialized_error_if_srid_mismatch_reference(), gserialized_get_srid(), gserialized_has_z(), and POSTGIS2GEOS().

Referenced by clusterintersecting_garray(), and polygonize_garray().

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