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

◆ ARRAY2LWGEOM()

LWGEOM ** ARRAY2LWGEOM ( ArrayType *  array,
uint32_t  nelems,
int *  is3d,
int *  srid 
)

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

1859{
1860 ArrayIterator iterator;
1861 Datum value;
1862 bool isnull;
1863 bool gotsrid = false;
1864 uint32_t i = 0;
1865
1866 LWGEOM** lw_geoms = palloc(nelems * sizeof(LWGEOM*));
1867
1868 iterator = array_create_iterator(array, 0, NULL);
1869
1870 while (array_iterate(iterator, &value, &isnull))
1871 {
1872 GSERIALIZED *geom = (GSERIALIZED *)DatumGetPointer(value);
1873
1874 if (isnull)
1875 continue;
1876
1877 *is3d = *is3d || gserialized_has_z(geom);
1878
1879 lw_geoms[i] = lwgeom_from_gserialized(geom);
1880 if (!lw_geoms[i]) /* error in creation */
1881 {
1882 lwpgerror("Geometry deserializing geometry");
1883 return NULL;
1884 }
1885 if (!gotsrid)
1886 {
1887 gotsrid = true;
1888 *srid = gserialized_get_srid(geom);
1889 }
1890 else
1891 gserialized_error_if_srid_mismatch_reference(geom, *srid, __func__);
1892
1893 i++;
1894 }
1895
1896 return lw_geoms;
1897}
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)...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
int value
Definition genraster.py:62

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

Referenced by cluster_within_distance_garray().

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