PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ ARRAY2LWGEOM()

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

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

2718{
2719 ArrayIterator iterator;
2720 Datum value;
2721 bool isnull;
2722 bool gotsrid = false;
2723 uint32_t i = 0;
2724
2725 LWGEOM** lw_geoms = palloc(nelems * sizeof(LWGEOM*));
2726
2727 iterator = array_create_iterator(array, 0, NULL);
2728
2729 while (array_iterate(iterator, &value, &isnull))
2730 {
2731 GSERIALIZED *geom = (GSERIALIZED *)DatumGetPointer(value);
2732
2733 if (isnull)
2734 continue;
2735
2736 *is3d = *is3d || gserialized_has_z(geom);
2737
2738 lw_geoms[i] = lwgeom_from_gserialized(geom);
2739 if (!lw_geoms[i]) /* error in creation */
2740 {
2741 lwpgerror("Geometry deserializing geometry");
2742 return NULL;
2743 }
2744 if (!gotsrid)
2745 {
2746 gotsrid = true;
2747 *srid = gserialized_get_srid(geom);
2748 }
2749 else
2750 gserialized_error_if_srid_mismatch_reference(geom, *srid, __func__);
2751
2752 i++;
2753 }
2754
2755 return lw_geoms;
2756}
void gserialized_error_if_srid_mismatch_reference(const GSERIALIZED *g1, const int32_t srid2, const char *funcname)
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
int value
Definition genraster.py:62

References gserialized_error_if_srid_mismatch_reference(), gserialized_get_srid(), gserialized_has_z(), and lwgeom_from_gserialized().

Referenced by cluster_within_distance_garray().

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