GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
wind_2_box.c
Go to the documentation of this file.
1 
17 #include <grass/gis.h>
18 
19 
33 int 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  G_copy((char *)dst, (char *)src, sizeof(*dst));
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 
57  return 0;
58 }
int G_copy(void *a, const void *b, int n)
Copies n bytes starting at address b into address a.
Definition: gis/copy.c:30
int 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
tuple cols