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

Definition at line 2176 of file rt_pg.c.

References FALSE, POSTGIS_RT_DEBUG, rtrowdump::raster, result, 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.

2177 {
2178  rt_pgraster *pgraster = NULL;
2179  rt_raster raster = NULL;
2180 
2181  double imag;
2182  double jmag;
2183  double theta_i;
2184  double theta_ij;
2185  /*
2186  double xoffset;
2187  double yoffset;
2188  */
2189 
2190  TupleDesc result_tuple; /* for returning a composite */
2191  int values_length = 6;
2192  Datum values[values_length];
2193  bool nulls[values_length];
2194  HeapTuple heap_tuple ; /* instance of the tuple to return */
2195  Datum result;
2196 
2197  POSTGIS_RT_DEBUG(3, "RASTER_getGeotransform: Starting");
2198 
2199  /* get argument */
2200  if (PG_ARGISNULL(0))
2201  PG_RETURN_NULL();
2202  pgraster = (rt_pgraster *)PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(0), 0, sizeof(struct rt_raster_serialized_t));
2203 
2204  /* raster */
2205  raster = rt_raster_deserialize(pgraster, TRUE);
2206  if (!raster) {
2207  PG_FREE_IF_COPY(pgraster, 0);
2208  elog(ERROR, "RASTER_getGeotransform: Could not deserialize raster");
2209  PG_RETURN_NULL();
2210  }
2211 
2212  /* do the calculation */
2214  rt_raster_get_x_scale(raster),
2215  rt_raster_get_x_skew(raster),
2216  rt_raster_get_y_skew(raster),
2217  rt_raster_get_y_scale(raster),
2218  &imag, &jmag, &theta_i, &theta_ij) ;
2219 
2220  rt_raster_destroy(raster);
2221  PG_FREE_IF_COPY(pgraster, 0);
2222 
2223  /* setup the return value infrastructure */
2224  if (get_call_result_type(fcinfo, NULL, &result_tuple) != TYPEFUNC_COMPOSITE) {
2225  ereport(ERROR, (
2226  errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2227  errmsg("RASTER_getGeotransform(): function returning record called in context that cannot accept type record"
2228  )
2229  ));
2230  PG_RETURN_NULL();
2231  }
2232 
2233  BlessTupleDesc(result_tuple);
2234 
2235  /* get argument */
2236  /* prep the composite return value */
2237  /* construct datum array */
2238  values[0] = Float8GetDatum(imag);
2239  values[1] = Float8GetDatum(jmag);
2240  values[2] = Float8GetDatum(theta_i);
2241  values[3] = Float8GetDatum(theta_ij);
2242  values[4] = Float8GetDatum(rt_raster_get_x_offset(raster));
2243  values[5] = Float8GetDatum(rt_raster_get_y_offset(raster));
2244 
2245  memset(nulls, FALSE, sizeof(bool) * values_length);
2246 
2247  /* stick em on the heap */
2248  heap_tuple = heap_form_tuple(result_tuple, values, nulls);
2249 
2250  /* make the tuple into a datum */
2251  result = HeapTupleGetDatum(heap_tuple);
2252 
2253  PG_RETURN_DATUM(result);
2254 }
double rt_raster_get_y_offset(rt_raster raster)
Get raster y offset, in projection units.
Definition: rt_api.c:5527
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_api.c:5387
double rt_raster_get_x_skew(rt_raster raster)
Get skew about the X axis.
Definition: rt_api.c:5486
double rt_raster_get_y_skew(rt_raster raster)
Get skew about the Y axis.
Definition: rt_api.c:5495
double rt_raster_get_x_offset(rt_raster raster)
Get raster x offset, in projection units.
Definition: rt_api.c:5518
tuple raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:123
char ** result
Definition: liblwgeom.h:218
#define POSTGIS_RT_DEBUG(level, msg)
Definition: rt_pg.h:58
double rt_raster_get_x_scale(rt_raster raster)
Get scale X in projection units.
Definition: rt_api.c:5455
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_api.c:5555
#define FALSE
Definition: dbfopen.c:169
Struct definitions.
Definition: rt_api.h:2175
double rt_raster_get_y_scale(rt_raster raster)
Get scale Y in projection units.
Definition: rt_api.c:5464
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_api.c:8350
#define TRUE
Definition: dbfopen.c:170

Here is the call graph for this function: