PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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 686 of file rt_raster.c.

691 {
692 double rnd = 0;
693 rt_errorstate err;
694
695 err = rt_raster_geopoint_to_rasterpoint(raster, xw, yw, xr, yr, igt);
696 if (err != ES_NONE)
697 return err;
698
699 rnd = ROUND(*xr, 0);
700 if (FLT_EQ(rnd, *xr))
701 *xr = rnd;
702 else
703 *xr = floor(*xr);
704
705 rnd = ROUND(*yr, 0);
706 if (FLT_EQ(rnd, *yr))
707 *yr = rnd;
708 else
709 *yr = floor(*yr);
710
711 RASTER_DEBUGF(4, "Corrected GDALApplyGeoTransform (g -> c) for (%f, %f) = (%f, %f)",
712 xw, yw, *xr, *yr);
713
714 return ES_NONE;
715}
#define RASTER_DEBUGF(level, msg,...)
Definition librtcore.h:308
#define ROUND(x, y)
Definition librtcore.h:2443
#define FLT_EQ(x, y)
Definition librtcore.h:2436
rt_errorstate
Enum definitions.
Definition librtcore.h:181
@ ES_NONE
Definition librtcore.h:182
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:730

References ES_NONE, FLT_EQ, 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: