GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-d6dec75dd4
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 GIS 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
31
void
G_adjust_window_to_box
(
const
struct
Cell_head
*
src
,
struct
Cell_head
*
dst
,
32
int
rows,
int
cols)
33
{
34
double
ew, ns;
35
36
*
dst
= *
src
;
37
38
/* calculate the effective resolutions */
39
ns = (
src
->ns_res *
src
->rows) / rows;
40
ew = (
src
->ew_res *
src
->cols) / cols;
41
42
/* set both resolutions equal to the larger */
43
if
(ns > ew)
44
ew = ns;
45
else
46
ns = ew;
47
48
dst
->ns_res = ns;
49
dst
->ew_res = ew;
50
51
/* compute rows and cols */
52
dst
->rows = (
dst
->north -
dst
->south) /
dst
->ns_res;
53
dst
->cols = (
dst
->east -
dst
->west) /
dst
->ew_res;
54
}
gis.h
dst
char * dst
Definition:
lz4.h:981
src
const char * src
Definition:
lz4.h:989
Cell_head
2D/3D raster map header (used also for region)
Definition:
gis.h:440
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:31
lib
gis
wind_2_box.c
Generated on Sun Dec 22 2024 07:38:21 for GRASS GIS 8 Programmer's Manual by
1.9.1