mask_info.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. *************************************************************
  3. * char * Rast_mask_info ()
  4. *
  5. * returns a printable text of mask information
  6. *
  7. ************************************************************
  8. * Rast__mask_info (name, mapset)
  9. *
  10. * char name[GNAME_MAX], mapset[GMAPSET_MAX];
  11. *
  12. * function:
  13. * determine the status off the automatic masking
  14. * and the name of the cell file which forms the mask
  15. *
  16. * (the mask file is actually MASK in the current mapset,
  17. * but is usually a reclassed cell file, and the reclass
  18. * name and mapset are returned)
  19. *
  20. * returns:
  21. * -1 no masking (name, mapset undefined)
  22. * name, mapset are undefined
  23. *
  24. * 1 mask file present, masking on
  25. * name, mapset hold mask file name, mapset
  26. *
  27. ***************************************************************/
  28. #include <string.h>
  29. #include <grass/gis.h>
  30. #include <grass/raster.h>
  31. #include <grass/glocale.h>
  32. char *Rast_mask_info(void)
  33. {
  34. char text[GNAME_MAX + GMAPSET_MAX + 16];
  35. char name[GNAME_MAX];
  36. char mapset[GMAPSET_MAX];
  37. switch (Rast__mask_info(name, mapset)) {
  38. case 1:
  39. sprintf(text, _("<%s> in mapset <%s>"), name, mapset);
  40. break;
  41. case -1:
  42. strcpy(text, _("none"));
  43. break;
  44. default:
  45. strcpy(text, _("not known"));
  46. break;
  47. }
  48. return G_store(text);
  49. }
  50. int Rast__mask_info(char *name, char *mapset)
  51. {
  52. char rname[GNAME_MAX], rmapset[GMAPSET_MAX];
  53. strcpy(name, "MASK");
  54. strcpy(mapset, G_mapset());
  55. if (!G_find_raster(name, mapset))
  56. return -1;
  57. if (Rast_is_reclass(name, mapset, rname, rmapset) > 0) {
  58. strcpy(name, rname);
  59. strcpy(mapset, rmapset);
  60. }
  61. return 1;
  62. }