PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ RASTER_getGeotransform()

Datum RASTER_getGeotransform ( PG_FUNCTION_ARGS  )

Definition at line 439 of file rtpg_raster_properties.c.

440 {
441  rt_pgraster *pgraster = NULL;
442  rt_raster raster = NULL;
443 
444  double imag;
445  double jmag;
446  double theta_i;
447  double theta_ij;
448  /*
449  double xoffset;
450  double yoffset;
451  */
452 
453  TupleDesc result_tuple; /* for returning a composite */
454  Datum values[VALUES_LENGTH];
455  bool nulls[VALUES_LENGTH];
456  HeapTuple heap_tuple ; /* instance of the tuple to return */
457  Datum result;
458 
459  POSTGIS_RT_DEBUG(3, "RASTER_getGeotransform: Starting");
460 
461  /* get argument */
462  if (PG_ARGISNULL(0))
463  PG_RETURN_NULL();
464  pgraster = (rt_pgraster *)PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(0), 0, sizeof(struct rt_raster_serialized_t));
465 
466  /* raster */
467  raster = rt_raster_deserialize(pgraster, TRUE);
468  if (!raster) {
469  PG_FREE_IF_COPY(pgraster, 0);
470  elog(ERROR, "RASTER_getGeotransform: Could not deserialize raster");
471  PG_RETURN_NULL();
472  }
473 
474  /* do the calculation */
480  &imag, &jmag, &theta_i, &theta_ij) ;
481 
483  PG_FREE_IF_COPY(pgraster, 0);
484 
485  /* setup the return value infrastructure */
486  if (get_call_result_type(fcinfo, NULL, &result_tuple) != TYPEFUNC_COMPOSITE) {
487  ereport(ERROR, (
488  errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
489  errmsg("RASTER_getGeotransform(): function returning record called in context that cannot accept type record"
490  )
491  ));
492  PG_RETURN_NULL();
493  }
494 
495  BlessTupleDesc(result_tuple);
496 
497  /* get argument */
498  /* prep the composite return value */
499  /* construct datum array */
500  values[0] = Float8GetDatum(imag);
501  values[1] = Float8GetDatum(jmag);
502  values[2] = Float8GetDatum(theta_i);
503  values[3] = Float8GetDatum(theta_ij);
504  values[4] = Float8GetDatum(rt_raster_get_x_offset(raster));
505  values[5] = Float8GetDatum(rt_raster_get_y_offset(raster));
506 
507  memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
508 
509  /* stick em on the heap */
510  heap_tuple = heap_form_tuple(result_tuple, values, nulls);
511 
512  /* make the tuple into a datum */
513  result = HeapTupleGetDatum(heap_tuple);
514 
515  PG_RETURN_DATUM(result);
516 }
#define TRUE
Definition: dbfopen.c:169
#define FALSE
Definition: dbfopen.c:168
double rt_raster_get_x_skew(rt_raster raster)
Get skew about the X axis.
Definition: rt_raster.c:181
double rt_raster_get_x_offset(rt_raster raster)
Get raster x offset, in projection units.
Definition: rt_raster.c:213
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
double rt_raster_get_x_scale(rt_raster raster)
Get scale X in projection units.
Definition: rt_raster.c:150
double rt_raster_get_y_scale(rt_raster raster)
Get scale Y in projection units.
Definition: rt_raster.c:159
double rt_raster_get_y_skew(rt_raster raster)
Get skew about the Y axis.
Definition: rt_raster.c:190
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:725
void rt_raster_calc_phys_params(double xscale, double xskew, double yskew, double yscale, double *i_mag, double *j_mag, double *theta_i, double *theta_ij)
Calculates the physically significant descriptors embodied in an arbitrary geotransform.
Definition: rt_raster.c:250
double rt_raster_get_y_offset(rt_raster raster)
Get raster y offset, in projection units.
Definition: rt_raster.c:222
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
#define VALUES_LENGTH
#define POSTGIS_RT_DEBUG(level, msg)
Definition: rtpostgis.h:61
Struct definitions.
Definition: librtcore.h:2250

References FALSE, POSTGIS_RT_DEBUG, rtrowdump::raster, rt_raster_calc_phys_params(), rt_raster_deserialize(), rt_raster_destroy(), 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(), TRUE, and VALUES_LENGTH.

Here is the call graph for this function: