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