GRASS Programmer's Manual 6.4.1(2011)
|
00001 00017 #include <grass/gis.h> 00018 00019 00033 int G_adjust_window_to_box(const struct Cell_head *src, 00034 struct Cell_head *dst, int rows, int cols) 00035 { 00036 double ew, ns; 00037 00038 G_copy((char *)dst, (char *)src, sizeof(*dst)); 00039 00040 /* calculate the effective resolutions */ 00041 ns = (src->ns_res * src->rows) / rows; 00042 ew = (src->ew_res * src->cols) / cols; 00043 00044 /* set both resolutions equal to the larger */ 00045 if (ns > ew) 00046 ew = ns; 00047 else 00048 ns = ew; 00049 00050 dst->ns_res = ns; 00051 dst->ew_res = ew; 00052 00053 /* compute rows and cols */ 00054 dst->rows = (dst->north - dst->south) / dst->ns_res; 00055 dst->cols = (dst->east - dst->west) / dst->ew_res; 00056 00057 return 0; 00058 }