PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ ARRAY2LWGEOM()

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

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

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