PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ rt_raster_geopoint_to_rasterpoint()

rt_errorstate rt_raster_geopoint_to_rasterpoint ( rt_raster  raster,
double  xw,
double  yw,
double *  xr,
double *  yr,
double *  igt 
)

Convert an xw,yw map point to a xr,yr raster point.

Parameters
raster: the raster to get info from
xw: X ordinate of the geographical point
yw: Y ordinate of the geographical point
xr: output parameter, the x ordinate in raster space
yr: output parameter, the y ordinate in raster space
igt: input/output parameter, inverse geotransform matrix
Returns
ES_NONE if success, ES_ERROR if error

Definition at line 852 of file rt_raster.c.

857  {
858  double _igt[6] = {0};
859 
860  assert(NULL != raster);
861  assert(NULL != xr && NULL != yr);
862 
863  if (igt != NULL)
864  memcpy(_igt, igt, sizeof(double) * 6);
865 
866  /* matrix is not set */
867  if (
868  FLT_EQ(_igt[0], 0.) &&
869  FLT_EQ(_igt[1], 0.) &&
870  FLT_EQ(_igt[2], 0.) &&
871  FLT_EQ(_igt[3], 0.) &&
872  FLT_EQ(_igt[4], 0.) &&
873  FLT_EQ(_igt[5], 0.)
874  ) {
876  rterror("rt_raster_geopoint_to_cell: Could not get inverse geotransform matrix");
877  return ES_ERROR;
878  }
879  }
880 
881  GDALApplyGeoTransform(_igt, xw, yw, xr, yr);
882  RASTER_DEBUGF(4, "GDALApplyGeoTransform (g -> c) for (%f, %f) = (%f, %f)",
883  xw, yw, *xr, *yr);
884 
885  return ES_NONE;
886 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:219
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:306
#define FLT_EQ(x, y)
Definition: librtcore.h:2387
@ ES_NONE
Definition: librtcore.h:182
@ ES_ERROR
Definition: librtcore.h:183
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
rt_errorstate rt_raster_get_inverse_geotransform_matrix(rt_raster raster, double *gt, double *igt)
Get 6-element array of raster inverse geotransform matrix.
Definition: rt_raster.c:680

References ES_ERROR, ES_NONE, FLT_EQ, rtrowdump::raster, RASTER_DEBUGF, rt_raster_get_inverse_geotransform_matrix(), and rterror().

Referenced by RASTER_getPixelValueResample(), rt_raster_copy_to_geometry(), rt_raster_geopoint_to_cell(), and test_raster_get_pixel_bilinear().

Here is the call graph for this function:
Here is the caller graph for this function: