GRASS GIS 8 Programmer's Manual 8.2.1RC1(2022)-exported
wind_in.c
Go to the documentation of this file.
1
2/*!
3 * \file lib/gis/wind_in.c
4 *
5 * \brief Point in region functions.
6 *
7 * This program is free software under the GNU General Public License
8 * (>=v2). Read the file COPYING that comes with GRASS for details.
9 *
10 * \author Hamish Bowman. (c) Hamish Bowman, and the GRASS Development Team
11 *
12 * \date February 2007
13 */
14
15#include <grass/gis.h>
16
17/*!
18 * \brief Returns TRUE if coordinate is within the current region settings.
19 *
20 * \param easting
21 * \param northing
22 * \return int
23 *
24 */
25
26int G_point_in_region(double easting, double northing)
27{
28 struct Cell_head window;
29
30 G_get_window(&window);
31
32 return G_point_in_window(easting, northing, &window);
33}
34
35
36
37/*!
38 * \brief Returns TRUE if coordinate is within the given map region.
39 *
40 * Use instead of G_point_in_region() when used in a loop (it's more
41 * efficient to only fetch the window once) or for checking if a point
42 * is in another region (e.g. contained with a raster map's bounds).
43 *
44 * \param easting
45 * \param northing
46 * \param window
47 * \return int
48 *
49 */
50
51int G_point_in_window(double easting, double northing,
52 const struct Cell_head *window)
53{
54
55 if (easting > window->east || easting < window->west ||
56 northing > window->north || northing < window->south)
57 return FALSE;
58
59 return TRUE;
60}
#define TRUE
Definition: dbfopen.c:183
#define FALSE
Definition: dbfopen.c:182
void G_get_window(struct Cell_head *window)
Get the current region.
Definition: get_window.c:47
int G_point_in_window(double easting, double northing, const struct Cell_head *window)
Returns TRUE if coordinate is within the given map region.
Definition: wind_in.c:51
int G_point_in_region(double easting, double northing)
Returns TRUE if coordinate is within the current region settings.
Definition: wind_in.c:26