PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ ARRAY2LWGEOM()

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

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

2779 {
2780  ArrayIterator iterator;
2781  Datum value;
2782  bool isnull;
2783  bool gotsrid = false;
2784  uint32_t i = 0;
2785 
2786  LWGEOM** lw_geoms = palloc(nelems * sizeof(LWGEOM*));
2787 
2788  iterator = array_create_iterator(array, 0, NULL);
2789 
2790  while (array_iterate(iterator, &value, &isnull))
2791  {
2792  GSERIALIZED *geom = (GSERIALIZED *)DatumGetPointer(value);
2793 
2794  if (isnull)
2795  continue;
2796 
2797  *is3d = *is3d || gserialized_has_z(geom);
2798 
2799  lw_geoms[i] = lwgeom_from_gserialized(geom);
2800  if (!lw_geoms[i]) /* error in creation */
2801  {
2802  lwpgerror("Geometry deserializing geometry");
2803  return NULL;
2804  }
2805  if (!gotsrid)
2806  {
2807  gotsrid = true;
2808  *srid = gserialized_get_srid(geom);
2809  }
2810  else
2811  gserialized_error_if_srid_mismatch_reference(geom, *srid, __func__);
2812 
2813  i++;
2814  }
2815 
2816  return lw_geoms;
2817 }
void gserialized_error_if_srid_mismatch_reference(const GSERIALIZED *g1, const int32_t srid2, const char *funcname)
Definition: gserialized.c:418
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:126
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
int gserialized_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
Definition: gserialized.c:174
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: