GRASS GIS 7 Programmer's Manual  7.0.2(2015)-r00000
wind_2_box.c
Go to the documentation of this file.
1 
17 #include <grass/gis.h>
18 
19 
33 void G_adjust_window_to_box(const struct Cell_head *src,
34  struct Cell_head *dst, int rows, int cols)
35 {
36  double ew, ns;
37 
38  *dst = *src;
39 
40  /* calculate the effective resolutions */
41  ns = (src->ns_res * src->rows) / rows;
42  ew = (src->ew_res * src->cols) / cols;
43 
44  /* set both resolutions equal to the larger */
45  if (ns > ew)
46  ew = ns;
47  else
48  ns = ew;
49 
50  dst->ns_res = ns;
51  dst->ew_res = ew;
52 
53  /* compute rows and cols */
54  dst->rows = (dst->north - dst->south) / dst->ns_res;
55  dst->cols = (dst->east - dst->west) / dst->ew_res;
56 }
void G_adjust_window_to_box(const struct Cell_head *src, struct Cell_head *dst, int rows, int cols)
Adjusts window to a rectangular box.
Definition: wind_2_box.c:33