GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Vlib/cindex.c File Reference

Vector library - Category index. More...

#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <grass/gis.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
Include dependency graph for Vlib/cindex.c:

Go to the source code of this file.

Macros

#define SEP   "------------------------------------------------------------------------------------------\n"
 

Functions

int Vect_cidx_get_num_fields (struct Map_info *Map)
 Get number of layer in category index. More...
 
int Vect_cidx_get_field_number (struct Map_info *Map, int index)
 Get layer number for given index. More...
 
int Vect_cidx_get_field_index (struct Map_info *Map, int field)
 Get layer index for given layer number. More...
 
int Vect_cidx_get_num_unique_cats_by_index (struct Map_info *Map, int index)
 Get number of unique categories for given layer index. More...
 
int Vect_cidx_get_num_cats_by_index (struct Map_info *Map, int index)
 Get number of categories for given layer index. More...
 
int Vect_cidx_get_num_types_by_index (struct Map_info *Map, int field_index)
 Get number of types for given layer index. More...
 
int Vect_cidx_get_type_count_by_index (struct Map_info *Map, int field_index, int type_index, int *type, int *count)
 Get type count field index and type index. More...
 
int Vect_cidx_get_type_count (struct Map_info *Map, int field, int type)
 Get count of features of certain type by layer and type. More...
 
int Vect_cidx_get_cat_by_index (struct Map_info *Map, int field_index, int cat_index, int *cat, int *type, int *id)
 Get number of categories for given field and category index. More...
 
int Vect_cidx_find_next (struct Map_info *Map, int field_index, int cat, int type_mask, int start_index, int *type, int *id)
 Find next line/area id for given category, start_index and type_mask. More...
 
void Vect_cidx_find_all (struct Map_info *Map, int layer, int type_mask, int cat, struct ilist *lines)
 Gind all line/area id's for given category. More...
 
int Vect_cidx_dump (struct Map_info *Map, FILE *out)
 Write category index in text form to file. More...
 
int Vect_cidx_save (struct Map_info *Map)
 Save category index. More...
 
int Vect_cidx_open (struct Map_info *Map, int head_only)
 Read category index from file if exists. More...
 

Detailed Description

Vector library - Category index.

Higher level functions for reading/writing/manipulating vectors.

Author
Radim Blazek

(C) 2001-2007 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Definition in file Vlib/cindex.c.

Macro Definition Documentation

#define SEP   "------------------------------------------------------------------------------------------\n"

Definition at line 378 of file Vlib/cindex.c.

Referenced by Vect_cidx_dump().

Function Documentation

int Vect_cidx_dump ( struct Map_info *  Map,
FILE *  out 
)

Write category index in text form to file.

Parameters
[in]Mapvector map
[out]outoutput file
Returns
1 on success
0 on error

Definition at line 389 of file Vlib/cindex.c.

References cat, count, G_debug(), tools::id, SEP, dialogs::type, Vect_cidx_get_cat_by_index(), Vect_cidx_get_field_number(), Vect_cidx_get_num_cats_by_index(), Vect_cidx_get_num_fields(), Vect_cidx_get_num_types_by_index(), Vect_cidx_get_num_unique_cats_by_index(), and Vect_cidx_get_type_count_by_index().

void Vect_cidx_find_all ( struct Map_info *  Map,
int  layer,
int  type_mask,
int  cat,
struct ilist *  lines 
)

Gind all line/area id's for given category.

Parameters
[in]Mapvector map
[in]layerlayer number
[in]type_masktype of objects to search for
[in]catcategory number
[out]linesarray of ids of found lines/points
Returns

Definition at line 342 of file Vlib/cindex.c.

References dialogs::type, Vect_cidx_find_next(), Vect_cidx_get_field_index(), Vect_list_append(), and Vect_reset_list().

int Vect_cidx_find_next ( struct Map_info *  Map,
int  field_index,
int  cat,
int  type_mask,
int  start_index,
int type,
int id 
)

Find next line/area id for given category, start_index and type_mask.

Parameters
[in]Mapvector map
[in]field_indexlayer index
[in]catcategory number
[in]type_maskrequested type
[in]start_indexstart search at this index (0 - whole category index)
[out]typereturned type
[out]idreturned line/area id
Returns
index to array
-1 not found

Definition at line 269 of file Vlib/cindex.c.

References G_debug(), and G_fatal_error().

Referenced by Vect_cidx_find_all().

int Vect_cidx_get_cat_by_index ( struct Map_info *  Map,
int  field_index,
int  cat_index,
int cat,
int type,
int id 
)

Get number of categories for given field and category index.

Parameters
[in]Mapvector map
[in]field_indexlayer index
[in]cat_indexcategory index
[out]catcategory number
[out]typefeature type
[out]idfeature id
Returns
1 OK
0 on error

Definition at line 225 of file Vlib/cindex.c.

References G_fatal_error().

Referenced by wxdigit.IVDigit::InitCats(), and Vect_cidx_dump().

int Vect_cidx_get_field_index ( struct Map_info *  Map,
int  field 
)

Get layer index for given layer number.

Parameters
[in]Mapvector map
[in]fieldlayer number
Returns
layer index
-1 if not found

Definition at line 75 of file Vlib/cindex.c.

References G_debug().

Referenced by Vect_cidx_find_all(), and Vect_cidx_get_type_count().

int Vect_cidx_get_field_number ( struct Map_info *  Map,
int  index 
)

Get layer number for given index.

Parameters
[in]Mapvector map
[in]indexlayer index: from 0 to Vect_cidx_get_num_fields() - 1
Returns
layer number

Definition at line 56 of file Vlib/cindex.c.

References G_fatal_error().

Referenced by wxdigit.IVDigit::InitCats(), and Vect_cidx_dump().

int Vect_cidx_get_num_cats_by_index ( struct Map_info *  Map,
int  index 
)

Get number of categories for given layer index.

Parameters
[in]Mapvector map
[in]indexlayer index
Returns
number of categories
-1 on error

Definition at line 121 of file Vlib/cindex.c.

References G_fatal_error().

Referenced by wxdigit.IVDigit::InitCats(), and Vect_cidx_dump().

int Vect_cidx_get_num_fields ( struct Map_info *  Map)

Get number of layer in category index.

Parameters
[in]Mapvector map
Returns
number of layers

Definition at line 41 of file Vlib/cindex.c.

Referenced by wxdigit.IVDigit::InitCats(), and Vect_cidx_dump().

int Vect_cidx_get_num_types_by_index ( struct Map_info *  Map,
int  field_index 
)

Get number of types for given layer index.

Parameters
[in]Mapvector map
[in]field_indexlayer index
Returns
number of types
-1 on error

Definition at line 139 of file Vlib/cindex.c.

References G_fatal_error().

Referenced by Vect_cidx_dump().

int Vect_cidx_get_num_unique_cats_by_index ( struct Map_info *  Map,
int  index 
)

Get number of unique categories for given layer index.

Parameters
[in]Mapvector map
[in]indexlayer number
Returns
number of unique categories
-1 on error

Definition at line 102 of file Vlib/cindex.c.

References G_fatal_error().

Referenced by Vect_cidx_dump().

int Vect_cidx_get_type_count ( struct Map_info *  Map,
int  field,
int  type 
)

Get count of features of certain type by layer and type.

Parameters
[in]Mapvector map
[in]fieldlayer number
[in]typefeature type
Returns
feature count
0 if no features, no such field or no such type in cidx

Definition at line 184 of file Vlib/cindex.c.

References count, G_debug(), and Vect_cidx_get_field_index().

int Vect_cidx_get_type_count_by_index ( struct Map_info *  Map,
int  field_index,
int  type_index,
int type,
int count 
)

Get type count field index and type index.

Parameters
[in]Mapvector map
[in]field_indexlayer index
[in]type_indextype index
[out]typefeature type
[out]countnumber of items
Returns
1 OK
0 on error

Definition at line 161 of file Vlib/cindex.c.

References G_fatal_error().

Referenced by Vect_cidx_dump().

int Vect_cidx_open ( struct Map_info *  Map,
int  head_only 
)

Read category index from file if exists.

Parameters
[in]Mapvector map
[in]head_onlyRead only header
Returns
0 on success
1 if file does not exist
-1 error, file exists but cannot be read

Definition at line 488 of file Vlib/cindex.c.

References buf, dig_cidx_init(), dig_file_init(), dig_read_cidx(), fclose(), G__file_name(), G_debug(), G_fopen_old(), G_warning(), NULL, sprintf(), and stat.

Referenced by Vect__open_old().

int Vect_cidx_save ( struct Map_info *  Map)

Save category index.

Parameters
[in]Mapvector map
Returns
0 on success
1 on error

Definition at line 444 of file Vlib/cindex.c.

References buf, dig__byte_order_out(), dig_file_init(), dig_init_portable(), dig_write_cidx(), fclose(), G__file_name(), G_debug(), G_warning(), NULL, and sprintf().

Referenced by Vect_close().