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

Definition at line 2926 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().

2927 {
2928  ArrayIterator iterator;
2929  Datum value;
2930  bool isnull;
2931  bool gotsrid = false;
2932  uint32_t i = 0;
2933 
2934  LWGEOM** lw_geoms = palloc(nelems * sizeof(LWGEOM*));
2935 
2936 #if POSTGIS_PGSQL_VERSION >= 95
2937  iterator = array_create_iterator(array, 0, NULL);
2938 #else
2939  iterator = array_create_iterator(array, 0);
2940 #endif
2941 
2942  while(array_iterate(iterator, &value, &isnull))
2943  {
2944  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2945 
2946  if (isnull)
2947  {
2948  continue;
2949  }
2950 
2951  *is3d = *is3d || gserialized_has_z(geom);
2952 
2953  lw_geoms[i] = lwgeom_from_gserialized(geom);
2954  if (!lw_geoms[i]) /* error in creation */
2955  {
2956  lwpgerror("Geometry deserializing geometry");
2957  return NULL;
2958  }
2959  if (!gotsrid)
2960  {
2961  gotsrid = true;
2962  *srid = gserialized_get_srid(geom);
2963  }
2964  else if (*srid != gserialized_get_srid(geom))
2965  {
2967  return NULL;
2968  }
2969 
2970  i++;
2971  }
2972 
2973  return lw_geoms;
2974 }
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:369
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:38
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:83

Here is the call graph for this function:

Here is the caller graph for this function: