mask_info.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. *************************************************************
  3. * char * G_mask_info ()
  4. *
  5. * returns a printable text of mask information
  6. *
  7. ************************************************************
  8. * G__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/glocale.h>
  31. char *G_mask_info(void)
  32. {
  33. char text[GNAME_MAX + GMAPSET_MAX + 16];
  34. char name[GNAME_MAX];
  35. char mapset[GMAPSET_MAX];
  36. switch (G__mask_info(name, mapset)) {
  37. case 1:
  38. sprintf(text, _("<%s> in mapset <%s>"), name, mapset);
  39. break;
  40. case -1:
  41. strcpy(text, _("none"));
  42. break;
  43. default:
  44. strcpy(text, _("not known"));
  45. break;
  46. }
  47. return G_store(text);
  48. }
  49. int G__mask_info(char *name, char *mapset)
  50. {
  51. char rname[GNAME_MAX], rmapset[GMAPSET_MAX];
  52. strcpy(name, "MASK");
  53. strcpy(mapset, G_mapset());
  54. if (!G_find_cell(name, mapset))
  55. return -1;
  56. if (G_is_reclass(name, mapset, rname, rmapset) > 0) {
  57. strcpy(name, rname);
  58. strcpy(mapset, rmapset);
  59. }
  60. return 1;
  61. }