wind_2_box.c

Go to the documentation of this file.
00001 /*******************************************************************
00002  *
00003  *   G_adjust_window_to_box (src, dst, rows, cols)
00004  *
00005  *     creates a new window (dst) from a window (src)
00006  *     which fits into the rectangular box with dimensions
00007  *     rows by cols
00008  *
00009  *   parms:
00010  *      struct Cell_head *src
00011  *      struct Cell_head *dst
00012  *      int rows
00013  *      int cols
00014  *
00015  *   returns:
00016  *      nothing
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 /* calculate the effective resolutions */
00029     ns = (src->ns_res * src->rows) / rows;
00030     ew = (src->ew_res * src->cols) / cols;
00031 
00032 /* set both resolutions equal to the larger */
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 /* compute rows and cols */
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 }

Generated on Fri Nov 21 11:02:18 2008 for GRASS by  doxygen 1.5.1