PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ ARRAY2LWGEOM()

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

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

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