PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ ARRAY2LWGEOM()

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

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

2889 {
2890  ArrayIterator iterator;
2891  Datum value;
2892  bool isnull;
2893  bool gotsrid = false;
2894  uint32_t i = 0;
2895 
2896  LWGEOM** lw_geoms = palloc(nelems * sizeof(LWGEOM*));
2897 
2898  iterator = array_create_iterator(array, 0, NULL);
2899 
2900  while (array_iterate(iterator, &value, &isnull))
2901  {
2902  GSERIALIZED *geom = (GSERIALIZED *)DatumGetPointer(value);
2903 
2904  if (isnull)
2905  continue;
2906 
2907  *is3d = *is3d || gserialized_has_z(geom);
2908 
2909  lw_geoms[i] = lwgeom_from_gserialized(geom);
2910  if (!lw_geoms[i]) /* error in creation */
2911  {
2912  lwpgerror("Geometry deserializing geometry");
2913  return NULL;
2914  }
2915  if (!gotsrid)
2916  {
2917  gotsrid = true;
2918  *srid = gserialized_get_srid(geom);
2919  }
2920  else
2921  gserialized_error_if_srid_mismatch_reference(geom, *srid, __func__);
2922 
2923  i++;
2924  }
2925 
2926  return lw_geoms;
2927 }
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: