Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <stdio.h>
00014 #include <string.h>
00015 #include <grass/gis.h>
00016 #include <grass/glocale.h>
00017
00018
00030 int G_read_raster_units(const char *name, const char *mapset, char *str)
00031 {
00032 return G__raster_misc_read_line("units", name, mapset, str);
00033 }
00034
00035
00046 int G_write_raster_units(const char *name, const char *str)
00047 {
00048 return G__raster_misc_write_line("units", name, str);
00049 }
00050
00051
00063 int G_read_raster_vdatum(const char *name, const char *mapset, char *str)
00064 {
00065 return G__raster_misc_read_line("vertical_datum", name, mapset, str);
00066 }
00067
00068
00079 int G_write_raster_vdatum(const char *name, const char *str)
00080 {
00081 return G__raster_misc_write_line("vertical_datum", name, str);
00082 }
00083
00084
00085
00098 int G__raster_misc_read_line(const char *elem, const char *name,
00099 const char *mapset, char *str)
00100 {
00101 FILE *fd;
00102 char buff[GNAME_MAX];
00103
00104 buff[0] = '\0';
00105
00106 if (G_find_file2_misc("cell_misc", elem, name, mapset) == NULL)
00107 return -1;
00108
00109 fd = G_fopen_old_misc("cell_misc", elem, name, mapset);
00110 if (!fd) {
00111 G_warning(_("Can't read %s for [%s in %s]"), elem, name, mapset);
00112 return -1;
00113 }
00114 if (G_getl2(buff, sizeof(buff) - 1, fd) == 0) {
00115
00116 return fclose(fd);
00117 }
00118
00119 strcpy(str, buff);
00120
00121 return fclose(fd);
00122 }
00123
00124
00137 int G__raster_misc_write_line(const char *elem, const char *name,
00138 const char *str)
00139 {
00140 FILE *fd;
00141
00142 fd = G_fopen_new_misc("cell_misc", elem, name);
00143 if (fd == NULL) {
00144 G_warning(_("Can't create %s metadata file for [%s in %s]"),
00145 elem, name, G_mapset());
00146 return -1;
00147 }
00148
00149 fprintf(fd, "%s", str);
00150
00151 return fclose(fd);
00152 }