PostGIS  2.4.9dev-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(), TRUE, and VALUES_LENGTH.

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