PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ARRAY2LWGEOM()

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

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

References error_if_srid_mismatch(), dumpnode::geom, gserialized_get_srid(), gserialized_has_z(), lwgeom_from_gserialized(), and genraster::value.

Referenced by cluster_within_distance_garray().

2998 {
2999  ArrayIterator iterator;
3000  Datum value;
3001  bool isnull;
3002  bool gotsrid = false;
3003  uint32_t i = 0;
3004 
3005  LWGEOM** lw_geoms = palloc(nelems * sizeof(LWGEOM*));
3006 
3007 #if POSTGIS_PGSQL_VERSION >= 95
3008  iterator = array_create_iterator(array, 0, NULL);
3009 #else
3010  iterator = array_create_iterator(array, 0);
3011 #endif
3012 
3013  while(array_iterate(iterator, &value, &isnull))
3014  {
3015  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
3016 
3017  if (isnull)
3018  {
3019  continue;
3020  }
3021 
3022  *is3d = *is3d || gserialized_has_z(geom);
3023 
3024  lw_geoms[i] = lwgeom_from_gserialized(geom);
3025  if (!lw_geoms[i]) /* error in creation */
3026  {
3027  lwpgerror("Geometry deserializing geometry");
3028  return NULL;
3029  }
3030  if (!gotsrid)
3031  {
3032  gotsrid = true;
3033  *srid = gserialized_get_srid(geom);
3034  }
3035  else if (*srid != gserialized_get_srid(geom))
3036  {
3038  return NULL;
3039  }
3040 
3041  i++;
3042  }
3043 
3044  return lw_geoms;
3045 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:371
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:45
unsigned int uint32_t
Definition: uthash.h:78
LWGEOM * geom
int value
Definition: genraster.py:61
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: g_serialized.c:100
Here is the call graph for this function:
Here is the caller graph for this function: