GRASS 8 Programmer's Manual
8.5.0RC1(2026)-3334b87d9c
Loading...
Searching...
No Matches
wind_2_box.c
Go to the documentation of this file.
1
/*!
2
* \file lib/gis/wind_2_box.c
3
*
4
* \brief GIS Library - Window box functions.
5
*
6
* (C) 2001-2014 by the GRASS Development Team
7
*
8
* This program is free software under the GNU General Public License
9
* (>=v2). Read the file COPYING that comes with GRASS for details.
10
*
11
* \author GRASS Development Team
12
*
13
* \date 1999-2014
14
*/
15
16
#include <grass/gis.h>
17
18
/**
19
* \brief Adjusts window to a rectangular box.
20
*
21
* Creates a new window <b>dst</b> from a window <b>src</b> which fits
22
* into the rectangular box with dimensions <b>rows</b> by <b>cols</b>.
23
*
24
* \param[in] src source window
25
* \param[in,out] dst destination window
26
* \param[in] rows number of rows in box
27
* \param[in] cols number of columns in box
28
* \return
29
*/
30
void
G_adjust_window_to_box
(
const
struct
Cell_head *src,
struct
Cell_head *dst,
31
int
rows,
int
cols)
32
{
33
double
ew, ns;
34
35
*dst = *src;
36
37
/* calculate the effective resolutions */
38
ns = (src->ns_res * src->rows) / rows;
39
ew = (src->ew_res * src->cols) / cols;
40
41
/* set both resolutions equal to the larger */
42
if
(ns > ew)
43
ew = ns;
44
else
45
ns = ew;
46
47
dst->ns_res = ns;
48
dst->ew_res = ew;
49
50
/* compute rows and cols */
51
dst->rows = (dst->north - dst->south) / dst->ns_res;
52
dst->cols = (dst->east - dst->west) / dst->ew_res;
53
}
G_adjust_window_to_box
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:30
gis
wind_2_box.c
Generated on
for GRASS 8 Programmer's Manual by
1.15.0