GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-535c39c9fc
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 
25 int G_point_in_region(double easting, double northing)
26 {
27  struct Cell_head window;
28 
29  G_get_window(&window);
30 
31  return G_point_in_window(easting, northing, &window);
32 }
33 
34 /*!
35  * \brief Returns TRUE if coordinate is within the given map region.
36  *
37  * Use instead of G_point_in_region() when used in a loop (it's more
38  * efficient to only fetch the window once) or for checking if a point
39  * is in another region (e.g. contained with a raster map's bounds).
40  *
41  * \param easting
42  * \param northing
43  * \param window
44  * \return int
45  *
46  */
47 
48 int G_point_in_window(double easting, double northing,
49  const struct Cell_head *window)
50 {
51 
52  if (easting > window->east || easting < window->west ||
53  northing > window->north || northing < window->south)
54  return FALSE;
55 
56  return TRUE;
57 }
void G_get_window(struct Cell_head *)
Get the current region.
Definition: get_window.c:47
#define TRUE
Definition: gis.h:79
#define FALSE
Definition: gis.h:83
2D/3D raster map header (used also for region)
Definition: gis.h:437
double north
Extent coordinates (north)
Definition: gis.h:483
double east
Extent coordinates (east)
Definition: gis.h:487
double south
Extent coordinates (south)
Definition: gis.h:485
double west
Extent coordinates (west)
Definition: gis.h:489
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:48
int G_point_in_region(double easting, double northing)
Returns TRUE if coordinate is within the current region settings.
Definition: wind_in.c:25