PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ ARRAY2LWGEOM()

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

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

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

References gserialized_error_if_srid_mismatch_reference(), gserialized_get_srid(), gserialized_has_z(), lwgeom_from_gserialized(), and genraster::value.

Referenced by cluster_within_distance_garray().

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