PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ RASTER_envelope()

Datum RASTER_envelope ( PG_FUNCTION_ARGS  )

Definition at line 66 of file rtpg_geometry.c.

67 {
68  rt_pgraster *pgraster;
70  LWGEOM *geom = NULL;
71  GSERIALIZED* gser = NULL;
72  size_t gser_size;
73  int err = ES_NONE;
74 
75  if (PG_ARGISNULL(0))
76  PG_RETURN_NULL();
77 
78  pgraster = (rt_pgraster *) PG_DETOAST_DATUM_SLICE(
79  PG_GETARG_DATUM(0),
80  0,
81  sizeof(struct rt_raster_serialized_t)
82  );
83  raster = rt_raster_deserialize(pgraster, TRUE);
84 
85  if (!raster) {
86  PG_FREE_IF_COPY(pgraster, 0);
87  elog(ERROR, "RASTER_envelope: Could not deserialize raster");
88  PG_RETURN_NULL();
89  }
90 
91  err = rt_raster_get_envelope_geom(raster, &geom);
92 
94  PG_FREE_IF_COPY(pgraster, 0);
95 
96  if (err != ES_NONE) {
97  elog(ERROR, "RASTER_envelope: Could not get raster's envelope");
98  PG_RETURN_NULL();
99  }
100  else if (geom == NULL) {
101  elog(NOTICE, "Raster's envelope is NULL");
102  PG_RETURN_NULL();
103  }
104 
105  gser = gserialized_from_lwgeom(geom, &gser_size);
106  lwgeom_free(geom);
107 
108  SET_VARSIZE(gser, gser_size);
109  PG_RETURN_POINTER(gser);
110 }
#define TRUE
Definition: dbfopen.c:169
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
@ ES_NONE
Definition: librtcore.h:180
rt_errorstate rt_raster_get_envelope_geom(rt_raster raster, LWGEOM **env)
Get raster's envelope as a geometry.
Definition: rt_geometry.c:670
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:725
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
Struct definitions.
Definition: librtcore.h:2250

References ES_NONE, gserialized_from_lwgeom(), lwgeom_free(), rtrowdump::raster, rt_raster_deserialize(), rt_raster_destroy(), rt_raster_get_envelope_geom(), and TRUE.

Here is the call graph for this function: