19 #include <grass/gis.h>
20 #include <grass/Vect.h>
21 #include <grass/version.h>
33 buf[0] = GV_SIDX_VER_MAJOR;
34 buf[1] = GV_SIDX_VER_MINOR;
35 buf[2] = GV_SIDX_EARLIEST_MAJOR;
36 buf[3] = GV_SIDX_EARLIEST_MINOR;
37 buf[4] = ptr->spidx_port.byte_order;
46 buf[0] = ptr->spidx_with_z;
66 G_debug(3,
"spidx offset node = %ld line = %ld, area = %ld isle = %ld",
67 ptr->Node_spidx_offset, ptr->Line_spidx_offset,
68 ptr->Area_spidx_offset, ptr->Isle_spidx_offset);
91 ptr->spidx_Version_Major = buf[0];
92 ptr->spidx_Version_Minor = buf[1];
93 ptr->spidx_Back_Major = buf[2];
94 ptr->spidx_Back_Minor = buf[3];
98 "Sidx header: file version %d.%d , supported from GRASS version %d.%d",
99 ptr->spidx_Version_Major, ptr->spidx_Version_Minor,
100 ptr->spidx_Back_Major, ptr->spidx_Back_Minor);
102 G_debug(2,
" byte order %d", byte_order);
105 if (ptr->spidx_Version_Major > GV_SIDX_VER_MAJOR ||
106 ptr->spidx_Version_Minor > GV_SIDX_VER_MINOR) {
109 if (ptr->spidx_Back_Major > GV_SIDX_VER_MAJOR ||
110 ptr->spidx_Back_Minor > GV_SIDX_VER_MINOR) {
112 G_debug(1,
"Spatial index format version %d.%d",
113 ptr->spidx_Version_Major, ptr->spidx_Version_Minor);
115 (
"This version of GRASS (%d.%d) is too old to read this spatial index format."
116 " Try to rebuild topology or upgrade GRASS to at least version %d.",
117 GRASS_VERSION_MAJOR, GRASS_VERSION_MINOR, GRASS_VERSION_MAJOR + 1);
122 (
"Your GRASS version does not fully support spatial index format %d.%d of the vector."
123 " Consider to rebuild topology or upgrade GRASS.",
124 ptr->spidx_Version_Major, ptr->spidx_Version_Minor);
133 G_debug(2,
" header size %ld", ptr->spidx_head_size);
138 ptr->spidx_with_z = buf[0];
139 G_debug(2,
" with_z %d", ptr->spidx_with_z);
160 G_debug(2,
" coor size %ld", coor_size);
162 dig_fseek(fp, ptr->spidx_head_size, SEEK_SET);
177 fprintf(fp,
" id = %d ", (
int)b->
child);
193 fprintf(fp,
"Node level=%d count=%d\n", n->
level, n->
count);
200 for (i = 0; i < nn; i++) {
202 fprintf(fp,
" Branch %d", i);
259 for (i = 0; i < nn; i++) {
276 G_debug(3,
"rtree_read_branch()");
312 G_debug(3,
"rtree_read_node()");
324 for (i = 0; i <
count; i++) {
361 G_debug(1,
"dig_read_spindx()");
370 dig_fseek(fp, Plus->Node_spidx_offset, 0);
373 dig_fseek(fp, Plus->Line_spidx_offset, 0);
376 dig_fseek(fp, Plus->Area_spidx_offset, 0);
379 dig_fseek(fp, Plus->Isle_spidx_offset, 0);
389 fprintf(fp,
"Nodes\n");
392 fprintf(fp,
"Lines\n");
395 fprintf(fp,
"Areas\n");
398 fprintf(fp,
"Isles\n");
int rtree_read_branch(GVFILE *fp, struct Branch *b, int with_z, int level)
RectReal boundary[NUMSIDES]
int dig_dump_spidx(FILE *fp, struct Plus_head *Plus)
int rtree_write_node(GVFILE *fp, struct Node *n, int with_z)
int dig_set_cur_port(struct Port_info *port)
int dig_Wr_spindx_head(GVFILE *fp, struct Plus_head *ptr)
int dig_spidx_init(struct Plus_head *Plus)
Initit spatial index (nodes, lines, areas, isles)
int dig__fwrite_port_D(double *buf, int cnt, GVFILE *fp)
int rtree_write_branch(GVFILE *fp, struct Branch *b, int with_z, int level)
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)
struct Node * RTreeNewNode(void)
int dig_fseek(GVFILE *file, long offset, int whence)
Set GVFILE position.
int dig_Rd_spindx_head(GVFILE *fp, struct Plus_head *ptr)
int dig_read_spidx(GVFILE *fp, struct Plus_head *Plus)
int dig__fwrite_port_L(long *buf, int cnt, GVFILE *fp)
int dig__fread_port_D(double *buf, int cnt, GVFILE *fp)
int dig_write_spidx(GVFILE *fp, struct Plus_head *Plus)
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
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 rtree_dump_node(FILE *fp, struct Node *n, int with_z)
int G_debug(int level, const char *msg,...)
Print debugging message.
void dig_rewind(GVFILE *file)
Rewind GVFILE position.
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.
int rtree_read_node(GVFILE *fp, struct Node *n, int with_z)
long dig_ftell(GVFILE *file)
Get GVFILE position.
struct Branch branch[MAXCARD]
int dig__fread_port_I(int *buf, int cnt, GVFILE *fp)
int rtree_dump_branch(FILE *fp, struct Branch *b, int with_z, int level)