83 #include <grass/gis.h>
84 #include <grass/vect/dig_defines.h>
85 #include <grass/glocale.h>
87 #define RAST_MISC "cell_misc"
141 while (fgets(buf,
sizeof(buf), fd)) {
142 if (sscanf(buf,
"%1s", comment) != 1 || *comment ==
'#')
166 fprintf(fd,
"%s\n", buf);
185 char temp1[128], temp2[128];
198 else if (ts->count == 2)
199 sprintf(buf,
"%s / %s", temp1, temp2);
224 for (slash = buf; *slash; slash++)
286 static int write_timestamp(
const char *maptype,
const char *dir,
287 const char *
name,
const struct TimeStamp *ts)
294 G_warning(_(
"Unable to create timestamp file for %s map <%s@%s>"),
303 G_warning(_(
"Invalid timestamp specified for %s map <%s@%s>"), maptype,
322 static int read_timestamp(
const char *maptype,
const char *dir,
323 const char *
name,
const char *mapset,
324 struct TimeStamp *ts)
333 G_warning(_(
"Unable to open timestamp file for %s map <%s@%s>"),
334 maptype,
name, mapset);
342 G_warning(_(
"Invalid timestamp file for %s map <%s@%s>"), maptype,
name,
375 struct TimeStamp *ts)
377 return read_timestamp(
"raster",
RAST_MISC,
name, mapset, ts);
426 char path[GPATH_MAX + GNAME_MAX];
430 snprintf(ele, GNAME_MAX,
"%s_%s", GV_TIMESTAMP_ELEMENT, layer);
432 snprintf(ele, GNAME_MAX,
"%s_1", GV_TIMESTAMP_ELEMENT);
434 snprintf(dir, GPATH_MAX,
"%s/%s", GV_DIRECTORY,
name);
439 if (access(
path, R_OK) != 0)
459 const char *mapset,
struct TimeStamp *ts)
471 snprintf(ele, GNAME_MAX,
"%s_%s", GV_TIMESTAMP_ELEMENT, layer);
473 snprintf(ele, GNAME_MAX,
"%s_1", GV_TIMESTAMP_ELEMENT);
475 snprintf(dir, GPATH_MAX,
"%s/%s", GV_DIRECTORY,
name);
477 G_debug(1,
"Read timestamp <%s/%s>", dir, ele);
482 G_warning(_(
"Unable to open timestamp file for vector map <%s@%s>"),
491 G_warning(_(
"Invalid timestamp file for vector map <%s@%s>"),
name, mapset);
508 const struct TimeStamp *ts)
516 snprintf(ele, GNAME_MAX,
"%s_%s", GV_TIMESTAMP_ELEMENT, layer);
518 snprintf(ele, GNAME_MAX,
"%s_1", GV_TIMESTAMP_ELEMENT);
520 snprintf(dir, GPATH_MAX,
"%s/%s", GV_DIRECTORY,
name);
522 G_debug(1,
"Write timestamp <%s/%s>", dir, ele);
527 G_warning(_(
"Unable to create timestamp file for vector map <%s@%s>"),
536 G_warning(_(
"Invalid timestamp specified for vector map <%s@%s>"),
name,
559 snprintf(ele, GNAME_MAX,
"%s_%s", GV_TIMESTAMP_ELEMENT, layer);
561 snprintf(ele, GNAME_MAX,
"%s_1", GV_TIMESTAMP_ELEMENT);
563 snprintf(dir, GPATH_MAX,
"%s/%s", GV_DIRECTORY,
name);
595 struct TimeStamp *ts)
597 return read_timestamp(
"raster3d",
GRID3,
name, mapset, ts);
613 return write_timestamp(
"raster3d",
GRID3,
name, ts);
void datetime_copy(DateTime *dst, const DateTime *src)
Copies the DateTime [into/from ???] src.
int G_debug(int level, const char *msg,...)
Print debugging message.
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
const char * G_find_file2_misc(const char *dir, const char *element, const char *name, const char *mapset)
Searches for a misc file from the mapset search list or in a specified mapset. (look but don't touch)
void G_warning(const char *msg,...)
Print a warning message to stderr.
FILE * G_fopen_new(const char *element, const char *name)
Open a new database file.
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.
const char * G_mapset(void)
Get current mapset name.
FILE * G_fopen_old_misc(const char *dir, const char *element, const char *name, const char *mapset)
open a database misc file for reading
FILE * G_fopen_new_misc(const char *dir, const char *element, const char *name)
open a new database misc file
int G_remove(const char *element, const char *name)
Remove a database file.
int G_remove_misc(const char *dir, const char *element, const char *name)
Remove a database misc file.
int datetime_scan(DateTime *dt, const char *buf)
Convert the ascii string into a DateTime. This determines the mode/from/to based on the string,...
void G_init_timestamp(struct TimeStamp *ts)
Initialize timestamp structure.
int G_read_raster_timestamp(const char *name, const char *mapset, struct TimeStamp *ts)
Read timestamp from raster map.
int G_has_raster_timestamp(const char *name, const char *mapset)
Check if timestamp for raster map exists.
int G_has_raster3d_timestamp(const char *name, const char *mapset)
Check if timestamp for 3D raster map exists.
int G_write_timestamp(FILE *fd, const struct TimeStamp *ts)
Output TimeStamp structure to a file as a formatted string.
int G_format_timestamp(const struct TimeStamp *ts, char *buf)
Create text string from TimeStamp structure.
int G_read_raster3d_timestamp(const char *name, const char *mapset, struct TimeStamp *ts)
Read timestamp from 3D raster map.
int G_remove_raster3d_timestamp(const char *name)
Remove timestamp from 3D raster map.
int G__read_timestamp(FILE *fd, struct TimeStamp *ts)
Read timestamp.
void G_set_timestamp(struct TimeStamp *ts, const DateTime *dt)
Set timestamp (single)
int G_write_raster_timestamp(const char *name, const struct TimeStamp *ts)
Write timestamp of raster map.
int G_scan_timestamp(struct TimeStamp *ts, const char *buf)
Fill a TimeStamp structure from a datetime string.
void G_set_timestamp_range(struct TimeStamp *ts, const DateTime *dt1, const DateTime *dt2)
Set timestamp (range)
int G_has_vector_timestamp(const char *name, const char *layer, const char *mapset)
Check if timestamp for vector map exists.
int G_read_vector_timestamp(const char *name, const char *layer, const char *mapset, struct TimeStamp *ts)
Read timestamp from vector map.
int G_write_raster3d_timestamp(const char *name, const struct TimeStamp *ts)
Write timestamp of 3D raster map.
int G_write_vector_timestamp(const char *name, const char *layer, const struct TimeStamp *ts)
Write timestamp of vector map.
int G_remove_vector_timestamp(const char *name, const char *layer)
Remove timestamp from vector map.
void G_get_timestamps(const struct TimeStamp *ts, DateTime *dt1, DateTime *dt2, int *count)
Copy TimeStamp into [two] Datetimes structs.
int G_remove_raster_timestamp(const char *name)
Remove timestamp from raster map.