main.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /****************************************************************************
  2. *
  3. * MODULE: r.in.poly
  4. * AUTHOR(S): Michael Shapiro, CERL (original contributor)
  5. * PURPOSE: creates GRASS binary raster maps from ASCII files
  6. * COPYRIGHT: (C) 1999-2006 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public
  9. * License (>=v2). Read the file COPYING that comes with GRASS
  10. * for details.
  11. *
  12. *****************************************************************************/
  13. #include <stdlib.h>
  14. #include <grass/gis.h>
  15. #include <grass/glocale.h>
  16. #include "local_proto.h"
  17. int main(int argc, char *argv[])
  18. {
  19. struct GModule *module;
  20. struct Option *input, *output, *title, *rows;
  21. int n;
  22. G_gisinit(argv[0]);
  23. module = G_define_module();
  24. G_add_keyword(_("raster"));
  25. G_add_keyword(_("import"));
  26. module->description =
  27. _("Creates raster maps from ASCII polygon/line/point data files.");
  28. input = G_define_standard_option(G_OPT_F_INPUT);
  29. input->description = _("Name of input file; or \"-\" to read from stdin");
  30. output = G_define_standard_option(G_OPT_R_OUTPUT);
  31. title = G_define_option();
  32. title->key = "title";
  33. title->key_desc = "phrase";
  34. title->type = TYPE_STRING;
  35. title->required = NO;
  36. title->description = _("Title for resultant raster map");
  37. rows = G_define_option();
  38. rows->key = "rows";
  39. rows->type = TYPE_INTEGER;
  40. rows->required = NO;
  41. rows->description = _("Number of rows to hold in memory");
  42. rows->answer = "4096";
  43. if (G_parser(argc, argv))
  44. exit(EXIT_FAILURE);
  45. sscanf(rows->answer, "%d", &n);
  46. if (n < 1)
  47. G_fatal_error(_("Minimum number of rows to hold in memory is 1"));
  48. exit(poly_to_rast(input->answer, output->answer, title->answer, n));
  49. }