PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ rt_raster_geopoint_to_cell()

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

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

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 pixel's column
yr: output parameter, the pixel's row
igt: input/output parameter, inverse geotransform matrix
Returns
ES_NONE if success, ES_ERROR if error

Definition at line 808 of file rt_raster.c.

813  {
814  double rnd = 0;
815  rt_errorstate err;
816 
817  err = rt_raster_geopoint_to_rasterpoint(raster, xw, yw, xr, yr, igt);
818  if (err != ES_NONE)
819  return err;
820 
821  rnd = ROUND(*xr, 0);
822  if (FLT_EQ(rnd, *xr))
823  *xr = rnd;
824  else
825  *xr = floor(*xr);
826 
827  rnd = ROUND(*yr, 0);
828  if (FLT_EQ(rnd, *yr))
829  *yr = rnd;
830  else
831  *yr = floor(*yr);
832 
833  RASTER_DEBUGF(4, "Corrected GDALApplyGeoTransform (g -> c) for (%f, %f) = (%f, %f)",
834  xw, yw, *xr, *yr);
835 
836  return ES_NONE;
837 }
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:306
#define ROUND(x, y)
Definition: librtcore.h:2394
#define FLT_EQ(x, y)
Definition: librtcore.h:2387
rt_errorstate
Enum definitions.
Definition: librtcore.h:181
@ ES_NONE
Definition: librtcore.h:182
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_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.
Definition: rt_raster.c:852

References ES_NONE, FLT_EQ, rtrowdump::raster, RASTER_DEBUGF, ROUND, and rt_raster_geopoint_to_rasterpoint().

Referenced by RASTER_nearestValue(), RASTER_setPixelValuesGeomval(), RASTER_worldToRasterCoord(), rt_band_load_offline_data(), rt_raster_compute_skewed_raster(), rt_raster_from_two_rasters(), rt_raster_gdal_rasterize(), rt_raster_gdal_warp(), rt_raster_intersects(), rt_raster_intersects_algorithm(), rt_raster_same_alignment(), and test_raster_geopoint_to_cell().

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