PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ RASTER_getGeotransform()

Datum RASTER_getGeotransform ( PG_FUNCTION_ARGS  )

Definition at line 437 of file rtpg_raster_properties.c.

References FALSE, PG_FUNCTION_INFO_V1(), POSTGIS_RT_DEBUG, rtrowdump::raster, RASTER_isEmpty(), 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(), and TRUE.

Referenced by RASTER_getPixelHeight().

438 {
439  rt_pgraster *pgraster = NULL;
440  rt_raster raster = NULL;
441 
442  double imag;
443  double jmag;
444  double theta_i;
445  double theta_ij;
446  /*
447  double xoffset;
448  double yoffset;
449  */
450 
451  TupleDesc result_tuple; /* for returning a composite */
452  int values_length = 6;
453  Datum values[values_length];
454  bool nulls[values_length];
455  HeapTuple heap_tuple ; /* instance of the tuple to return */
456  Datum result;
457 
458  POSTGIS_RT_DEBUG(3, "RASTER_getGeotransform: Starting");
459 
460  /* get argument */
461  if (PG_ARGISNULL(0))
462  PG_RETURN_NULL();
463  pgraster = (rt_pgraster *)PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(0), 0, sizeof(struct rt_raster_serialized_t));
464 
465  /* raster */
466  raster = rt_raster_deserialize(pgraster, TRUE);
467  if (!raster) {
468  PG_FREE_IF_COPY(pgraster, 0);
469  elog(ERROR, "RASTER_getGeotransform: Could not deserialize raster");
470  PG_RETURN_NULL();
471  }
472 
473  /* do the calculation */
475  rt_raster_get_x_scale(raster),
476  rt_raster_get_x_skew(raster),
477  rt_raster_get_y_skew(raster),
478  rt_raster_get_y_scale(raster),
479  &imag, &jmag, &theta_i, &theta_ij) ;
480 
481  rt_raster_destroy(raster);
482  PG_FREE_IF_COPY(pgraster, 0);
483 
484  /* setup the return value infrastructure */
485  if (get_call_result_type(fcinfo, NULL, &result_tuple) != TYPEFUNC_COMPOSITE) {
486  ereport(ERROR, (
487  errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
488  errmsg("RASTER_getGeotransform(): function returning record called in context that cannot accept type record"
489  )
490  ));
491  PG_RETURN_NULL();
492  }
493 
494  BlessTupleDesc(result_tuple);
495 
496  /* get argument */
497  /* prep the composite return value */
498  /* construct datum array */
499  values[0] = Float8GetDatum(imag);
500  values[1] = Float8GetDatum(jmag);
501  values[2] = Float8GetDatum(theta_i);
502  values[3] = Float8GetDatum(theta_ij);
503  values[4] = Float8GetDatum(rt_raster_get_x_offset(raster));
504  values[5] = Float8GetDatum(rt_raster_get_y_offset(raster));
505 
506  memset(nulls, FALSE, sizeof(bool) * values_length);
507 
508  /* stick em on the heap */
509  heap_tuple = heap_form_tuple(result_tuple, values, nulls);
510 
511  /* make the tuple into a datum */
512  result = HeapTupleGetDatum(heap_tuple);
513 
514  PG_RETURN_DATUM(result);
515 }
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
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
double rt_raster_get_x_scale(rt_raster raster)
Get scale X in projection units.
Definition: rt_raster.c:150
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
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
#define FALSE
Definition: dbfopen.c:168
Struct definitions.
Definition: librtcore.h:2250
#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:717
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: