init.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /****************************************************************************
  2. *
  3. * MODULE: r.buffer
  4. *
  5. * AUTHOR(S): Michael Shapiro - CERL
  6. *
  7. * PURPOSE: This program creates distance zones from non-zero
  8. * cells in a grid layer. Distances are specified in
  9. * meters (on the command-line). Window does not have to
  10. * have square cells. Works both for planimetric
  11. * (UTM, State Plane) and lat-long.
  12. *
  13. * COPYRIGHT: (C) 2005 by the GRASS Development Team
  14. *
  15. * This program is free software under the GNU General Public
  16. * License (>=v2). Read the file COPYING that comes with GRASS
  17. * for details.
  18. *
  19. ****************************************************************************/
  20. #include "distance.h"
  21. #include <grass/gis.h>
  22. int init_grass(void)
  23. {
  24. double a, e2;
  25. double factor;
  26. G_get_set_window(&window);
  27. if (window.proj == PROJECTION_LL) {
  28. G_get_ellipsoid_parameters(&a, &e2);
  29. G_begin_geodesic_distance(a, e2);
  30. wrap_ncols =
  31. (360.0 - (window.east - window.west)) / window.ew_res + 1.1;
  32. /* add 1.1 instead of 1 to insure that we round up, not down */
  33. }
  34. else {
  35. wrap_ncols = 0;
  36. factor = G_database_units_to_meters_factor();
  37. if (factor <= 0.0)
  38. factor = 1.0;
  39. meters_to_grid = 1.0 / factor;
  40. }
  41. return 0;
  42. }