wind_in.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include <grass/gis.h>
  14. /*!
  15. * \brief Returns TRUE if coordinate is within the current region settings.
  16. *
  17. * \param easting
  18. * \param northing
  19. * \return int
  20. *
  21. */
  22. int G_point_in_region(double easting, double northing)
  23. {
  24. struct Cell_head window;
  25. G_get_window(&window);
  26. return G_point_in_window(easting, northing, &window);
  27. }
  28. /*!
  29. * \brief Returns TRUE if coordinate is within the given map region.
  30. *
  31. * Use instead of G_point_in_region() when used in a loop (it's more
  32. * efficient to only fetch the window once) or for checking if a point
  33. * is in another region (e.g. contained with a raster map's bounds).
  34. *
  35. * \param easting
  36. * \param northing
  37. * \param window
  38. * \return int
  39. *
  40. */
  41. int G_point_in_window(double easting, double northing,
  42. const struct Cell_head *window)
  43. {
  44. if (easting > window->east || easting < window->west ||
  45. northing > window->north || northing < window->south)
  46. return FALSE;
  47. return TRUE;
  48. }