22 #include <sys/types.h>
25 #include <grass/Vect.h>
26 #include <grass/gis.h>
27 #include <grass/glocale.h>
29 static char name_buf[GPATH_MAX];
30 static int check_coor(
struct Map_info *
Map);
47 G_debug(1,
"V1_open_old_nat(): name = %s mapset = %s", Map->name,
50 sprintf(buf,
"%s/%s", GRASS_VECT_DIRECTORY, Map->name);
56 G_fopen_old(buf, GRASS_VECT_COOR_ELEMENT, Map->mapset);
58 if (Map->dig_fp.file ==
NULL)
91 G_debug(1,
"V1_open_new_nat(): name = %s", name);
93 sprintf(buf,
"%s/%s", GRASS_VECT_DIRECTORY, name);
96 Map->head.Version_Major = GV_COOR_VER_MAJOR;
97 Map->head.Version_Minor = GV_COOR_VER_MINOR;
98 Map->head.Back_Major = GV_COOR_EARLIEST_MAJOR;
99 Map->head.Back_Minor = GV_COOR_EARLIEST_MINOR;
103 Map->dig_fp.file =
G_fopen_new(buf, GRASS_VECT_COOR_ELEMENT);
104 if (Map->dig_fp.file ==
NULL)
110 if (Map->dig_fp.file ==
NULL)
115 if (
stat(name_buf, &info) == 0)
121 Map->head.head_size = GV_COOR_HEAD_SIZE;
134 int check_coor(
struct Map_info *
Map)
136 struct Coor_info CInfo;
140 dif = CInfo.size - Map->head.size;
141 G_debug(1,
"coor size in head = %ld, real coor file size= %ld",
142 Map->head.size, CInfo.size);
145 G_warning(_(
"Coor files of vector map <%s@%s> is larger than it should be "
146 "(%ld bytes excess)"), Map->name, Map->mapset, dif);
149 G_warning(_(
"Coor files of vector <%s@%s> is shorter than it should be "
150 "(%ld bytes missing)."), Map->name, Map->mapset, -dif);
char * G_mapset(void)
current mapset name
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
int V1_open_new_nat(struct Map_info *Map, const char *name, int with_z)
Open/Create new vector map.
FILE * G_fopen_modify(const char *element, const char *name)
Open a database file for update (r+ mode)
int dig__read_head(struct Map_info *Map)
void dig_init_portable(struct Port_info *port, int byte_order)
char * G__file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
int Vect_coor_info(struct Map_info *Map, struct Coor_info *Info)
Update Coor_info structure.
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
FILE * G_fopen_new(const char *element, const char *name)
Open a new database file.
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int G_debug(int level, const char *msg,...)
Print debugging message.
void dig_file_init(GVFILE *file)
Initialize GVFILE.
int dig_file_load(GVFILE *file)
Load opened GVFILE to memory.
int dig__byte_order_out()
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.
int V1_open_old_nat(struct Map_info *Map, int update)
Open existing vector map.
int dig__write_head(struct Map_info *Map)