PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ RASTER_metadata()

Datum RASTER_metadata ( PG_FUNCTION_ARGS  )

Definition at line 588 of file rtpg_raster_properties.c.

References FALSE, rt_raster_serialized_t::height, rt_raster_serialized_t::ipX, rt_raster_serialized_t::ipY, rt_raster_serialized_t::numBands, PG_FUNCTION_INFO_V1(), POSTGIS_RT_DEBUG, rtrowdump::raster, RASTER_rasterToWorldCoord(), rt_raster_deserialize(), rt_raster_destroy(), rt_raster_get_height(), rt_raster_get_num_bands(), rt_raster_get_srid(), rt_raster_get_width(), rt_raster_get_x_offset(), rt_raster_get_x_scale(), rt_raster_get_x_skew(), rt_raster_get_y_offset(), rt_raster_get_y_scale(), rt_raster_get_y_skew(), rt_raster_serialized_t::scaleX, rt_raster_serialized_t::scaleY, rt_raster_serialized_t::skewX, rt_raster_serialized_t::skewY, rt_raster_serialized_t::srid, TRUE, and rt_raster_serialized_t::width.

Referenced by RASTER_hasNoBand().

589 {
590  rt_pgraster *pgraster = NULL;
591  rt_raster raster = NULL;
592 
594  double scaleX;
595  double scaleY;
596  double ipX;
597  double ipY;
598  double skewX;
599  double skewY;
600  int32_t srid;
601  uint32_t width;
603 
604  TupleDesc tupdesc;
605  int values_length = 10;
606  Datum values[values_length];
607  bool nulls[values_length];
608  HeapTuple tuple;
609  Datum result;
610 
611  POSTGIS_RT_DEBUG(3, "RASTER_metadata: Starting");
612 
613  /* pgraster is null, return null */
614  if (PG_ARGISNULL(0))
615  PG_RETURN_NULL();
616  pgraster = (rt_pgraster *) PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(0), 0, sizeof(struct rt_raster_serialized_t));
617 
618  /* raster */
619  raster = rt_raster_deserialize(pgraster, TRUE);
620  if (!raster) {
621  PG_FREE_IF_COPY(pgraster, 0);
622  elog(ERROR, "RASTER_metadata; Could not deserialize raster");
623  PG_RETURN_NULL();
624  }
625 
626  /* upper left x, y */
627  ipX = rt_raster_get_x_offset(raster);
628  ipY = rt_raster_get_y_offset(raster);
629 
630  /* width, height */
631  width = rt_raster_get_width(raster);
632  height = rt_raster_get_height(raster);
633 
634  /* scale x, y */
635  scaleX = rt_raster_get_x_scale(raster);
636  scaleY = rt_raster_get_y_scale(raster);
637 
638  /* skew x, y */
639  skewX = rt_raster_get_x_skew(raster);
640  skewY = rt_raster_get_y_skew(raster);
641 
642  /* srid */
643  srid = rt_raster_get_srid(raster);
644 
645  /* numbands */
646  numBands = rt_raster_get_num_bands(raster);
647 
648  rt_raster_destroy(raster);
649  PG_FREE_IF_COPY(pgraster, 0);
650 
651  /* Build a tuple descriptor for our result type */
652  if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) {
653  ereport(ERROR, (
654  errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
655  errmsg(
656  "function returning record called in context "
657  "that cannot accept type record"
658  )
659  ));
660  }
661 
662  BlessTupleDesc(tupdesc);
663 
664  values[0] = Float8GetDatum(ipX);
665  values[1] = Float8GetDatum(ipY);
666  values[2] = UInt32GetDatum(width);
667  values[3] = UInt32GetDatum(height);
668  values[4] = Float8GetDatum(scaleX);
669  values[5] = Float8GetDatum(scaleY);
670  values[6] = Float8GetDatum(skewX);
671  values[7] = Float8GetDatum(skewY);
672  values[8] = Int32GetDatum(srid);
673  values[9] = UInt32GetDatum(numBands);
674 
675  memset(nulls, FALSE, sizeof(bool) * values_length);
676 
677  /* build a tuple */
678  tuple = heap_form_tuple(tupdesc, values, nulls);
679 
680  /* make the tuple into a datum */
681  result = HeapTupleGetDatum(tuple);
682 
683  PG_RETURN_DATUM(result);
684 }
double rt_raster_get_x_offset(rt_raster raster)
Get raster x offset, in projection units.
Definition: rt_raster.c:213
double rt_raster_get_y_skew(rt_raster raster)
Get skew about the Y axis.
Definition: rt_raster.c:190
uint16_t rt_raster_get_num_bands(rt_raster raster)
Definition: rt_raster.c:372
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
unsigned int uint32_t
Definition: uthash.h:78
double rt_raster_get_x_scale(rt_raster raster)
Get scale X in projection units.
Definition: rt_raster.c:150
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
Definition: rt_raster.c:356
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
double rt_raster_get_y_scale(rt_raster raster)
Get scale Y in projection units.
Definition: rt_raster.c:159
double rt_raster_get_x_skew(rt_raster raster)
Get skew about the X axis.
Definition: rt_raster.c:181
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_raster.c:121
#define FALSE
Definition: dbfopen.c:168
Struct definitions.
Definition: librtcore.h:2250
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_raster.c:129
#define POSTGIS_RT_DEBUG(level, msg)
Definition: rtpostgis.h:61
#define TRUE
Definition: dbfopen.c:169
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:715
double rt_raster_get_y_offset(rt_raster raster)
Get raster y offset, in projection units.
Definition: rt_raster.c:222
Here is the call graph for this function:
Here is the caller graph for this function: