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.

Defines

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

Functions

int Vect_cidx_get_num_fields (struct Map_info *Map)
 Get number of layer in category index.
int Vect_cidx_get_field_number (struct Map_info *Map, int index)
 Get layer number for given index.
int Vect_cidx_get_field_index (struct Map_info *Map, int field)
 Get layer index for given layer number.
int Vect_cidx_get_num_unique_cats_by_index (struct Map_info *Map, int index)
 Get number of unique categories for given layer index.
int Vect_cidx_get_num_cats_by_index (struct Map_info *Map, int index)
 Get number of categories for given layer index.
int Vect_cidx_get_num_types_by_index (struct Map_info *Map, int field_index)
 Get number of types for given layer 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.
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.
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.
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.
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.
int Vect_cidx_dump (struct Map_info *Map, FILE *out)
 Write category index in text form to file.
int Vect_cidx_save (struct Map_info *Map)
 Save category index.
int Vect_cidx_open (struct Map_info *Map, int head_only)
 Read category index from file if exists.


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.


Define Documentation

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

Definition at line 377 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] Map vector map
[out] out output file
Returns:
1 on success

0 on error

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

References SEP, 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] Map vector map
[in] layer layer number
[in] type_mask type of objects to search for
[in] cat category number
[out] lines array of ids of found lines/points
Returns:

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

References 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] Map vector map
[in] field_index layer index
[in] cat category number
[in] type_mask requested type
[in] start_index start search at this index (0 - whole category index)
[out] type returned type
[out] id returned line/area id
Returns:
index to array

-1 not found

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

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] Map vector map
[in] field_index layer index
[in] cat_index category index
[out] cat category number
[out] type feature type
[out] id feature id
Returns:
1 OK

0 on error

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

Referenced by Vect_cidx_dump().

int Vect_cidx_get_field_index ( struct Map_info *  Map,
int  field 
)

Get layer index for given layer number.

Parameters:
[in] Map vector map
[in] field layer number
Returns:
layer index

-1 if not found

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

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] Map vector map
[in] index layer index: from 0 to Vect_cidx_get_num_fields() - 1
Returns:
layer number

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

Referenced by 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] Map vector map
[in] index layer index
Returns:
number of categories

-1 on error

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

Referenced by Vect_cidx_dump().

int Vect_cidx_get_num_fields ( struct Map_info *  Map  ) 

Get number of layer in category index.

Parameters:
[in] Map vector map
Returns:
number of layers

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

Referenced by 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] Map vector map
[in] field_index layer index
Returns:
number of types

-1 on error

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

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] Map vector map
[in] index layer number
Returns:
number of unique categories

-1 on error

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

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] Map vector map
[in] field layer number
[in] type feature 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 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] Map vector map
[in] field_index layer index
[in] type_index type index
[out] type feature type
[out] count number of items
Returns:
1 OK

0 on error

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

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] Map vector map
[in] head_only Read only header
Returns:
0 on success

1 if file does not exist

-1 error, file exists but cannot be read

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

References dig_cidx_init(), dig_file_init(), and dig_read_cidx().

Referenced by Vect__open_old().

int Vect_cidx_save ( struct Map_info *  Map  ) 

Save category index.

Parameters:
[in] Map vector map
Returns:
0 on success

1 on error

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

References dig__byte_order_out(), dig_file_init(), dig_init_portable(), and dig_write_cidx().

Referenced by Vect_close().


Generated on Thu Jul 16 13:21:20 2009 for GRASS Programmer's Manual by  doxygen 1.5.6