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

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

735 {
736 double _igt[6] = {0};
737
738 assert(NULL != raster);
739 assert(NULL != xr && NULL != yr);
740
741 if (igt != NULL)
742 memcpy(_igt, igt, sizeof(double) * 6);
743
744 /* matrix is not set */
745 if (
746 FLT_EQ(_igt[0], 0.) &&
747 FLT_EQ(_igt[1], 0.) &&
748 FLT_EQ(_igt[2], 0.) &&
749 FLT_EQ(_igt[3], 0.) &&
750 FLT_EQ(_igt[4], 0.) &&
751 FLT_EQ(_igt[5], 0.)
752 ) {
753 if (rt_raster_get_inverse_geotransform_matrix(raster, NULL, _igt) != ES_NONE) {
754 rterror("rt_raster_geopoint_to_cell: Could not get inverse geotransform matrix");
755 return ES_ERROR;
756 }
757 }
758
759 GDALApplyGeoTransform(_igt, xw, yw, xr, yr);
760 RASTER_DEBUGF(4, "GDALApplyGeoTransform (g -> c) for (%f, %f) = (%f, %f)",
761 xw, yw, *xr, *yr);
762
763 return ES_NONE;
764}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
#define RASTER_DEBUGF(level, msg,...)
Definition librtcore.h:308
#define FLT_EQ(x, y)
Definition librtcore.h:2436
@ ES_NONE
Definition librtcore.h:182
@ ES_ERROR
Definition librtcore.h:183
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:558

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