PostGIS  2.5.0dev-r@@SVN_REVISION@@
Datum RASTER_getGeotransform ( PG_FUNCTION_ARGS  )

Definition at line 435 of file rtpg_raster_properties.c.

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(), and TRUE.

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