PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ ARRAY2LWGEOM()

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

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

2698 {
2699  ArrayIterator iterator;
2700  Datum value;
2701  bool isnull;
2702  bool gotsrid = false;
2703  uint32_t i = 0;
2704 
2705  LWGEOM** lw_geoms = palloc(nelems * sizeof(LWGEOM*));
2706 
2707 #if POSTGIS_PGSQL_VERSION >= 95
2708  iterator = array_create_iterator(array, 0, NULL);
2709 #else
2710  iterator = array_create_iterator(array, 0);
2711 #endif
2712 
2713  while(array_iterate(iterator, &value, &isnull))
2714  {
2715  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2716 
2717  if (isnull)
2718  {
2719  continue;
2720  }
2721 
2722  *is3d = *is3d || gserialized_has_z(geom);
2723 
2724  lw_geoms[i] = lwgeom_from_gserialized(geom);
2725  if (!lw_geoms[i]) /* error in creation */
2726  {
2727  lwpgerror("Geometry deserializing geometry");
2728  return NULL;
2729  }
2730  if (!gotsrid)
2731  {
2732  gotsrid = true;
2733  *srid = gserialized_get_srid(geom);
2734  }
2735  else if (*srid != gserialized_get_srid(geom))
2736  {
2738  return NULL;
2739  }
2740 
2741  i++;
2742  }
2743 
2744  return lw_geoms;
2745 }
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: