get_area.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /****************************************************************************
  2. *
  3. * MODULE: r.digit
  4. *
  5. * AUTHOR(S): Michael Shapiro - CERL
  6. *
  7. * PURPOSE: Interactive tool used to draw and save vector features
  8. * on a graphics monitor using a pointing device (mouse)
  9. * and save to a raster map.
  10. *
  11. * COPYRIGHT: (C) 2006 by the GRASS Development Team
  12. *
  13. * This program is free software under the GNU General Public
  14. * License (>=v2). Read the file COPYING that comes with GRASS
  15. * for details.
  16. *
  17. ***************************************************************************/
  18. #include <grass/gis.h>
  19. #include <grass/display.h>
  20. #include "local_proto.h"
  21. int get_area(FILE * fd, struct Categories *labels)
  22. {
  23. int x, y;
  24. int px, py;
  25. int x0, y0;
  26. int any;
  27. char east[256], north[256];
  28. instructions(0);
  29. x = y = -9999;
  30. any = 0;
  31. while (get_point(&x, &y, east, north)) {
  32. if (!any) {
  33. fprintf(fd, "AREA\n");
  34. any = 1;
  35. x0 = x;
  36. y0 = y;
  37. }
  38. else {
  39. black_and_white_line(px, py, x, y);
  40. R_flush();
  41. }
  42. px = x;
  43. py = y;
  44. fprintf(fd, " %s %s\n", east, north);
  45. }
  46. black_and_white_line(x0, y0, x, y);
  47. R_flush();
  48. get_category(fd, "area", labels);
  49. return any;
  50. }