main.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /****************************************************************************
  2. *
  3. * MODULE: d.measure
  4. * AUTHOR(S): James Westervelt and Michael Shapiro
  5. * (CERL - original contributors)
  6. * Markus Neteler <neteler itc.it>,
  7. * Reinhard Brunzema <r.brunzema@web.de>,
  8. * Bernhard Reiter <bernhard intevation.de>,
  9. * Huidae Cho <grass4u gmail.com>,
  10. * Eric G. Miller <egm2 jps.net>,
  11. * Glynn Clements <glynn gclements.plus.com>,
  12. * Hamish Bowman <hamish_b yahoo.com>,
  13. * Jan-Oliver Wagner <jan intevation.de>
  14. * PURPOSE: interactive line and polygon measurement in display
  15. * COPYRIGHT: (C) 1999-2006 by the GRASS Development Team
  16. *
  17. * This program is free software under the GNU General Public
  18. * License (>=v2). Read the file COPYING that comes with GRASS
  19. * for details.
  20. *
  21. *****************************************************************************/
  22. #include <stdlib.h>
  23. #include <grass/gis.h>
  24. #include <grass/display.h>
  25. #include <grass/glocale.h>
  26. #include "local_proto.h"
  27. int main(int argc, char **argv)
  28. {
  29. struct GModule *module;
  30. struct
  31. {
  32. struct Option *c1;
  33. struct Option *c2;
  34. struct Flag *s;
  35. struct Flag *m;
  36. struct Flag *k;
  37. } parm;
  38. int color1, color2, s_flag, m_flag, k_flag;
  39. /* Initialize the GIS calls */
  40. G_gisinit(argv[0]);
  41. module = G_define_module();
  42. G_add_keyword(_("display"));
  43. G_add_keyword(_("geometry"));
  44. module->description =
  45. _("Measures the lengths and areas of features drawn "
  46. "by the user in the active display frame on the "
  47. "graphics monitor.");
  48. parm.c1 = G_define_option();
  49. parm.c1->key = "c1";
  50. parm.c1->description = _("Line color 1");
  51. parm.c1->type = TYPE_STRING;
  52. parm.c1->required = NO;
  53. parm.c1->gisprompt = "old_color,color,color";
  54. parm.c1->answer = DEFAULT_BG_COLOR;
  55. parm.c2 = G_define_option();
  56. parm.c2->key = "c2";
  57. parm.c2->description = _("Line color 2");
  58. parm.c2->type = TYPE_STRING;
  59. parm.c2->required = NO;
  60. parm.c2->gisprompt = "old_color,color,color";
  61. parm.c2->answer = DEFAULT_FG_COLOR;
  62. parm.s = G_define_flag();
  63. parm.s->key = 's';
  64. parm.s->description = _("Suppress clear screen");
  65. parm.m = G_define_flag();
  66. parm.m->key = 'm';
  67. parm.m->description = _("Output in meters only");
  68. parm.k = G_define_flag();
  69. parm.k->key = 'k';
  70. parm.k->description = _("Output in kilometers as well");
  71. if (G_parser(argc, argv))
  72. exit(EXIT_FAILURE);
  73. if (R_open_driver() != 0)
  74. G_fatal_error(_("No graphics device selected"));
  75. color1 = D_translate_color(parm.c1->answer);
  76. color2 = D_translate_color(parm.c2->answer);
  77. s_flag = parm.s->answer;
  78. m_flag = parm.m->answer;
  79. k_flag = parm.k->answer;
  80. measurements(color1, color2, s_flag, m_flag, k_flag);
  81. R_close_driver();
  82. exit(EXIT_SUCCESS);
  83. }