19 #include <grass/gis.h>
20 #include <grass/Vect.h>
21 #include <grass/version.h>
29 G_debug(3,
"dig_write_cidx_head()");
36 buf[0] = GV_CIDX_VER_MAJOR;
37 buf[1] = GV_CIDX_VER_MINOR;
38 buf[2] = GV_CIDX_EARLIEST_MAJOR;
39 buf[3] = GV_CIDX_EARLIEST_MINOR;
40 buf[4] = plus->cidx_port.byte_order;
53 for (i = 0; i < plus->n_cidx; i++) {
57 ci = &(plus->cidx[i]);
78 for (t = 0; t < ci->n_types; t++) {
95 G_debug(3,
"cidx %d offset: %ld", i, ci->offset);
106 unsigned char buf[5];
114 plus->cidx_Version_Major = buf[0];
115 plus->cidx_Version_Minor = buf[1];
116 plus->cidx_Back_Major = buf[2];
117 plus->cidx_Back_Minor = buf[3];
121 "Cidx header: file version %d.%d , supported from GRASS version %d.%d",
122 plus->cidx_Version_Major, plus->cidx_Version_Minor,
123 plus->cidx_Back_Major, plus->cidx_Back_Minor);
125 G_debug(3,
" byte order %d", byte_order);
128 if (plus->cidx_Version_Major > GV_CIDX_VER_MAJOR ||
129 plus->cidx_Version_Minor > GV_CIDX_VER_MINOR) {
132 if (plus->cidx_Back_Major > GV_CIDX_VER_MAJOR ||
133 plus->cidx_Back_Minor > GV_CIDX_VER_MINOR) {
135 G_debug(1,
"Category index format version %d.%d",
136 plus->cidx_Version_Major, plus->cidx_Version_Minor);
138 (
"This version of GRASS (%d.%d) is too old to read this category index format."
139 " Try to rebuild topology or upgrade GRASS to at least version %d.",
140 GRASS_VERSION_MAJOR, GRASS_VERSION_MINOR, GRASS_VERSION_MAJOR + 1);
145 (
"Your GRASS version does not fully support category index format %d.%d of the vector."
146 " Consider to rebuild topology or upgrade GRASS.",
147 plus->cidx_Version_Major, plus->cidx_Version_Minor);
156 G_debug(3,
" header size %ld", plus->cidx_head_size);
164 plus->a_cidx = plus->n_cidx;
166 (
struct Cat_index *)G_malloc(plus->a_cidx *
sizeof(
struct Cat_index));
168 for (i = 0; i < plus->n_cidx; i++) {
170 struct Cat_index *ci;
172 ci = &(plus->cidx[i]);
193 for (t = 0; t < ci->n_types; t++) {
211 if (
dig_fseek(fp, plus->cidx_head_size, SEEK_SET) == -1)
228 for (i = 0; i < plus->n_cidx; i++) {
230 struct Cat_index *ci;
232 ci = &(plus->cidx[i]);
236 for (j = 0; j < ci->n_cats; j++)
243 for (j = 0; j < ci->n_cats; j++)
266 G_debug(3,
"Cannot read cidx head");
271 plus->cidx_up_to_date = 1;
278 for (i = 0; i < plus->n_cidx; i++) {
280 struct Cat_index *ci;
282 ci = &(plus->cidx[i]);
283 ci->a_cats = ci->n_cats;
284 ci->cat = G_malloc(ci->a_cats * 3 *
sizeof(
int));
293 for (j = 0; j < ci->n_cats; j++)
298 plus->cidx_up_to_date = 1;
int dig_set_cur_port(struct Port_info *port)
void dig_init_portable(struct Port_info *port, int byte_order)
int dig__fread_port_L(long *buf, int cnt, GVFILE *fp)
int dig__fwrite_port_I(int *buf, int cnt, GVFILE *fp)
int dig_fseek(GVFILE *file, long offset, int whence)
Set GVFILE position.
int dig_write_cidx_head(GVFILE *fp, struct Plus_head *plus)
int dig_read_cidx_head(GVFILE *fp, struct Plus_head *plus)
int dig__fwrite_port_L(long *buf, int cnt, GVFILE *fp)
int dig_type_from_store(int stype)
Convert type from store type.
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
int dig_cidx_init(struct Plus_head *Plus)
int dig_read_cidx(GVFILE *fp, struct Plus_head *plus, int head_only)
int dig__fread_port_C(char *buf, int cnt, GVFILE *fp)
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int dig_type_to_store(int type)
Convert type to store type.
int G_debug(int level, const char *msg,...)
Print debugging message.
void dig_rewind(GVFILE *file)
Rewind GVFILE position.
int dig_write_cidx(GVFILE *fp, struct Plus_head *plus)
int dig__fwrite_port_C(char *buf, int cnt, GVFILE *fp)
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
long dig_ftell(GVFILE *file)
Get GVFILE position.
int dig__fread_port_I(int *buf, int cnt, GVFILE *fp)