GRASS GIS 8 Programmer's Manual
8.0.2(2022)-exported
wind_2_box.c
Go to the documentation of this file.
1
2
/*!
3
* \file lib/gis/wind_2_box.c
4
*
5
* \brief GIS Library - Window box functions.
6
*
7
* (C) 2001-2014 by the GRASS Development Team
8
*
9
* This program is free software under the GNU General Public License
10
* (>=v2). Read the file COPYING that comes with GRASS for details.
11
*
12
* \author GRASS GIS Development Team
13
*
14
* \date 1999-2014
15
*/
16
17
#include <grass/gis.h>
18
19
20
/**
21
* \brief Adjusts window to a rectangular box.
22
*
23
* Creates a new window <b>dst</b> from a window <b>src</b> which fits
24
* into the rectangular box with dimensions <b>rows</b> by <b>cols</b>.
25
*
26
* \param[in] src source window
27
* \param[in,out] dst destination window
28
* \param[in] rows number of rows in box
29
* \param[in] cols number of columns in box
30
* \return
31
*/
32
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
}
dst
char * dst
Definition:
lz4.h:599
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:33
gis
wind_2_box.c
Generated on Thu May 12 2022 14:57:19 for GRASS GIS 8 Programmer's Manual by
1.9.1