PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ ARRAY2LWGEOM()

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

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

2695 {
2696  ArrayIterator iterator;
2697  Datum value;
2698  bool isnull;
2699  bool gotsrid = false;
2700  uint32_t i = 0;
2701 
2702  LWGEOM** lw_geoms = palloc(nelems * sizeof(LWGEOM*));
2703 
2704 #if POSTGIS_PGSQL_VERSION >= 95
2705  iterator = array_create_iterator(array, 0, NULL);
2706 #else
2707  iterator = array_create_iterator(array, 0);
2708 #endif
2709 
2710  while(array_iterate(iterator, &value, &isnull))
2711  {
2712  GSERIALIZED *geom = (GSERIALIZED*) DatumGetPointer(value);
2713 
2714  if (isnull)
2715  {
2716  continue;
2717  }
2718 
2719  *is3d = *is3d || gserialized_has_z(geom);
2720 
2721  lw_geoms[i] = lwgeom_from_gserialized(geom);
2722  if (!lw_geoms[i]) /* error in creation */
2723  {
2724  lwpgerror("Geometry deserializing geometry");
2725  return NULL;
2726  }
2727  if (!gotsrid)
2728  {
2729  gotsrid = true;
2730  *srid = gserialized_get_srid(geom);
2731  }
2732  else if (*srid != gserialized_get_srid(geom))
2733  {
2735  return NULL;
2736  }
2737 
2738  i++;
2739  }
2740 
2741  return lw_geoms;
2742 }
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:100
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:45
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 value
Definition: genraster.py:61
unsigned int uint32_t
Definition: uthash.h:78

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

Referenced by cluster_within_distance_garray().

Here is the call graph for this function:
Here is the caller graph for this function: