00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <grass/gis.h>
00020
00021 int G_adjust_window_to_box (
00022 struct Cell_head *src,struct Cell_head *dst,int rows,int cols)
00023 {
00024 double ew, ns;
00025
00026 G_copy ((char *) dst, (char *) src, sizeof(*dst));
00027
00028
00029 ns = (src->ns_res * src->rows) / rows;
00030 ew = (src->ew_res * src->cols) / cols;
00031
00032
00033 if (ns > ew)
00034 ew = ns;
00035 else
00036 ns = ew;
00037
00038 dst->ns_res = ns;
00039 dst->ew_res = ew;
00040
00041
00042 dst->rows = (dst->north - dst->south) / dst->ns_res;
00043 dst->cols = (dst->east - dst->west ) / dst->ew_res;
00044
00045 return 0;
00046 }