PostGIS  2.2.7dev-r@@SVN_REVISION@@
LWGEOM** ARRAY2LWGEOM ( ArrayType *  array,
uint32_t  nelems,
int *  is3d,
int *  srid 
)

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

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

Referenced by cluster_within_distance_garray().

3238 {
3239  ArrayIterator iterator;
3240  Datum value;
3241  bool isnull;
3242  bool gotsrid = false;
3243  uint32_t i = 0;
3244 
3245  LWGEOM** lw_geoms = palloc(nelems * sizeof(LWGEOM*));
3246 
3247 #if POSTGIS_PGSQL_VERSION >= 95
3248  iterator = array_create_iterator(array, 0, NULL);
3249 #else
3250  iterator = array_create_iterator(array, 0);
3251 #endif
3252 
3253  while(array_iterate(iterator, &value, &isnull))
3254  {
3255  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
3256 
3257  if (isnull)
3258  {
3259  continue;
3260  }
3261 
3262  *is3d = *is3d || gserialized_has_z(geom);
3263 
3264  lw_geoms[i] = lwgeom_from_gserialized(geom);
3265  if (!lw_geoms[i]) /* error in creation */
3266  {
3267  lwpgerror("Geometry deserializing geometry");
3268  return NULL;
3269  }
3270  if (!gotsrid)
3271  {
3272  gotsrid = true;
3273  *srid = gserialized_get_srid(geom);
3274  }
3275  else if (*srid != gserialized_get_srid(geom))
3276  {
3278  return NULL;
3279  }
3280 
3281  i++;
3282  }
3283 
3284  return lw_geoms;
3285 }
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:341
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:24
LWGEOM * geom
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:69

Here is the call graph for this function:

Here is the caller graph for this function: