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

◆ ARRAY2GEOS()

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

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

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