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

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

2849 {
2850  ArrayIterator iterator;
2851  Datum value;
2852  bool isnull;
2853  bool gotsrid = false;
2854  uint32_t i = 0;
2855 
2856  LWGEOM** lw_geoms = palloc(nelems * sizeof(LWGEOM*));
2857 
2858 #if POSTGIS_PGSQL_VERSION >= 95
2859  iterator = array_create_iterator(array, 0, NULL);
2860 #else
2861  iterator = array_create_iterator(array, 0);
2862 #endif
2863 
2864  while(array_iterate(iterator, &value, &isnull))
2865  {
2866  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2867 
2868  if (isnull)
2869  {
2870  continue;
2871  }
2872 
2873  *is3d = *is3d || gserialized_has_z(geom);
2874 
2875  lw_geoms[i] = lwgeom_from_gserialized(geom);
2876  if (!lw_geoms[i]) /* error in creation */
2877  {
2878  lwpgerror("Geometry deserializing geometry");
2879  return NULL;
2880  }
2881  if (!gotsrid)
2882  {
2883  gotsrid = true;
2884  *srid = gserialized_get_srid(geom);
2885  }
2886  else if (*srid != gserialized_get_srid(geom))
2887  {
2889  return NULL;
2890  }
2891 
2892  i++;
2893  }
2894 
2895  return lw_geoms;
2896 }
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:338
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
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:99

Here is the call graph for this function:

Here is the caller graph for this function: