[GRASS5] Category index

Radim Blazek blazek at itc.it
Tue Feb 17 04:24:38 EST 2004


Hi all,

I am working on category index (cidx) for GRASS vectors. Cidx should 
improve performance of all selections by cats/attributes(sql)
(d.vect cats=27591, v.extract list=20000-21000). Currently all
such selections are made by loop through all lines. Cidx is also essential
for simple feature representation of GRASS vectors (mail about that will 
follow later).

Cidx is created for each field. In memory it is stored in
struct Cat_index {
    int field;      /* field number */
    int n_cats;     /* number of items in cat array */
    int a_cats;     /* allocated space in cat array */
    int (*cat)[3];  /* array of cats (cat, type, lines/area) */
    int n_ucats;    /* number of unique cats */
    int n_types;    /* number of types in type */
    int type[7][2]; /* number of elements for each type (point, line, boundary, centroid, area, face, kernel) */    
    long offset;    /* offset of the beginning of this index in cidx file */
};

Cidx is built with topology, but it is not updated if vector is edited on level 2.
Cidx is stored in 'cidx' file, 'cat' array is written/read by one call of
dig__fwrite_port_I ( (int *)ci->cat, 3 * ci->n_cats, fp)
dig__fread_port_I ( (int *)ci->cat, 3 * ci->n_cats, fp)

Stored values can be retrieved either by index in 'cat' array 
(if all features of given field are required) or by category value
(one or few features), always by Vect_cidx_* functions.

To create cidx, it will be necessary to rebuild topology for all existing vectors.
This is an opportunity to make (hopefully) last changes in 'topo', 'sidx' formats.

Do you have any suggestions/comments for cidx (topo/sidx)?

Radim
 









More information about the grass-dev mailing list