50 for (i = 0; i < Plus->
n_cidx; i++) {
51 ci = &(Plus->
cidx[i]);
78 G_debug(3,
"dig_cidx_add_cat(): field = %d cat = %d line = %d type = %d",
83 for (i = 0; i < Plus->
n_cidx; i++) {
97 ci = &(Plus->
cidx[si]);
107 ci = &(Plus->
cidx[si]);
120 for (i = 0; i < ci->
n_types; i++) {
136 static int cmp_cat(
const void *pa,
const void *pb)
157 static int cmp_field(
const void *pa,
const void *pb)
180 int i, si, found, position;
184 3,
"dig_cidx_add_cat_sorted(): field = %d cat = %d line = %d type = %d",
189 for (i = 0; i < Plus->
n_cidx; i++) {
203 ci = &(Plus->
cidx[si]);
213 ci = &(Plus->
cidx[si]);
220 for (position = ci->
n_cats; position > 0; position--) {
221 if (ci->
cat[position - 1][0] <
cat ||
222 (ci->
cat[position - 1][0] ==
cat &&
223 ci->
cat[position - 1][1] <=
type)) {
226 ci->
cat[position][0] = ci->
cat[position - 1][0];
227 ci->
cat[position][1] = ci->
cat[position - 1][1];
228 ci->
cat[position][2] = ci->
cat[position - 1][2];
231 G_debug(4,
"position = %d", position);
233 ci->
cat[position][0] =
cat;
235 ci->
cat[position][2] = line;
240 for (i = 0; i < ci->
n_types; i++) {
255 G_debug(3,
"Added new category to index");
273 G_debug(3,
"dig_cidx_del_cat(): field = %d cat = %d line = %d",
field,
cat,
278 for (i = 0; i < Plus->
n_cidx; i++) {
280 ci = &(Plus->
cidx[i]);
290 for (position = 0; position < ci->
n_cats; position++) {
291 if (ci->
cat[position][0] ==
cat && ci->
cat[position][1] ==
type &&
292 ci->
cat[position][2] == line) {
297 G_debug(4,
"position = %d", position);
299 if (position == ci->
n_cats) {
300 G_warning(
"BUG: Category not found in category index.");
305 for (i = position; i < ci->
n_cats - 1; i++) {
306 ci->
cat[i][0] = ci->
cat[i + 1][0];
307 ci->
cat[i][1] = ci->
cat[i + 1][1];
308 ci->
cat[i][2] = ci->
cat[i + 1][2];
313 for (i = 0; i < ci->
n_types; i++) {
319 G_debug(3,
"Deleted from category index");
335 for (f = 0; f < Plus->
n_cidx; f++) {
338 ci = &(Plus->
cidx[f]);
341 qsort(ci->
cat, ci->
n_cats, 3 *
sizeof(
int), cmp_cat);
346 for (c = 1; c < ci->
n_cats; c++) {
347 if (ci->
cat[c][0] != ci->
cat[c - 1][0])
void G_free(void *)
Free allocated memory.
void G_warning(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int dig_cidx_init(struct Plus_head *Plus)
Initialize Plus_head structure (cidx)
void dig_cidx_free(struct Plus_head *Plus)
int dig_cidx_del_cat(struct Plus_head *Plus, int field, int cat, int line, int type)
void dig_cidx_sort(struct Plus_head *Plus)
int dig_cidx_add_cat_sorted(struct Plus_head *Plus, int field, int cat, int line, int type)
int dig_cidx_add_cat(struct Plus_head *Plus, int field, int cat, int line, int type)
int n_types
Number of types in type.
int(* cat)[3]
Array of cats (cat, type, lines/area)
int a_cats
Allocated space in cat array.
int n_cats
Number of items in cat array.
off_t offset
Offset of the beginning of this index in cidx file.
int field
Field (layer) number.
int type[7][2]
Number of elements for each type.
int n_ucats
Number of unique cats (not updated)
Basic topology-related info.
int n_cidx
Number of category indexes (one for each field/layer)
int a_cidx
Allocated space for category indexes.
int cidx_up_to_date
Category index to be updated.
struct Version_info cidx
Version info for category index file.