PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ ARRAY2LWGEOM()

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

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

2890 {
2891  ArrayIterator iterator;
2892  Datum value;
2893  bool isnull;
2894  bool gotsrid = false;
2895  uint32_t i = 0;
2896 
2897  LWGEOM** lw_geoms = palloc(nelems * sizeof(LWGEOM*));
2898 
2899 #if POSTGIS_PGSQL_VERSION >= 95
2900  iterator = array_create_iterator(array, 0, NULL);
2901 #else
2902  iterator = array_create_iterator(array, 0);
2903 #endif
2904 
2905  while(array_iterate(iterator, &value, &isnull))
2906  {
2907  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2908 
2909  if (isnull)
2910  {
2911  continue;
2912  }
2913 
2914  *is3d = *is3d || gserialized_has_z(geom);
2915 
2916  lw_geoms[i] = lwgeom_from_gserialized(geom);
2917  if (!lw_geoms[i]) /* error in creation */
2918  {
2919  lwpgerror("Geometry deserializing geometry");
2920  return NULL;
2921  }
2922  if (!gotsrid)
2923  {
2924  gotsrid = true;
2925  *srid = gserialized_get_srid(geom);
2926  }
2927  else if (*srid != gserialized_get_srid(geom))
2928  {
2930  return NULL;
2931  }
2932 
2933  i++;
2934  }
2935 
2936  return lw_geoms;
2937 }
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
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:99
Here is the call graph for this function:
Here is the caller graph for this function: