PostGIS  2.1.10dev-r@@SVN_REVISION@@
rt_errorstate rt_raster_get_envelope ( rt_raster  raster,
rt_envelope env 
)

Get raster's envelope.

The envelope is the minimum bounding rectangle of the raster

Parameters
raster: the raster to get envelope of
env: pointer to rt_envelope
Returns
ES_NONE if success, ES_ERROR if error

Definition at line 6681 of file rt_api.c.

References ES_ERROR, ES_NONE, rt_raster_t::height, rt_envelope::MaxX, rt_envelope::MaxY, rt_envelope::MinX, rt_envelope::MinY, rt_raster_cell_to_geopoint(), rt_raster_get_geotransform_matrix(), rterror(), and rt_raster_t::width.

6684  {
6685  int i;
6686  int rtn;
6687  int set = 0;
6688  double _r[2] = {0.};
6689  double _w[2] = {0.};
6690  double _gt[6] = {0.};
6691 
6692  assert(raster != NULL);
6693  assert(env != NULL);
6694 
6695  rt_raster_get_geotransform_matrix(raster, _gt);
6696 
6697  for (i = 0; i < 4; i++) {
6698  switch (i) {
6699  case 0:
6700  _r[0] = 0;
6701  _r[1] = 0;
6702  break;
6703  case 1:
6704  _r[0] = 0;
6705  _r[1] = raster->height;
6706  break;
6707  case 2:
6708  _r[0] = raster->width;
6709  _r[1] = raster->height;
6710  break;
6711  case 3:
6712  _r[0] = raster->width;
6713  _r[1] = 0;
6714  break;
6715  }
6716 
6718  raster,
6719  _r[0], _r[1],
6720  &(_w[0]), &(_w[1]),
6721  _gt
6722  );
6723  if (rtn != ES_NONE) {
6724  rterror("rt_raster_get_envelope: Could not compute spatial coordinates for raster pixel");
6725  return ES_ERROR;
6726  }
6727 
6728  if (!set) {
6729  set = 1;
6730  env->MinX = _w[0];
6731  env->MaxX = _w[0];
6732  env->MinY = _w[1];
6733  env->MaxY = _w[1];
6734  }
6735  else {
6736  if (_w[0] < env->MinX)
6737  env->MinX = _w[0];
6738  else if (_w[0] > env->MaxX)
6739  env->MaxX = _w[0];
6740 
6741  if (_w[1] < env->MinY)
6742  env->MinY = _w[1];
6743  else if (_w[1] > env->MaxY)
6744  env->MaxY = _w[1];
6745  }
6746  }
6747 
6748  return ES_NONE;
6749 }
double MinY
Definition: rt_api.h:154
double MaxY
Definition: rt_api.h:155
double MaxX
Definition: rt_api.h:153
uint16_t height
Definition: rt_api.h:2227
rt_errorstate rt_raster_cell_to_geopoint(rt_raster raster, double xr, double yr, double *xw, double *yw, double *gt)
Convert an xr, yr raster point to an xw, yw point on map.
Definition: rt_api.c:6054
void rt_raster_get_geotransform_matrix(rt_raster raster, double *gt)
Get 6-element array of raster geotransform matrix.
Definition: rt_api.c:6005
uint16_t width
Definition: rt_api.h:2226
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895
double MinX
Definition: rt_api.h:152

Here is the call graph for this function: