Forráskód Böngészése

vlib: modify prototypes to use 'const'

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@36588 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 éve
szülő
commit
1118067a86
72 módosított fájl, 1244 hozzáadás és 1381 törlés
  1. 156 156
      include/Vect.h
  2. 15 15
      include/vect/dig_externs.h
  3. 44 45
      lib/vector/Vlib/area.c
  4. 27 28
      lib/vector/Vlib/array.c
  5. 35 35
      lib/vector/Vlib/box.c
  6. 1 3
      lib/vector/Vlib/break_lines.c
  7. 12 11
      lib/vector/Vlib/break_polygons.c
  8. 12 14
      lib/vector/Vlib/bridges.c
  9. 10 6
      lib/vector/Vlib/buffer.c
  10. 6 54
      lib/vector/Vlib/buffer2.c
  11. 25 23
      lib/vector/Vlib/build.c
  12. 7 9
      lib/vector/Vlib/build_nat.c
  13. 4 5
      lib/vector/Vlib/build_ogr.c
  14. 27 27
      lib/vector/Vlib/cats.c
  15. 56 57
      lib/vector/Vlib/cindex.c
  16. 8 12
      lib/vector/Vlib/clean_nodes.c
  17. 5 9
      lib/vector/Vlib/close.c
  18. 23 20
      lib/vector/Vlib/close_nat.c
  19. 39 32
      lib/vector/Vlib/close_ogr.c
  20. 21 24
      lib/vector/Vlib/constraint.c
  21. 14 16
      lib/vector/Vlib/dangles.c
  22. 7 11
      lib/vector/Vlib/dbcolumns.c
  23. 24 21
      lib/vector/Vlib/dgraph.c
  24. 1 1
      lib/vector/Vlib/dgraph.h
  25. 15 2
      lib/vector/Vlib/e_intersect.c
  26. 6 10
      lib/vector/Vlib/error.c
  27. 23 26
      lib/vector/Vlib/field.c
  28. 30 33
      lib/vector/Vlib/find.c
  29. 1 1
      lib/vector/Vlib/geos.c
  30. 10 14
      lib/vector/Vlib/graph.c
  31. 55 49
      lib/vector/Vlib/header.c
  32. 12 15
      lib/vector/Vlib/hist.c
  33. 10 14
      lib/vector/Vlib/init_head.c
  34. 68 71
      lib/vector/Vlib/intersect.c
  35. 7 11
      lib/vector/Vlib/legal_vname.c
  36. 5 9
      lib/vector/Vlib/level.c
  37. 19 21
      lib/vector/Vlib/level_two.c
  38. 19 23
      lib/vector/Vlib/line.c
  39. 12 14
      lib/vector/Vlib/list.c
  40. 32 34
      lib/vector/Vlib/map.c
  41. 23 26
      lib/vector/Vlib/net.c
  42. 31 31
      lib/vector/Vlib/open.c
  43. 9 13
      lib/vector/Vlib/open_nat.c
  44. 6 10
      lib/vector/Vlib/open_ogr.c
  45. 24 17
      lib/vector/Vlib/overlap.c
  46. 6 9
      lib/vector/Vlib/overlay.c
  47. 20 24
      lib/vector/Vlib/poly.c
  48. 8 10
      lib/vector/Vlib/read.c
  49. 16 20
      lib/vector/Vlib/read_nat.c
  50. 12 16
      lib/vector/Vlib/read_ogr.c
  51. 7 12
      lib/vector/Vlib/remove_areas.c
  52. 9 12
      lib/vector/Vlib/remove_duplicates.c
  53. 5 9
      lib/vector/Vlib/rewind.c
  54. 32 21
      lib/vector/Vlib/rewind_nat.c
  55. 29 18
      lib/vector/Vlib/rewind_ogr.c
  56. 10 15
      lib/vector/Vlib/select.c
  57. 11 15
      lib/vector/Vlib/sindex.c
  58. 25 28
      lib/vector/Vlib/snap.c
  59. 3 7
      lib/vector/Vlib/tin.c
  60. 4 8
      lib/vector/Vlib/type.c
  61. 14 17
      lib/vector/Vlib/window.c
  62. 6 9
      lib/vector/Vlib/write.c
  63. 15 17
      lib/vector/Vlib/write_nat.c
  64. 1 1
      lib/vector/diglib/box.c
  65. 2 2
      lib/vector/diglib/plus_line.c
  66. 1 1
      lib/vector/diglib/plus_node.c
  67. 8 8
      lib/vector/diglib/portable.c
  68. 4 4
      lib/vector/diglib/spindex.c
  69. 0 9
      vector/v.buffer2/local_proto.h
  70. 0 1
      vector/v.buffer2/main.c
  71. 0 9
      vector/v.parallel2/local_proto.h
  72. 0 1
      vector/v.parallel2/main.c

+ 156 - 156
include/Vect.h

@@ -15,39 +15,39 @@
 /* Points (line) */
 struct line_pnts *Vect_new_line_struct(void);
 int Vect_append_point(struct line_pnts *, double, double, double);
-int Vect_append_points(struct line_pnts *, struct line_pnts *, int);
+int Vect_append_points(struct line_pnts *, const struct line_pnts *, int);
 int Vect_line_insert_point(struct line_pnts *, int, double, double, double);
 int Vect_line_delete_point(struct line_pnts *, int);
 int Vect_line_prune(struct line_pnts *);
 int Vect_line_prune_thresh(struct line_pnts *, double);
 void Vect_line_reverse(struct line_pnts *);
-int Vect_copy_xyz_to_pnts(struct line_pnts *, double *, double *, double *,
+int Vect_copy_xyz_to_pnts(struct line_pnts *, const double *, const double *, const double *,
 			  int);
-int Vect_copy_pnts_to_xyz(struct line_pnts *, double *, double *, double *,
+int Vect_copy_pnts_to_xyz(const struct line_pnts *, double *, double *, double *,
 			  int *);
 int Vect_reset_line(struct line_pnts *);
 int Vect_destroy_line_struct(struct line_pnts *);
-int Vect_point_on_line(struct line_pnts *, double, double *, double *,
+int Vect_point_on_line(const struct line_pnts *, double, double *, double *,
 		       double *, double *, double *);
-int Vect_line_segment(struct line_pnts *, double, double, struct line_pnts *);
-double Vect_line_length(struct line_pnts *);
-double Vect_area_perimeter(struct line_pnts *);
-double Vect_line_geodesic_length(struct line_pnts *);
-int Vect_line_distance(struct line_pnts *, double, double, double, int,
+int Vect_line_segment(const struct line_pnts *, double, double, struct line_pnts *);
+double Vect_line_length(const struct line_pnts *);
+double Vect_area_perimeter(const struct line_pnts *);
+double Vect_line_geodesic_length(const struct line_pnts *);
+int Vect_line_distance(const struct line_pnts *, double, double, double, int,
 		       double *, double *, double *, double *, double *,
 		       double *);
-int Vect_line_box(struct line_pnts *, BOUND_BOX *);
+int Vect_line_box(const struct line_pnts *, BOUND_BOX *);
 void Vect_line_parallel(struct line_pnts *, double, double, int,
 			struct line_pnts *);
 void Vect_line_parallel2(struct line_pnts *, double, double,
 			 double, int, int, double,
 			 struct line_pnts *);
-void Vect_line_buffer(struct line_pnts *, double, double, struct line_pnts *);
-void Vect_line_buffer2(struct line_pnts *, double, double,
+void Vect_line_buffer(const struct line_pnts *, double, double, struct line_pnts *);
+void Vect_line_buffer2(const struct line_pnts *, double, double,
 		       double, int, int, double,
 		       struct line_pnts **,
 		       struct line_pnts ***, int *);
-void Vect_area_buffer2(struct Map_info *, int, double, double,
+void Vect_area_buffer2(const struct Map_info *, int, double, double,
 		       double, int, int, double,
 		       struct line_pnts **,
 		       struct line_pnts ***, int *);
@@ -59,31 +59,31 @@ void Vect_point_buffer2(double, double, double, double,
 /* Categories */
 struct line_cats *Vect_new_cats_struct(void);
 int Vect_cat_set(struct line_cats *, int, int);
-int Vect_cat_get(struct line_cats *, int, int *);
+int Vect_cat_get(const struct line_cats *, int, int *);
 int Vect_cat_del(struct line_cats *, int);
 int Vect_field_cat_del(struct line_cats *, int, int);
-int Vect_field_cat_get(struct line_cats *, int, struct ilist *);
-int Vect_cat_in_array(int, int *, int);
+int Vect_field_cat_get(const struct line_cats *, int, struct ilist *);
+int Vect_cat_in_array(int, const int *, int);
 int Vect_reset_cats(struct line_cats *);
 int Vect_destroy_cats_struct(struct line_cats *);
-int Vect_get_area_cats(struct Map_info *, int, struct line_cats *);
-int Vect_get_area_cat(struct Map_info *, int, int);
-int Vect_get_line_cat(struct Map_info *, int, int);
+int Vect_get_area_cats(const struct Map_info *, int, struct line_cats *);
+int Vect_get_area_cat(const struct Map_info *, int, int);
+int Vect_get_line_cat(const struct Map_info *, int, int);
 
 /* List of categories */
 struct cat_list *Vect_new_cat_list(void);
 int Vect_str_to_cat_list(const char *, struct cat_list *);
-int Vect_array_to_cat_list(int *, int, struct cat_list *);
-int Vect_cat_in_cat_list(int, struct cat_list *);
+int Vect_array_to_cat_list(const int *, int, struct cat_list *);
+int Vect_cat_in_cat_list(int, const struct cat_list *);
 int Vect_destroy_cat_list(struct cat_list *);
 
 /* Vector array */
-VARRAY *Vect_new_varray(int size);
-int Vect_set_varray_from_cat_string(struct Map_info *, int, const char *, int,
+VARRAY *Vect_new_varray(int);
+int Vect_set_varray_from_cat_string(const struct Map_info *, int, const char *, int,
 				    int, VARRAY *);
-int Vect_set_varray_from_cat_list(struct Map_info *, int, struct cat_list *,
+int Vect_set_varray_from_cat_list(const struct Map_info *, int, struct cat_list *,
 				  int, int, VARRAY *);
-int Vect_set_varray_from_db(struct Map_info *, int, const char *, int, int,
+int Vect_set_varray_from_db(const struct Map_info *, int, const char *, int, int,
 			    VARRAY *);
 
 /* DB connection - field info */
@@ -91,109 +91,109 @@ struct dblinks *Vect_new_dblinks_struct(void);
 void Vect_reset_dblinks(struct dblinks *);
 int Vect_add_dblink(struct dblinks *, int, const char *,
 		    const char *, const char *, const char *, const char *);
-int Vect_check_dblink(struct dblinks *, int);
+int Vect_check_dblink(const struct dblinks *, int);
 int Vect_map_add_dblink(struct Map_info *, int, const char *,
 			const char *, const char *, const char *,
 			const char *);
 int Vect_map_del_dblink(struct Map_info *, int);
-int Vect_map_check_dblink(struct Map_info *, int);
+int Vect_map_check_dblink(const struct Map_info *, int);
 int Vect_read_dblinks(struct Map_info *);
 int Vect_write_dblinks(struct Map_info *);
 struct field_info *Vect_default_field_info(struct Map_info *, int,
 					   const char *, int);
-struct field_info *Vect_get_dblink(struct Map_info *, int);
-struct field_info *Vect_get_field(struct Map_info *, int);
+struct field_info *Vect_get_dblink(const struct Map_info *, int);
+struct field_info *Vect_get_field(const struct Map_info *, int);
 void Vect_set_db_updated(struct Map_info *);
-const char *Vect_get_column_names(struct Map_info *, int);
-const char *Vect_get_column_types(struct Map_info *, int);
-const char *Vect_get_column_names_types(struct Map_info *, int);
+const char *Vect_get_column_names(const struct Map_info *, int);
+const char *Vect_get_column_types(const struct Map_info *, int);
+const char *Vect_get_column_names_types(const struct Map_info *, int);
 
 /* List of FID (feature ID) (integers) */
 struct ilist *Vect_new_list(void);
 int Vect_list_append(struct ilist *, int);
-int Vect_list_append_list(struct ilist *, struct ilist *);
+int Vect_list_append_list(struct ilist *, const struct ilist *);
 int Vect_list_delete(struct ilist *, int);
-int Vect_list_delete_list(struct ilist *, struct ilist *);
-int Vect_val_in_list(struct ilist *, int);
+int Vect_list_delete_list(struct ilist *, const struct ilist *);
+int Vect_val_in_list(const struct ilist *, int);
 int Vect_reset_list(struct ilist *);
 int Vect_destroy_list(struct ilist *);
 
 /* Bounding box (MBR) */
-int Vect_point_in_box(double, double, double, BOUND_BOX *);
-int Vect_box_overlap(BOUND_BOX *, BOUND_BOX *);
-int Vect_box_copy(BOUND_BOX *, BOUND_BOX *);
-int Vect_box_extend(BOUND_BOX *, BOUND_BOX *);
-int Vect_box_clip(double *, double *, double *, double *, BOUND_BOX *);
-int Vect_region_box(struct Cell_head *, BOUND_BOX *);
+int Vect_point_in_box(double, double, double, const BOUND_BOX *);
+int Vect_box_overlap(const BOUND_BOX *, const BOUND_BOX *);
+int Vect_box_copy(BOUND_BOX *, const BOUND_BOX *);
+int Vect_box_extend(BOUND_BOX *, const BOUND_BOX *);
+int Vect_box_clip(double *, double *, double *, double *, const BOUND_BOX *);
+int Vect_region_box(const struct Cell_head *, BOUND_BOX *);
 
 /* Spatial index */
 void Vect_spatial_index_init(SPATIAL_INDEX *);
 void Vect_spatial_index_destroy(SPATIAL_INDEX *);
-void Vect_spatial_index_add_item(SPATIAL_INDEX *, int, BOUND_BOX *);
+void Vect_spatial_index_add_item(SPATIAL_INDEX *, int, const BOUND_BOX *);
 void Vect_spatial_index_del_item(SPATIAL_INDEX *, int);
-int Vect_spatial_index_select(SPATIAL_INDEX *, BOUND_BOX *, struct ilist *);
+int Vect_spatial_index_select(const SPATIAL_INDEX *, const BOUND_BOX *, struct ilist *);
 
 /* Category index */
-int Vect_cidx_get_num_fields(struct Map_info *);
-int Vect_cidx_get_field_number(struct Map_info *, int);
-int Vect_cidx_get_field_index(struct Map_info *, int);
-int Vect_cidx_get_num_unique_cats_by_index(struct Map_info *, int);
-int Vect_cidx_get_num_cats_by_index(struct Map_info *, int);
-int Vect_cidx_get_num_types_by_index(struct Map_info *, int);
-int Vect_cidx_get_type_count_by_index(struct Map_info *, int, int, int *,
+int Vect_cidx_get_num_fields(const struct Map_info *);
+int Vect_cidx_get_field_number(const struct Map_info *, int);
+int Vect_cidx_get_field_index(const struct Map_info *, int);
+int Vect_cidx_get_num_unique_cats_by_index(const struct Map_info *, int);
+int Vect_cidx_get_num_cats_by_index(const struct Map_info *, int);
+int Vect_cidx_get_num_types_by_index(const struct Map_info *, int);
+int Vect_cidx_get_type_count_by_index(const struct Map_info *, int, int, int *,
 				      int *);
-int Vect_cidx_get_type_count(struct Map_info *, int, int);
-int Vect_cidx_get_cat_by_index(struct Map_info *, int, int, int *, int *,
+int Vect_cidx_get_type_count(const struct Map_info *, int, int);
+int Vect_cidx_get_cat_by_index(const struct Map_info *, int, int, int *, int *,
 			       int *);
-int Vect_cidx_find_next(struct Map_info *, int, int, int, int, int *, int *);
-void Vect_cidx_find_all(struct Map_info *, int, int, int, struct ilist *);
-int Vect_cidx_dump(struct Map_info *, FILE *);
+int Vect_cidx_find_next(const struct Map_info *, int, int, int, int, int *, int *);
+void Vect_cidx_find_all(const struct Map_info *, int, int, int, struct ilist *);
+int Vect_cidx_dump(const struct Map_info *, FILE *);
 int Vect_cidx_save(struct Map_info *);
 int Vect_cidx_open(struct Map_info *, int);
 
 
 /* Set/get map header info */
 int Vect_read_header(struct Map_info *);
-int Vect_write_header(struct Map_info *);
-const char *Vect_get_name(struct Map_info *);
-const char *Vect_get_mapset(struct Map_info *);
-const char *Vect_get_full_name(struct Map_info *);
-int Vect_is_3d(struct Map_info *);
+int Vect_write_header(const struct Map_info *);
+const char *Vect_get_name(const struct Map_info *);
+const char *Vect_get_mapset(const struct Map_info *);
+const char *Vect_get_full_name(const struct Map_info *);
+int Vect_is_3d(const struct Map_info *);
 int Vect_set_organization(struct Map_info *, const char *);
-const char *Vect_get_organization(struct Map_info *);
+const char *Vect_get_organization(const struct Map_info *);
 int Vect_set_date(struct Map_info *, const char *);
-const char *Vect_get_date(struct Map_info *);
+const char *Vect_get_date(const struct Map_info *);
 int Vect_set_person(struct Map_info *, const char *);
-const char *Vect_get_person(struct Map_info *);
+const char *Vect_get_person(const struct Map_info *);
 int Vect_set_map_name(struct Map_info *, const char *);
-const char *Vect_get_map_name(struct Map_info *);
+const char *Vect_get_map_name(const struct Map_info *);
 int Vect_set_map_date(struct Map_info *, const char *);
-const char *Vect_get_map_date(struct Map_info *);
+const char *Vect_get_map_date(const struct Map_info *);
 int Vect_set_comment(struct Map_info *, const char *);
-const char *Vect_get_comment(struct Map_info *);
+const char *Vect_get_comment(const struct Map_info *);
 int Vect_set_scale(struct Map_info *, int);
-int Vect_get_scale(struct Map_info *);
+int Vect_get_scale(const struct Map_info *);
 int Vect_set_zone(struct Map_info *, int);
-int Vect_get_zone(struct Map_info *);
-int Vect_get_proj(struct Map_info *);
-const char *Vect_get_proj_name(struct Map_info *);
+int Vect_get_zone(const struct Map_info *);
+int Vect_get_proj(const struct Map_info *);
+const char *Vect_get_proj_name(const struct Map_info *);
 int Vect_set_thresh(struct Map_info *, double);
-double Vect_get_thresh(struct Map_info *);
-int Vect_get_constraint_box(struct Map_info *, BOUND_BOX *);
+double Vect_get_thresh(const struct Map_info *);
+int Vect_get_constraint_box(const struct Map_info *, BOUND_BOX *);
 
 
 /* Get map level 2 informations */
-int Vect_level(struct Map_info *);
-int Vect_get_num_nodes(struct Map_info *);
-int Vect_get_num_primitives(struct Map_info *, int);
-int Vect_get_num_lines(struct Map_info *);
-int Vect_get_num_areas(struct Map_info *);
-int Vect_get_num_faces(struct Map_info *);
-int Vect_get_num_islands(struct Map_info *);
-int Vect_get_line_box(struct Map_info *, int, BOUND_BOX *);
-int Vect_get_area_box(struct Map_info *, int, BOUND_BOX *);
-int Vect_get_isle_box(struct Map_info *, int, BOUND_BOX *);
-int Vect_get_map_box(struct Map_info *, BOUND_BOX *);
+int Vect_level(const struct Map_info *);
+int Vect_get_num_nodes(const struct Map_info *);
+int Vect_get_num_primitives(const struct Map_info *, int);
+int Vect_get_num_lines(const struct Map_info *);
+int Vect_get_num_areas(const struct Map_info *);
+int Vect_get_num_faces(const struct Map_info *);
+int Vect_get_num_islands(const struct Map_info *);
+int Vect_get_line_box(const struct Map_info *, int, BOUND_BOX *);
+int Vect_get_area_box(const struct Map_info *, int, BOUND_BOX *);
+int Vect_get_isle_box(const struct Map_info *, int, BOUND_BOX *);
+int Vect_get_map_box(const struct Map_info *, BOUND_BOX *);
 int V__map_overlap(struct Map_info *, double, double, double, double);
 void Vect_set_release_support(struct Map_info *);
 void Vect_set_category_index_update(struct Map_info *);
@@ -211,9 +211,9 @@ int Vect_open_old_head(struct Map_info *, const char *, const char *);
 int Vect_open_new(struct Map_info *, const char *, int);
 int Vect_open_update(struct Map_info *, const char *, const char *);
 int Vect_open_update_head(struct Map_info *, const char *, const char *);
-int Vect_copy_head_data(struct Map_info *, struct Map_info *);
+int Vect_copy_head_data(const struct Map_info *, struct Map_info *);
 int Vect_build(struct Map_info *);
-int Vect_get_built(struct Map_info *);
+int Vect_get_built(const struct Map_info *);
 int Vect_build_partial(struct Map_info *, int);
 int Vect_set_constraint_region(struct Map_info *, double, double, double,
 			       double, double, double);
@@ -224,71 +224,71 @@ int Vect_close(struct Map_info *);
 
 /* Read/write lines, nodes, areas */
 /* Level 1 and 2 */
-int Vect_read_next_line(struct Map_info *, struct line_pnts *,
+int Vect_read_next_line(const struct Map_info *, struct line_pnts *,
 			struct line_cats *);
-off_t Vect_write_line(struct Map_info *, int, struct line_pnts *,
-		     struct line_cats *);
+off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *,
+		      const struct line_cats *);
 
-int Vect_get_num_dblinks(struct Map_info *);
+int Vect_get_num_dblinks(const struct Map_info *);
 
 /* Level 2 only */
-int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *,
+int Vect_read_line(const struct Map_info *, struct line_pnts *, struct line_cats *,
 		   int);
-int Vect_rewrite_line(struct Map_info *, int, int, struct line_pnts *,
-		      struct line_cats *);
+int Vect_rewrite_line(struct Map_info *, int, int, const struct line_pnts *,
+		      const struct line_cats *);
 int Vect_delete_line(struct Map_info *, int);
 int Vect_restore_line(struct Map_info *, int, off_t);
 
-int Vect_line_alive(struct Map_info *, int);
-int Vect_node_alive(struct Map_info *, int);
-int Vect_area_alive(struct Map_info *, int);
-int Vect_isle_alive(struct Map_info *, int);
-int Vect_get_line_nodes(struct Map_info *, int, int *, int *);
-int Vect_get_line_areas(struct Map_info *, int, int *, int *);
+int Vect_line_alive(const struct Map_info *, int);
+int Vect_node_alive(const struct Map_info *, int);
+int Vect_area_alive(const struct Map_info *, int);
+int Vect_isle_alive(const struct Map_info *, int);
+int Vect_get_line_nodes(const struct Map_info *, int, int *, int *);
+int Vect_get_line_areas(const struct Map_info *, int, int *, int *);
 off_t Vect_get_line_offset(const struct Map_info *, int);
 
-int Vect_get_node_coor(struct Map_info *, int, double *, double *, double *);
-int Vect_get_node_n_lines(struct Map_info *, int);
-int Vect_get_node_line(struct Map_info *, int, int);
-float Vect_get_node_line_angle(struct Map_info *, int, int);
+int Vect_get_node_coor(const struct Map_info *, int, double *, double *, double *);
+int Vect_get_node_n_lines(const struct Map_info *, int);
+int Vect_get_node_line(const struct Map_info *, int, int);
+float Vect_get_node_line_angle(const struct Map_info *, int, int);
 
-int Vect_get_area_points(struct Map_info *, int, struct line_pnts *);
-int Vect_get_area_centroid(struct Map_info *, int);
-int Vect_get_area_num_isles(struct Map_info *, int);
-int Vect_get_area_isle(struct Map_info *, int, int);
-double Vect_get_area_area(struct Map_info *, int);
-int Vect_get_area_boundaries(struct Map_info *, int, struct ilist *);
+int Vect_get_area_points(const struct Map_info *, int, struct line_pnts *);
+int Vect_get_area_centroid(const struct Map_info *, int);
+int Vect_get_area_num_isles(const struct Map_info *, int);
+int Vect_get_area_isle(const struct Map_info *, int, int);
+double Vect_get_area_area(const struct Map_info *, int);
+int Vect_get_area_boundaries(const struct Map_info *, int, struct ilist *);
 
-int Vect_get_isle_points(struct Map_info *, int, struct line_pnts *);
-int Vect_get_isle_area(struct Map_info *, int);
-int Vect_get_isle_boundaries(struct Map_info *, int, struct ilist *);
+int Vect_get_isle_points(const struct Map_info *, int, struct line_pnts *);
+int Vect_get_isle_area(const struct Map_info *, int);
+int Vect_get_isle_boundaries(const struct Map_info *, int, struct ilist *);
 
-int Vect_get_centroid_area(struct Map_info *, int);
+int Vect_get_centroid_area(const struct Map_info *, int);
 
 /* Level 2 update only */
-int Vect_get_num_updated_lines(struct Map_info *);
-int Vect_get_updated_line(struct Map_info *, int);
-int Vect_get_num_updated_nodes(struct Map_info *);
-int Vect_get_updated_node(struct Map_info *, int);
+int Vect_get_num_updated_lines(const struct Map_info *);
+int Vect_get_updated_line(const struct Map_info *, int);
+int Vect_get_num_updated_nodes(const struct Map_info *);
+int Vect_get_updated_node(const struct Map_info *, int);
 
 /* History */
 int Vect_hist_command(struct Map_info *);
 int Vect_hist_write(struct Map_info *, const char *);
-int Vect_hist_copy(struct Map_info *, struct Map_info *);
+int Vect_hist_copy(const struct Map_info *, struct Map_info *);
 void Vect_hist_rewind(struct Map_info *);
-char *Vect_hist_read(char *, int, struct Map_info *);
+char *Vect_hist_read(char *, int, const struct Map_info *);
 
 /* Selecting features */
-int Vect_select_lines_by_box(struct Map_info *, BOUND_BOX *, int,
+int Vect_select_lines_by_box(struct Map_info *, const BOUND_BOX *, int,
 			     struct ilist *);
-int Vect_select_areas_by_box(struct Map_info *, BOUND_BOX *, struct ilist *);
-int Vect_select_isles_by_box(struct Map_info *, BOUND_BOX *, struct ilist *);
-int Vect_select_nodes_by_box(struct Map_info *, BOUND_BOX *, struct ilist *);
+int Vect_select_areas_by_box(struct Map_info *, const BOUND_BOX *, struct ilist *);
+int Vect_select_isles_by_box(struct Map_info *, const BOUND_BOX *, struct ilist *);
+int Vect_select_nodes_by_box(struct Map_info *, const BOUND_BOX *, struct ilist *);
 int Vect_find_node(struct Map_info *, double, double, double, double, int);
 int Vect_find_line(struct Map_info *, double, double, double, int, double,
 		   int, int);
 int Vect_find_line_list(struct Map_info *, double, double, double, int,
-			double, int, struct ilist *, struct ilist *);
+			double, int, const struct ilist *, struct ilist *);
 int Vect_find_area(struct Map_info *, double, double);
 int Vect_find_island(struct Map_info *, double, double);
 int Vect_select_lines_by_polygon(struct Map_info *, struct line_pnts *, int,
@@ -297,21 +297,21 @@ int Vect_select_areas_by_polygon(struct Map_info *, struct line_pnts *, int,
 				 struct line_pnts **, struct ilist *);
 
 /* Analysis */
-int Vect_point_in_area(struct Map_info *, int, double, double);
+int Vect_point_in_area(const struct Map_info *, int, double, double);
 int Vect_tin_get_z(struct Map_info *, double, double, double *, double *,
 		   double *);
-int Vect_get_point_in_area(struct Map_info *, int, double *, double *);
+int Vect_get_point_in_area(const struct Map_info *, int, double *, double *);
 
 /* int Vect_point_in_islands (struct Map_info *, int, double, double); */
-int Vect_find_poly_centroid(struct line_pnts *, double *, double *);
-int Vect_get_point_in_poly_isl(struct line_pnts *, struct line_pnts **, int,
+int Vect_find_poly_centroid(const struct line_pnts *, double *, double *);
+int Vect_get_point_in_poly_isl(const struct line_pnts *, const struct line_pnts **, int,
 			       double *, double *);
-int Vect__intersect_line_with_poly(struct line_pnts *, double,
+int Vect__intersect_line_with_poly(const struct line_pnts *, double,
 				   struct line_pnts *);
-int Vect_get_point_in_poly(struct line_pnts *, double *, double *);
-int Vect_point_in_poly(double, double, struct line_pnts *);
-int Vect_point_in_area_outer_ring(double, double, struct Map_info *, int);
-int Vect_point_in_island(double, double, struct Map_info *, int);
+int Vect_get_point_in_poly(const struct line_pnts *, double *, double *);
+int Vect_point_in_poly(double, double, const struct line_pnts *);
+int Vect_point_in_area_outer_ring(double, double, const struct Map_info *, int);
+int Vect_point_in_island(double, double, const struct Map_info *, int);
 
 /* Cleaning */
 void Vect_break_lines(struct Map_info *, int, struct Map_info *);
@@ -322,7 +322,7 @@ void Vect_remove_duplicates(struct Map_info *, int, struct Map_info *);
 int Vect_line_check_duplicate(const struct line_pnts *,
 			      const struct line_pnts *, int);
 void Vect_snap_lines(struct Map_info *, int, double, struct Map_info *);
-void Vect_snap_lines_list(struct Map_info *, struct ilist *, double,
+void Vect_snap_lines_list(struct Map_info *, const struct ilist *, double,
 			  struct Map_info *);
 void Vect_remove_dangles(struct Map_info *, int, double, struct Map_info *);
 void Vect_chtype_dangles(struct Map_info *, double, struct Map_info *);
@@ -355,8 +355,8 @@ int Vect_net_build_graph(struct Map_info *, int, int, int, const char *,
 			 const char *, const char *, int, int);
 int Vect_net_shortest_path(struct Map_info *, int, int, struct ilist *,
 			   double *);
-int Vect_net_get_line_cost(struct Map_info *, int, int, double *);
-int Vect_net_get_node_cost(struct Map_info *, int, double *);
+int Vect_net_get_line_cost(const struct Map_info *, int, int, double *);
+int Vect_net_get_node_cost(const struct Map_info *, int, double *);
 int Vect_net_nearest_nodes(struct Map_info *, double, double, double, int,
 			   double, int *, int *, int *, double *, double *,
 			   struct line_pnts *, struct line_pnts *, double *);
@@ -367,18 +367,18 @@ int Vect_net_shortest_path_coor(struct Map_info *, double, double, double,
 				double *, double *);
 
 /* Miscellaneous */
-int Vect_topo_dump(struct Map_info *, FILE *);
+int Vect_topo_dump(const struct Map_info *, FILE *);
 double Vect_points_distance(double, double, double, double, double, double,
 			    int);
-int Vect_option_to_types(struct Option *);
+int Vect_option_to_types(const struct Option *);
 int Vect_copy_map_lines(struct Map_info *, struct Map_info *);
 int Vect_copy(const char *, const char *, const char *);
 int Vect_rename(const char *, const char *);
-int Vect_copy_table(struct Map_info *, struct Map_info *, int, int,
+int Vect_copy_table(const struct Map_info *, struct Map_info *, int, int,
 		    const char *, int);
-int Vect_copy_table_by_cats(struct Map_info *, struct Map_info *, int, int,
+int Vect_copy_table_by_cats(const struct Map_info *, struct Map_info *, int, int,
 			    const char *, int, int *, int);
-int Vect_copy_tables(struct Map_info *, struct Map_info *, int);
+int Vect_copy_tables(const struct Map_info *, struct Map_info *, int);
 int Vect_delete(const char *);
 int Vect_segment_intersection(double, double, double, double, double, double,
 			      double, double, double, double, double, double,
@@ -390,17 +390,17 @@ int Vect_line_intersection(struct line_pnts *, struct line_pnts *,
 int Vect_line_check_intersection(struct line_pnts *, struct line_pnts *, int);
 int Vect_line_get_intersections(struct line_pnts *, struct line_pnts *,
 				struct line_pnts *, int);
-char *Vect_subst_var(const char *str, struct Map_info *Map);
+char *Vect_subst_var(const char *, const struct Map_info *);
 
 /*
  * Internal functions, MUST NOT be used in modules
  */
-int Vect_print_header(struct Map_info *);
+int Vect_print_header(const struct Map_info *);
 int Vect__init_head(struct Map_info *);
 
 /* Open/close/rewind map */
-int Vect_coor_info(struct Map_info *, struct Coor_info *);
-const char *Vect_maptype_info(struct Map_info *);
+int Vect_coor_info(const struct Map_info *, struct Coor_info *);
+const char *Vect_maptype_info(const struct Map_info *);
 int Vect_open_topo(struct Map_info *, int);
 int Vect_save_topo(struct Map_info *);
 int Vect_open_spatial_index(struct Map_info *);
@@ -409,7 +409,7 @@ int Vect_spatial_index_dump(struct Map_info *, FILE *);
 int Vect_build_sidx_from_topo(struct Map_info *);
 int Vect_build_spatial_index(struct Map_info *);
 
-int Vect__write_head(struct Map_info *);
+int Vect__write_head(const struct Map_info *);
 int Vect__read_head(struct Map_info *);
 int V1_open_old_nat(struct Map_info *, int);
 int V1_open_old_ogr(struct Map_info *, int);
@@ -442,18 +442,18 @@ int V1_delete_line_nat(struct Map_info *, off_t);
 int V2_delete_line_nat(struct Map_info *, int);
 int V1_restore_line_nat(struct Map_info *, off_t);
 int V2_restore_line_nat(struct Map_info *, int, off_t);
-off_t V1_write_line_nat(struct Map_info *, int type, struct line_pnts *,
-		       struct line_cats *);
-off_t V2_write_line_nat(struct Map_info *, int type, struct line_pnts *,
-		       struct line_cats *);
+off_t V1_write_line_nat(struct Map_info *, int, const struct line_pnts *,
+			const struct line_cats *);
+off_t V2_write_line_nat(struct Map_info *, int, const struct line_pnts *,
+			const struct line_cats *);
 #if 0
-long V1_write_line_ogr(struct Map_info *, int type, struct line_pnts *,
+long V1_write_line_ogr(struct Map_info *, int, struct line_pnts *,
 		       struct line_cats *);
 #endif
-off_t V1_rewrite_line_nat(struct Map_info *, off_t offset, int type,
-			 struct line_pnts *, struct line_cats *);
-int V2_rewrite_line_nat(struct Map_info *, int line, int type,
-			struct line_pnts *, struct line_cats *);
+off_t V1_rewrite_line_nat(struct Map_info *, off_t, int,
+			  const struct line_pnts *, const struct line_cats *);
+int V2_rewrite_line_nat(struct Map_info *, int, int,
+			const struct line_pnts *, const struct line_cats *);
 #if 0
 long V1_rewrite_line_ogr(struct Map_info *, long offset, int type,
 			 struct line_pnts *, struct line_cats *);
@@ -465,8 +465,8 @@ int Vect_build_ogr(struct Map_info *, int);
 int Vect_build_line_area(struct Map_info *, int, int);
 int Vect_isle_find_area(struct Map_info *, int);
 int Vect_attach_isle(struct Map_info *, int);
-int Vect_attach_isles(struct Map_info *, BOUND_BOX *);
-int Vect_attach_centroids(struct Map_info *, BOUND_BOX *);
+int Vect_attach_isles(struct Map_info *, const BOUND_BOX *);
+int Vect_attach_centroids(struct Map_info *, const BOUND_BOX *);
 
     /* GEOS support */
 #ifdef HAVE_GEOS

+ 15 - 15
include/vect/dig_externs.h

@@ -56,14 +56,14 @@ int dig__fread_port_S(short *, int, GVFILE *);
 int dig__fread_port_I(int *, int, GVFILE *);
 int dig__fread_port_P(plus_t *, int, GVFILE *);
 int dig__fread_port_C(char *, int, GVFILE *);
-int dig__fwrite_port_D(double *, int, GVFILE *);
-int dig__fwrite_port_F(float *, int, GVFILE *);
-int dig__fwrite_port_O(off_t *, int, GVFILE *, int);
-int dig__fwrite_port_L(long *, int, GVFILE *);
-int dig__fwrite_port_S(short *, int, GVFILE *);
-int dig__fwrite_port_I(int *, int, GVFILE *);
-int dig__fwrite_port_P(plus_t *, int, GVFILE *);
-int dig__fwrite_port_C(char *, int, GVFILE *);
+int dig__fwrite_port_D(const double *, int, GVFILE *);
+int dig__fwrite_port_F(const float *, int, GVFILE *);
+int dig__fwrite_port_O(const off_t *, int, GVFILE *, int);
+int dig__fwrite_port_L(const long *, int, GVFILE *);
+int dig__fwrite_port_S(const short *, int, GVFILE *);
+int dig__fwrite_port_I(const int *, int, GVFILE *);
+int dig__fwrite_port_P(const plus_t *, int, GVFILE *);
+int dig__fwrite_port_C(const char *, int, GVFILE *);
 
 
 /******************************************************************************/
@@ -81,7 +81,7 @@ int dig_bound_box2(struct line_pnts *, double *, double *, double *, double *,
 		   long);
 int dig_box_copy(BOUND_BOX *, BOUND_BOX *);
 int dig_box_extend(BOUND_BOX *, BOUND_BOX *);
-int dig_line_box(struct line_pnts *, BOUND_BOX *);
+int dig_line_box(const struct line_pnts *, BOUND_BOX *);
 int dig_line_set_box(struct Plus_head *, plus_t, BOUND_BOX *);
 int dig_line_get_box(struct Plus_head *, plus_t, BOUND_BOX *);
 int dig_area_set_box(struct Plus_head *, plus_t, BOUND_BOX *);
@@ -127,12 +127,12 @@ int dig_spindex_init(struct Plus_head *);
 
 int dig_add_node(struct Plus_head *, double, double, double);
 int dig_which_node(struct Plus_head *, double, double, double);
-int dig_add_line(struct Plus_head *, int, struct line_pnts *,
+int dig_add_line(struct Plus_head *, int, const struct line_pnts *,
 		 off_t);
 int dig_restore_line(struct Plus_head *, int, int, struct line_pnts *,
 		     off_t);
 int dig_del_line(struct Plus_head *, int);
-int dig_node_add_line(struct Plus_head *, int, int, struct line_pnts *, int);
+int dig_node_add_line(struct Plus_head *, int, int, const struct line_pnts *, int);
 float dig_node_line_angle(struct Plus_head *, int, int);
 int dig_node_angle_check(struct Plus_head *, int, int);
 
@@ -164,10 +164,10 @@ int dig_spidx_del_line(struct Plus_head *, int);
 int dig_spidx_del_area(struct Plus_head *, int);
 int dig_spidx_del_isle(struct Plus_head *, int);
 
-int dig_select_nodes(struct Plus_head *, BOUND_BOX *, struct ilist *);
-int dig_select_lines(struct Plus_head *, BOUND_BOX *, struct ilist *);
-int dig_select_areas(struct Plus_head *, BOUND_BOX *, struct ilist *);
-int dig_select_isles(struct Plus_head *, BOUND_BOX *, struct ilist *);
+int dig_select_nodes(struct Plus_head *, const BOUND_BOX *, struct ilist *);
+int dig_select_lines(struct Plus_head *, const BOUND_BOX *, struct ilist *);
+int dig_select_areas(struct Plus_head *, const BOUND_BOX *, struct ilist *);
+int dig_select_isles(struct Plus_head *, const BOUND_BOX *, struct ilist *);
 int dig_find_node(struct Plus_head *, double, double, double);
 
 int dig_spidx_init(struct Plus_head *);

+ 44 - 45
lib/vector/Vlib/area.c

@@ -1,11 +1,11 @@
 /*!
    \file area.c
 
-   \brief Vector library - area feature related fns
+   \brief Vector library - area-related functions 
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 by the GRASS Development Team
 
    This program is free software under the 
    GNU General Public License (>=v2). 
@@ -13,9 +13,7 @@
    for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 
 #include <stdlib.h>
@@ -24,7 +22,7 @@
 #include <grass/glocale.h>
 
 /*!
-   \brief Returns the polygon array of points in BPoints
+   \brief Returns polygon array of points of given area
 
    \param Map vector map
    \param area area id
@@ -34,11 +32,11 @@
    \return -1 on error
  */
 int
-Vect_get_area_points(struct Map_info *Map,
+Vect_get_area_points(const struct Map_info *Map,
 		     int area, struct line_pnts *BPoints)
 {
     int i, line, aline, dir;
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_AREA *Area;
     static int first_time = 1;
     static struct line_pnts *Points;
@@ -86,20 +84,21 @@ Vect_get_area_points(struct Map_info *Map,
 }
 
 /*!
-   \brief Returns the polygon array of points in BPoints
+   \brief Returns polygon array of points for given isle
 
    \param Map vector map
    \param isle island id
    \param[out] BPoints points array
 
-   \return number of points or -1 on error
+   \return number of points
+   \return -1 on error
  */
 int
-Vect_get_isle_points(struct Map_info *Map,
+Vect_get_isle_points(const struct Map_info *Map,
 		     int isle, struct line_pnts *BPoints)
 {
     int i, line, aline, dir;
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_ISLE *Isle;
     static int first_time = 1;
     static struct line_pnts *Points;
@@ -142,7 +141,7 @@ Vect_get_isle_points(struct Map_info *Map,
 }
 
 /*!
-   \brief Returns centroid number of area
+   \brief Returns centroid id for given area
 
    \param Map vector map
    \param area area id
@@ -150,9 +149,9 @@ Vect_get_isle_points(struct Map_info *Map,
    \return centroid number of area
    \return 0 if no centroid found
  */
-int Vect_get_area_centroid(struct Map_info *Map, int area)
+int Vect_get_area_centroid(const struct Map_info *Map, int area)
 {
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_AREA *Area;
 
     G_debug(3, "Vect_get_area_centroid(): area = %d", area);
@@ -167,19 +166,19 @@ int Vect_get_area_centroid(struct Map_info *Map, int area)
 }
 
 /*!
-   \brief Creates list of boundaries for area
+   \brief Creates list of boundaries for given area
 
    \param Map vector map
    \param area area id
-   \param List pointer to list of boundaries
+   \param[out] List pointer to list of boundaries
 
    \return number of boundaries
  */
 int
-Vect_get_area_boundaries(struct Map_info *Map, int area, struct ilist *List)
+Vect_get_area_boundaries(const struct Map_info *Map, int area, struct ilist *List)
 {
     int i, line;
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_AREA *Area;
 
     G_debug(3, "Vect_get_area_boundaries(): area = %d", area);
@@ -201,19 +200,19 @@ Vect_get_area_boundaries(struct Map_info *Map, int area, struct ilist *List)
 }
 
 /*!
-   \brief Creates list of boundaries for isle
+   \brief Creates list of boundaries for given isle
 
    \param Map vector map
    \param isle island number
-   \param List pointer to list where boundaries are stored
+   \param[out] List pointer to list where boundaries are stored
 
    \return number of boundaries
  */
 int
-Vect_get_isle_boundaries(struct Map_info *Map, int isle, struct ilist *List)
+Vect_get_isle_boundaries(const struct Map_info *Map, int isle, struct ilist *List)
 {
     int i, line;
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_ISLE *Isle;
 
     G_debug(3, "Vect_get_isle_boundaries(): isle = %d", isle);
@@ -224,7 +223,7 @@ Vect_get_isle_boundaries(struct Map_info *Map, int isle, struct ilist *List)
     Isle = Plus->Isle[isle];
 
     if (Isle == NULL)
-	G_fatal_error("Attempt to read topo for dead isle (%d)", isle);
+	G_fatal_error(_("Attempt to read topo for dead isle (%d)"), isle);
 
     for (i = 0; i < Isle->n_lines; i++) {
 	line = Isle->lines[i];
@@ -235,7 +234,7 @@ Vect_get_isle_boundaries(struct Map_info *Map, int isle, struct ilist *List)
 }
 
 /*!
-   \brief Returns number of isles for area
+   \brief Returns number of isles for given area
 
    \param Map vector map
    \param area area id
@@ -243,9 +242,9 @@ Vect_get_isle_boundaries(struct Map_info *Map, int isle, struct ilist *List)
    \return number of isles for area
    \return 0 if area not found
  */
-int Vect_get_area_num_isles(struct Map_info *Map, int area)
+int Vect_get_area_num_isles(const struct Map_info *Map, int area)
 {
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_AREA *Area;
 
     G_debug(3, "Vect_get_area_num_isles(): area = %d", area);
@@ -263,18 +262,18 @@ int Vect_get_area_num_isles(struct Map_info *Map, int area)
 }
 
 /*!
-   \brief Returns isle for area
+   \brief Returns isle id for area
 
    \param Map vector map
    \param area area id
-   \param isle isle id
+   \param isle isle index (0 .. nisles - 1)
 
-   \return isles for area
+   \return isle id
    \return 0 if no isle found
  */
-int Vect_get_area_isle(struct Map_info *Map, int area, int isle)
+int Vect_get_area_isle(const struct Map_info *Map, int area, int isle)
 {
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_AREA *Area;
 
     G_debug(3, "Vect_get_area_isle(): area = %d isle = %d", area, isle);
@@ -291,17 +290,17 @@ int Vect_get_area_isle(struct Map_info *Map, int area, int isle)
 }
 
 /*!
-   \brief Returns area for isle
+   \brief Returns area id for isle
 
    \param Map vector
-   \param isle island number
+   \param isle isle number (0 .. nisles - 1)
 
    \return area id
    \return 0 area not found
  */
-int Vect_get_isle_area(struct Map_info *Map, int isle)
+int Vect_get_isle_area(const struct Map_info *Map, int isle)
 {
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_ISLE *Isle;
 
     G_debug(3, "Vect_get_isle_area(): isle = %d", isle);
@@ -325,14 +324,14 @@ int Vect_get_isle_area(struct Map_info *Map, int isle)
 
    \return area perimeter
  */
-double Vect_area_perimeter(struct line_pnts *Points)
+double Vect_area_perimeter(const struct line_pnts *Points)
 {
     return Vect_line_length(Points);
 }
 
 
 /*!
-   \brief Returns 1 if point is in area
+   \brief Check if point is in area
 
    \param Map vector map
    \param area area id
@@ -341,10 +340,10 @@ double Vect_area_perimeter(struct line_pnts *Points)
    \return 1 if point is in area
    \return 0 if not 
  */
-int Vect_point_in_area(struct Map_info *Map, int area, double x, double y)
+int Vect_point_in_area(const struct Map_info *Map, int area, double x, double y)
 {
     int i, isle;
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_AREA *Area;
     int poly;
 
@@ -376,9 +375,9 @@ int Vect_point_in_area(struct Map_info *Map, int area, double x, double y)
 
    \return area of area without areas of isles
  */
-double Vect_get_area_area(struct Map_info *Map, int area)
+double Vect_get_area_area(const struct Map_info *Map, int area)
 {
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_AREA *Area;
     struct line_pnts *Points;
     double size;
@@ -419,10 +418,10 @@ double Vect_get_area_area(struct Map_info *Map, int area)
    \param area area id
    \param[out] Cats list of categories
 
-   \return 0 OK centroid found (but may be without categories)
+   \return 0 centroid found (but may be without categories)
    \return 1 no centroid found
  */
-int Vect_get_area_cats(struct Map_info *Map, int area, struct line_cats *Cats)
+int Vect_get_area_cats(const struct Map_info *Map, int area, struct line_cats *Cats)
 {
     int centroid;
 
@@ -450,7 +449,7 @@ int Vect_get_area_cats(struct Map_info *Map, int area, struct line_cats *Cats)
    \return first found category of given field
    \return -1 no centroid or no category found
  */
-int Vect_get_area_cat(struct Map_info *Map, int area, int field)
+int Vect_get_area_cat(const struct Map_info *Map, int area, int field)
 {
     int i;
     static struct line_cats *Cats = NULL;

+ 27 - 28
lib/vector/Vlib/array.c

@@ -1,11 +1,11 @@
 /*!
    \file array.c
 
-   \brief Vector library - array structure
+   \brief Vector library - category array
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 by the GRASS Development Team
 
    This program is free software under the 
    GNU General Public License (>=v2). 
@@ -13,8 +13,6 @@
    for details.
 
    \author Radim Blazek
-
-   \date 2001-2008
  */
 
 #include <stdlib.h>
@@ -62,27 +60,27 @@ VARRAY *Vect_new_varray(int size)
 }
 
 /*!
-   \brief Set values in 'varray' to 'value'.
+   \brief Set values in 'varray' to 'value' from category string.
 
-   If category of object of given type is in 'cstring' (string
-   representing category list like: '1,3,5-7').  'type' may be either:
-   GV_AREA or: GV_POINT | GV_LINE | GV_BOUNDARY | GV_CENTROID
+   If category of object of given type is in <em>cstring</em> (string
+   representing category list like: '1,3,5-7'). <em>type</em> may be
+   either: GV_AREA or: GV_POINT | GV_LINE | GV_BOUNDARY | GV_CENTROID
 
-   Array is not reset to zero before, but old values (if any > 0) are overwritten.
-   Array must be initialised by Vect_new_varray(size) call.
+   Array is not reset to zero before, but old values (if any > 0) are
+   overwritten.  Array must be initialised by Vect_new_varray() call.
 
    \param Map vector map
    \param field layer number
    \param cstring pointer to string with categories
    \param type feature type
    \param value value to set up
-   \param[in,out] varray varray structure to modify
+   \param[out] varray varray structure to modify
 
    \return number of items set
    \return -1 on error
  */
 int
-Vect_set_varray_from_cat_string(struct Map_info *Map, int field,
+Vect_set_varray_from_cat_string(const struct Map_info *Map, int field,
 				const char *cstring, int type, int value,
 				VARRAY * varray)
 {
@@ -96,7 +94,7 @@ Vect_set_varray_from_cat_string(struct Map_info *Map, int field,
     ret = Vect_str_to_cat_list(cstring, Clist);
 
     if (ret > 0)
-	G_warning(_("%d errors in category string."), ret);
+	G_warning(_("%d errors in category string"), ret);
 
     G_debug(4, "  %d ranges in clist", Clist->n_ranges);
 
@@ -109,27 +107,27 @@ Vect_set_varray_from_cat_string(struct Map_info *Map, int field,
 }
 
 /*!
-   \brief Set values in 'varray' to 'value'
+   \brief Set values in 'varray' to 'value' from category list
 
-   If category of object of given type is in 'clist' (category list).
-   'type' may be either: GV_AREA or: GV_POINT | GV_LINE | GV_BOUNDARY |
-   GV_CENTROID
+   If category of object of given type is in <em>clist</em> (category
+   list).  <em>type</em> may be either: GV_AREA or: GV_POINT | GV_LINE
+   | GV_BOUNDARY | GV_CENTROID
 
-   Array is not reset to zero before, but old values (if any > 0) are overwritten.
-   Array must be initialised by Vect_new_varray(size) call.
+   Array is not reset to zero before, but old values (if any > 0) are
+   overwritten.  Array must be initialised by Vect_new_varray() call.
 
    \param Map vector map
    \param field layer number
    \param clist list of categories
    \param type feature type
    \param value value to set up
-   \param[in,out] varray varray structure to modify
+   \param[out] varray varray structure to modify
 
    \return number of items set
    \return -1 on error
  */
 int
-Vect_set_varray_from_cat_list(struct Map_info *Map, int field,
+Vect_set_varray_from_cat_list(const struct Map_info *Map, int field,
 			      struct cat_list *clist, int type, int value,
 			      VARRAY * varray)
 {
@@ -228,27 +226,28 @@ static int in_array(int *cats, size_t ncats, int cat)
 }
 
 /*!
-   \brief Set values in 'varray' to 'value'.
+   \brief Set values in 'varray' to 'value' from DB (where statement)
 
-   if category of object of given type is in categories selected from
-   DB based on where statement (given without where).  'type' may be
-   either: GV_AREA or: GV_POINT | GV_LINE | GV_BOUNDARY | GV_CENTROID
+   I category of object of given type is in categories selected from
+   DB based on where statement (given without where). <em>type</em>
+   may be either: GV_AREA or: GV_POINT | GV_LINE | GV_BOUNDARY |
+   GV_CENTROID
 
    Array is not reset to zero before, but old values (if any > 0) are
-   overwritten. Array must be initialised by Vect_new_varray(size) call.
+   overwritten. Array must be initialised by Vect_new_varray() call.
 
    \param Map vector map
    \param field layer number
    \param where where statement
    \param type feature type
    \param value value to set up
-   \param[in,out] varray varray structure to modify
+   \param[out] varray varray structure to modify
 
    \return number of items set
    \return -1 on error
  */
 int
-Vect_set_varray_from_db(struct Map_info *Map, int field, const char *where,
+Vect_set_varray_from_db(const struct Map_info *Map, int field, const char *where,
 			int type, int value, VARRAY * varray)
 {
     int i, n, c, centr, cat, *cats;

+ 35 - 35
lib/vector/Vlib/box.c

@@ -1,11 +1,11 @@
 /*!
    \file box.c
 
-   \brief Vector library - bounding box related fns
+   \brief Vector library - bounding box
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 by the GRASS Development Team
 
    This program is free software under the 
    GNU General Public License (>=v2). 
@@ -13,8 +13,6 @@
    for details.
 
    \author Radim Blazek
-
-   \date 2001-2008
  */
 
 #include <stdlib.h>
@@ -30,7 +28,7 @@
    \return 1 point is in box
    \return 0 point is not in box
  */
-int Vect_point_in_box(double x, double y, double z, BOUND_BOX * Box)
+int Vect_point_in_box(double x, double y, double z, const BOUND_BOX * Box)
 {
 
     if (x >= Box->W && x <= Box->E &&
@@ -50,7 +48,7 @@ int Vect_point_in_box(double x, double y, double z, BOUND_BOX * Box)
    \return 1 boxes overlap
    \return 0 boxes do not overlap
  */
-int Vect_box_overlap(BOUND_BOX * A, BOUND_BOX * B)
+int Vect_box_overlap(const BOUND_BOX * A, const BOUND_BOX * B)
 {
 
     if (A->E < B->W || A->W > B->E ||
@@ -69,7 +67,7 @@ int Vect_box_overlap(BOUND_BOX * A, BOUND_BOX * B)
 
    \return 1
  */
-int Vect_box_copy(BOUND_BOX * A, BOUND_BOX * B)
+int Vect_box_copy(BOUND_BOX * A, const BOUND_BOX * B)
 {
 
     A->N = B->N;
@@ -90,7 +88,7 @@ int Vect_box_copy(BOUND_BOX * A, BOUND_BOX * B)
 
    \return 1
  */
-int Vect_box_extend(BOUND_BOX * A, BOUND_BOX * B)
+int Vect_box_extend(BOUND_BOX * A, const BOUND_BOX * B)
 {
 
     if (B->N > A->N)
@@ -113,18 +111,18 @@ int Vect_box_extend(BOUND_BOX * A, BOUND_BOX * B)
 /*!
  * \brief Clip coordinates to box, if necessary, lines extending outside of a box.
  *
- * A line represented by the coordinates <b>x, y</b> and <b>c_x, c_y</b> is clipped to
- * the window defined by <b>s</b> (south), <b>n</b> (north), <b>w</b>
- * (west), and <b>e</b> (east). Note that the following constraints must be
+ * A line represented by the coordinates <em>x, y</em> and <em>c_x, c_y</em> is clipped to
+ * the window defined by <em>s</em> (south), <em>n</em> (north), <em>w</em>
+ * (west), and <em>e</em> (east). Note that the following constraints must be
  * true:
  * w <e
  * s <n
- * The <b>x</b> and <b>c_x</b> are values to be compared to <b>w</b> and
- * <b>e.</b> The <b>y</b> and <b>c_y</b> are values to be compared to
- * <b>s</b> and <b>n.</b>
- * The <b>x</b> and <b>c_x</b> values returned lie between <b>w</b> and 
- * <b>e.</b> The <b>y</b> and <b>c_y</b> values returned lie between 
- * <b>s</b> and <b>n.</b>
+ * The <em>x</em> and <em>c_x</em> are values to be compared to <em>w</em> and
+ * <em>e.</em> The <em>y</em> and <em>c_y</em> are values to be compared to
+ * <em>s</em> and <em>n.</em>
+ * The <em>x</em> and <em>c_x</em> values returned lie between <em>w</em> and 
+ * <em>e.</em> The <em>y</em> and <em>c_y</em> values returned lie between 
+ * <em>s</em> and <em>n.</em>
  *
  *  \param x, y coordinates (w, e)
  *  \param c_x,c_y coordinates (s, n)
@@ -135,7 +133,7 @@ int Vect_box_extend(BOUND_BOX * A, BOUND_BOX * B)
  */
 
 int
-Vect_box_clip(double *x, double *y, double *c_x, double *c_y, BOUND_BOX * Box)
+Vect_box_clip(double *x, double *y, double *c_x, double *c_y, const BOUND_BOX * Box)
 {
     int mod;
 
@@ -196,18 +194,18 @@ Vect_box_clip(double *x, double *y, double *c_x, double *c_y, BOUND_BOX * Box)
 
 
 /*!
-   \brief Get boundary box of line
+   \brief Get bounding box of given feature
 
    \param Map vector map
-   \param line line id
+   \param line feature id
    \param[out] Box bounding box
 
    \return 1 on success
    \return 0 line is dead
  */
-int Vect_get_line_box(struct Map_info *Map, int line, BOUND_BOX * Box)
+int Vect_get_line_box(const struct Map_info *Map, int line, BOUND_BOX * Box)
 {
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_LINE *Line;
 
     Plus = &(Map->plus);
@@ -235,7 +233,7 @@ int Vect_get_line_box(struct Map_info *Map, int line, BOUND_BOX * Box)
 }
 
 /*!
-   \brief Get boundary box of area
+   \brief Get bounding box of area
 
    \param Map vector map
    \param area area id
@@ -244,9 +242,9 @@ int Vect_get_line_box(struct Map_info *Map, int line, BOUND_BOX * Box)
    \return 1 on success
    \return 0 area is dead
  */
-int Vect_get_area_box(struct Map_info *Map, int area, BOUND_BOX * Box)
+int Vect_get_area_box(const struct Map_info *Map, int area, BOUND_BOX * Box)
 {
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_AREA *Area;
 
     Plus = &(Map->plus);
@@ -274,7 +272,7 @@ int Vect_get_area_box(struct Map_info *Map, int area, BOUND_BOX * Box)
 }
 
 /*!
-   \brief Get boundary box of isle
+   \brief Get bounding box of isle
 
    \param Map vector map
    \param isle isle id
@@ -283,9 +281,9 @@ int Vect_get_area_box(struct Map_info *Map, int area, BOUND_BOX * Box)
    \return 1 on success
    \return 0 isle is dead
  */
-int Vect_get_isle_box(struct Map_info *Map, int isle, BOUND_BOX * Box)
+int Vect_get_isle_box(const struct Map_info *Map, int isle, BOUND_BOX * Box)
 {
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_ISLE *Isle;
 
     Plus = &(Map->plus);
@@ -313,16 +311,17 @@ int Vect_get_isle_box(struct Map_info *Map, int isle, BOUND_BOX * Box)
 }
 
 /*!
-   \brief Get boundary box of map
+   \brief Get bounding box of map (all features in the map)
 
    \param Map vector map
    \param[out] Box bouding box
 
-   \return 1 on success, 0 on error
+   \return 1 on success
+   \return 0 on error
  */
-int Vect_get_map_box(struct Map_info *Map, BOUND_BOX * Box)
+int Vect_get_map_box(const struct Map_info *Map, BOUND_BOX * Box)
 {
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
 
     Plus = &(Map->plus);
 
@@ -338,14 +337,15 @@ int Vect_get_map_box(struct Map_info *Map, BOUND_BOX * Box)
 
 
 /*!
-   \brief Copy region Window to Box
+   \brief Copy region window to bounding box
 
    \param Window region structure (raster-based)
    \param[out] Box boundary box (vector-based)
 
-   \return 1 on success, 0 on error
+   \return 1 on success
+   \return 0 on error
  */
-int Vect_region_box(struct Cell_head *Window, BOUND_BOX * Box)
+int Vect_region_box(const struct Cell_head *Window, BOUND_BOX * Box)
 {
 
     Box->N = Window->north;

+ 1 - 3
lib/vector/Vlib/break_lines.c

@@ -3,7 +3,7 @@
  *
  * \brief Vector library - Clean vector map (break lines)
  *
- * (C) 2001-2008 by the GRASS Development Team
+ * (C) 2001-2009 by the GRASS Development Team
  *
  * This program is free software under the 
  * GNU General Public License (>=v2). 
@@ -11,8 +11,6 @@
  * for details.
  *
  * \author Radim Blazek
- *
- * \date 2001
  */
 
 #include <stdlib.h>

+ 12 - 11
lib/vector/Vlib/break_polygons.c

@@ -12,9 +12,8 @@
    Read the file COPYING that comes with GRASS
    for details.
 
-   \author Radim Blazek, update for GRASS 7 Markus Metz
-
-   \date 2001-2008
+   \author Radim Blazek
+   \author Update for GRASS 7 Markus Metz
  */
 
 #include <stdlib.h>
@@ -60,7 +59,7 @@ typedef struct
 
 /* function used by binary tree to compare items */
 
-int compare_xpnts(const void *Xpnta, const void *Xpntb)
+static int compare_xpnts(const void *Xpnta, const void *Xpntb)
 {
     XPNT *a, *b;
 
@@ -80,20 +79,22 @@ int compare_xpnts(const void *Xpnta, const void *Xpntb)
 	    return 0;
     }
 
-    G_warning("Break polygons: Bug in binary tree!");
+    G_warning(_("Break polygons: Bug in binary tree!"));
     return 1;
 }
 
 /*!
    \brief Break polygons in vector map.
 
-   Breaks lines specified by type in vector map. Points at intersections may be optionally 
-   written to error map. Input map must be opened on level 2 for update at least on GV_BUILD_BASE.
+   Breaks lines specified by type in vector map. Points at
+   intersections may be optionally written to error map. Input map
+   must be opened on level 2 for update at least on GV_BUILD_BASE.
 
-   Function is optimized for closed polygons rigs (e.g. imported from OGR) but with clean geometry -
-   adjacent polygons mostly have identical boundary. Function creates database of ALL points
-   in the map, and then is looking for those where polygons should be broken. 
-   Lines may be broken only at points existing in input map! 
+   Function is optimized for closed polygons rigs (e.g. imported from
+   OGR) but with clean geometry - adjacent polygons mostly have
+   identical boundary. Function creates database of ALL points in the
+   map, and then is looking for those where polygons should be broken.
+   Lines may be broken only at points existing in input map!
 
    \param Map input map where polygons will be broken
    \param type type of line to be broken

+ 12 - 14
lib/vector/Vlib/bridges.c

@@ -5,7 +5,7 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 by the GRASS Development Team
 
    This program is free software under the 
    GNU General Public License (>=v2). 
@@ -13,8 +13,6 @@
    for details.
 
    \author Radim Blazek
-
-   \date 2001-2008
  */
 
 #include <stdlib.h>
@@ -28,18 +26,17 @@ remove_bridges(struct Map_info *Map, int chtype, struct Map_info *Err);
 /*!
    \brief Remove bridges from vector map.
 
-   Remove bridges (type boundary) connecting areas to islands or 2 islands.
-   Islands and areas must be already clean, i.e. without dangles.
-   Bridge may be formed by more lines.
-   Optionally deleted bridges are written to error map. 
-   Input map must be opened on level 2 for update at least on level GV_BUILD_BASE
+   Remove bridges (type boundary) connecting areas to islands or 2
+   islands.  Islands and areas must be already clean, i.e. without
+   dangles.  Bridge may be formed by more lines.  Optionally deleted
+   bridges are written to error map.  Input map must be opened on
+   level 2 for update at least on level GV_BUILD_BASE
 
    \param Map input map where bridges are deleted
    \param Err vector map where deleted bridges are written or NULL
 
    \return
  */
-
 void
 Vect_remove_bridges(struct Map_info *Map, struct Map_info *Err)
 {
@@ -49,11 +46,12 @@ Vect_remove_bridges(struct Map_info *Map, struct Map_info *Err)
 /*!
    \brief Change type of bridges in vector map.
 
-   Change the type of bridges (type boundary) connecting areas to islands or 2 islands.
-   Islands and areas must be already clean, i.e. without dangles.
-   Bridge may be formed by more lines.
-   Optionally changed bridges are written to error map. 
-   Input map must be opened on level 2 for update at least on level GV_BUILD_BASE.
+   Change the type of bridges (type boundary) connecting areas to
+   islands or 2 islands. Islands and areas must be already clean,
+   i.e. without dangles. Bridge may be formed by more lines.
+   Optionally changed bridges are written to error map.  Input map
+   must be opened on level 2 for update at least on level
+   GV_BUILD_BASE.
 
    \param Map input map where bridges are changed
    \param Err vector map where changed bridges are written or NULL

+ 10 - 6
lib/vector/Vlib/buffer.c

@@ -5,7 +5,9 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   See buffer2.c for replacement.
+
+   (C) 2001-2009 by the GRASS Development Team
 
    This program is free software under the 
    GNU General Public License (>=v2). 
@@ -13,8 +15,6 @@
    for details.
 
    \author Radim Blazek
-
-   \date 2001-2008
  */
 
 #include <stdlib.h>
@@ -342,6 +342,8 @@ static void parallel_line(struct line_pnts *Points, double d, double tol,
 /*!
    \brief Create parrallel line
 
+   This function is replaced by Vect_line_parallel2().
+
    \param InPoints input line
    \param distance create parrallel line in distance
    \param tolerance maximum distance between theoretical arc and polygon segments
@@ -368,8 +370,10 @@ Vect_line_parallel(struct line_pnts *InPoints, double distance,
 /*!
    \brief Create buffer around the line line.
 
-   Buffer is closed counter clockwise polygon.
-   Warning: output line may contain loops!
+   This function is replaced by Vect_line_buffer().
+
+   Buffer is closed counter clockwise polygon. Warning: output line
+   may contain loops!
 
    \param InPoints input line
    \param distance create buffer in distance
@@ -377,7 +381,7 @@ Vect_line_parallel(struct line_pnts *InPoints, double distance,
    \param[out] OutPoints output line
  */
 void
-Vect_line_buffer(struct line_pnts *InPoints, double distance,
+Vect_line_buffer(const struct line_pnts *InPoints, double distance,
 		 double tolerance, struct line_pnts *OutPoints)
 {
     double dangle;

+ 6 - 54
lib/vector/Vlib/buffer2.c

@@ -5,7 +5,7 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 by the GRASS Development Team
 
    This program is free software under the 
    GNU General Public License (>=v2). 
@@ -14,8 +14,6 @@
 
    \author Original author Radim Blazek (see buffer.c)
    \author Rewritten by Rosen Matev (Google Summer of Code 2008)
-
-   \date 2008
  */
 
 #include <stdlib.h>
@@ -186,19 +184,12 @@ static void parallel_line(struct line_pnts *Points, double da, double db,
 			  double tol, struct line_pnts *nPoints)
 {
     int i, j, res, np;
-
     double *x, *y;
-
     double tx, ty, vx, vy, wx, wy, nx, ny, mx, my, rx, ry;
-
     double vx1, vy1, wx1, wy1;
-
     double a0, b0, c0, a1, b1, c1;
-
     double phi1, phi2, delta_phi;
-
     double nsegments, angular_tol, angular_step;
-
     int inner_corner, turns360;
 
     G_debug(3, "parallel_line()");
@@ -347,21 +338,13 @@ static void convolution_line(struct line_pnts *Points, double da, double db,
 			     double tol, struct line_pnts *nPoints)
 {
     int i, j, res, np;
-
     double *x, *y;
-
     double tx, ty, vx, vy, wx, wy, nx, ny, mx, my, rx, ry;
-
     double vx1, vy1, wx1, wy1;
-
     double a0, b0, c0, a1, b1, c1;
-
     double phi1, phi2, delta_phi;
-
     double nsegments, angular_tol, angular_step;
-
     double angle0, angle1;
-
     int inner_corner, turns360;
 
     G_debug(3, "convolution_line() side = %d", side);
@@ -454,9 +437,8 @@ static void convolution_line(struct line_pnts *Points, double da, double db,
 		/* no need to append point in this case */
 	    }
 	    else
-		G_fatal_error
-		    ("unexpected result of line_intersection() res = %d",
-		     res);
+		G_fatal_error(_("Unexpected result of line_intersection() res = %d"),
+			      res);
 	}
 
 	if (round && (!inner_corner) && (!turns360 || caps)) {
@@ -509,29 +491,21 @@ static void extract_contour(struct planar_graph *pg, struct pg_edge *first,
 			    struct line_pnts *nPoints)
 {
     int j;
-
     int v;			/* current vertex number */
-
     int v0;
-
     int eside;			/* side of the current edge */
-
     double eangle;		/* current edge angle with Ox (according to the current direction) */
 
     struct pg_vertex *vert;	/* current vertex */
-
     struct pg_vertex *vert0;	/* last vertex */
-
     struct pg_edge *edge;	/* current edge; must be edge of vert */
 
     /*    int cs; *//* on which side are we turning along the contour */
     /* we will always turn right and dont need that one */
     double opt_angle, tangle;
-
     int opt_j, opt_side, opt_flag;
 
-    G_debug(3,
-	    "extract_contour(): v1=%d, v2=%d, side=%d, stop_at_line_end=%d",
+    G_debug(3, "extract_contour(): v1=%d, v2=%d, side=%d, stop_at_line_end=%d",
 	    first->v1, first->v2, side, stop_at_line_end);
 
     Vect_reset_line(nPoints);
@@ -712,7 +686,6 @@ static int extract_inner_contour(struct planar_graph *pg, int *winding,
 				 struct line_pnts *nPoints)
 {
     int i, w;
-
     struct pg_edge *edge;
 
     G_debug(3, "extract_inner_contour()");
@@ -749,13 +722,9 @@ static int point_in_buf(struct line_pnts *Points, double px, double py, double d
 			double db, double dalpha)
 {
     int i, np;
-
     double cx, cy;
-
     double delta, delta_k, k;
-
     double vx, vy, wx, wy, mx, my, nx, ny;
-
     double len, tx, ty, d, da2;
 
     G_debug(3, "point_in_buf()");
@@ -824,7 +793,6 @@ static int point_in_buf(struct line_pnts *Points, double px, double py, double d
 static int get_polygon_orientation(const double *x, const double *y, int n)
 {
     double x1, y1, x2, y2;
-
     double area;
 
     x2 = x[n - 1];
@@ -877,21 +845,14 @@ static void buffer_lines(struct line_pnts *area_outer, struct line_pnts **area_i
 			 int *inner_count)
 {
     struct planar_graph *pg2;
-
     struct line_pnts *sPoints, *cPoints;
-
     struct line_pnts **arrPoints;
 
     int i, count = 0;
-
     int res, winding;
-
     int auto_side;
-
     int more = 8;
-
     int allocated = 0;
-
     double px, py;
 
     G_debug(3, "buffer_lines()");
@@ -995,23 +956,18 @@ static void buffer_lines(struct line_pnts *area_outer, struct line_pnts **area_i
    \param[out] inner_count number of holes
    \param[out] iPoints array of output polygon's holes (cw order)
  */
-void Vect_line_buffer2(struct line_pnts *Points, double da, double db,
+void Vect_line_buffer2(const struct line_pnts *Points, double da, double db,
 		       double dalpha, int round, int caps, double tol,
 		       struct line_pnts **oPoints,
 		       struct line_pnts ***iPoints, int *inner_count)
 {
     struct planar_graph *pg;
-
     struct line_pnts *tPoints, *outer;
-
     struct line_pnts **isles;
 
     int isles_count = 0;
-
     int res, winding;
-
     int more = 8;
-
     int isles_allocated = 0;
 
     G_debug(2, "Vect_line_buffer()");
@@ -1060,21 +1016,17 @@ void Vect_line_buffer2(struct line_pnts *Points, double da, double db,
    \param[out] inner_count number of holes
    \param[out] iPoints array of output polygon's holes (cw order)
  */
-void Vect_area_buffer2(struct Map_info *Map, int area, double da, double db,
+void Vect_area_buffer2(const struct Map_info *Map, int area, double da, double db,
 		       double dalpha, int round, int caps, double tol,
 		       struct line_pnts **oPoints,
 		       struct line_pnts ***iPoints, int *inner_count)
 {
     struct line_pnts *tPoints, *outer;
-
     struct line_pnts **isles;
 
     int isles_count = 0;
-
     int i, isle;
-
     int more = 8;
-
     int isles_allocated = 0;
 
     G_debug(2, "Vect_area_buffer()");

+ 25 - 23
lib/vector/Vlib/build.c

@@ -5,7 +5,7 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 by the GRASS Development Team
 
    This program is free software under the 
    GNU General Public License (>=v2). 
@@ -13,9 +13,7 @@
    for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 #include <stdlib.h>
 #include <stdio.h>
@@ -63,7 +61,7 @@ int Vect_build(struct Map_info *Map)
 
    \return current highest built level
  */
-int Vect_get_built(struct Map_info *Map)
+int Vect_get_built(const struct Map_info *Map)
 {
     return (Map->plus.built);
 }
@@ -82,27 +80,30 @@ int Vect_get_built(struct Map_info *Map)
    - GV_BUILD_CENTROIDS - assign centroids to areas;
    - GV_BUILD_ALL - top level, the same as GV_BUILD_CENTROIDS.
 
-   If functions is called with build lower than current value of the Map, the level is downgraded to 
-   requested value.
-
-   All calls to Vect_write_line(), Vect_rewrite_line(), Vect_delete_line() respect the last value of 
-   build used in this function.
+   If functions is called with build lower than current value of the
+   Map, the level is downgraded to requested value.
 
-   Values lower than GV_BUILD_ALL are supported only by GV_FORMAT_NATIVE,
-   other formats ignore build and build always GV_BUILD_ALL
+   All calls to Vect_write_line(), Vect_rewrite_line(),
+   Vect_delete_line() respect the last value of build used in this
+   function.
 
-   Note that the functions has effect only if requested level is higher than current level, to rebuild
-   part of topology, call first downgrade and then upgrade, for example:
+   Values lower than GV_BUILD_ALL are supported only by
+   GV_FORMAT_NATIVE, other formats ignore build and build always
+   GV_BUILD_ALL
 
-   Vect_build()
-   Vect_build_partial(,GV_BUILD_BASE,)
-   Vect_build_partial(,GV_BUILD_AREAS,) 
+   Note that the functions has effect only if requested level is
+   higher than current level, to rebuild part of topology, call first
+   downgrade and then upgrade, for example:
 
+   - Vect_build()
+   - Vect_build_partial(,GV_BUILD_BASE,)
+   - Vect_build_partial(,GV_BUILD_AREAS,) 
 
    \param Map vector map
    \param build highest level of build
 
-   \return 1 on success, 0 on error
+   \return 1 on success
+   \return 0 on error
  */
 int Vect_build_partial(struct Map_info *Map, int build)
 {
@@ -234,7 +235,8 @@ int Vect_build_partial(struct Map_info *Map, int build)
 
    \param Map vector map
 
-   \return 1 on success, 0 on error
+   \return 1 on success
+   \return 0 on error
  */
 int Vect_save_topo(struct Map_info *Map)
 {
@@ -279,7 +281,7 @@ int Vect_save_topo(struct Map_info *Map)
    \return 1 on success
    \return 0 on error
  */
-int Vect_topo_dump(struct Map_info *Map, FILE * out)
+int Vect_topo_dump(const struct Map_info *Map, FILE * out)
 {
     int i, j, line, isle;
     P_NODE *Node;
@@ -287,7 +289,7 @@ int Vect_topo_dump(struct Map_info *Map, FILE * out)
     P_AREA *Area;
     P_ISLE *Isle;
     BOUND_BOX box;
-    struct Plus_head *plus;
+    const struct Plus_head *plus;
 
     plus = &(Map->plus);
 
@@ -322,9 +324,9 @@ int Vect_topo_dump(struct Map_info *Map, FILE * out)
 	    continue;
 	}
 	Line = plus->Line[i];
-	fprintf(out, "line = %d, type = %d, offset = %ld n1 = %d, n2 = %d, "
+	fprintf(out, "line = %d, type = %d, offset = %lu n1 = %d, n2 = %d, "
 		"left/area = %d, right = %d\n",
-		i, Line->type, Line->offset, Line->N1, Line->N2,
+		i, Line->type, (unsigned long) Line->offset, Line->N1, Line->N2,
 		Line->left, Line->right);
 	fprintf(out, "N,S,E,W,T,B: %f, %f, %f, %f, %f, %f\n", Line->N,
 		Line->S, Line->E, Line->W, Line->T, Line->B);

+ 7 - 9
lib/vector/Vlib/build_nat.c

@@ -3,7 +3,7 @@
 
    \brief Vector library - Building topology for native format
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 by the GRASS Development Team
 
    This program is free software under the 
    GNU General Public License (>=v2). 
@@ -11,9 +11,7 @@
    for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 
 #include <grass/config.h>
@@ -135,7 +133,7 @@ int Vect_isle_find_area(struct Map_info *Map, int isle)
 {
     int j, line, node, sel_area, first, area, poly;
     static int first_call = 1;
-    struct Plus_head *plus;
+    const struct Plus_head *plus;
     P_LINE *Line;
     P_NODE *Node;
     P_ISLE *Isle;
@@ -297,14 +295,14 @@ int Vect_attach_isle(struct Map_info *Map, int isle)
 }
 
 /*!
-   \brief (Re)Attach isles to areas in given box
+   \brief (Re)Attach isles to areas in given bounding box
 
    \param Map_info vector map
    \param box bounding box
 
    \return 0
  */
-int Vect_attach_isles(struct Map_info *Map, BOUND_BOX * box)
+int Vect_attach_isles(struct Map_info *Map, const BOUND_BOX * box)
 {
     int i, isle;
     static int first = 1;
@@ -331,14 +329,14 @@ int Vect_attach_isles(struct Map_info *Map, BOUND_BOX * box)
 }
 
 /*!
-   \brief (Re)Attach centroids to areas in given box
+   \brief (Re)Attach centroids to areas in given bouding box
 
    \param Map_info vector map
    \param box bounding box
 
    \return 0
  */
-int Vect_attach_centroids(struct Map_info *Map, BOUND_BOX * box)
+int Vect_attach_centroids(struct Map_info *Map, const BOUND_BOX * box)
 {
     int i, sel_area, centr;
     static int first = 1;

+ 4 - 5
lib/vector/Vlib/build_ogr.c

@@ -5,7 +5,7 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 by the GRASS Development Team
 
    This program is free software under the 
    GNU General Public License (>=v2). 
@@ -13,8 +13,6 @@
    for details.
 
    \author Radim Blazek, Piero Cavalieri
-
-   \date 2001-2008
  */
 
 #include <string.h>
@@ -266,8 +264,9 @@ static int add_geometry(struct Map_info *Map, OGRGeometryH hGeom, int FID,
 
 	/* create virtual centroid */
 	ret =
-	    Vect_get_point_in_poly_isl(Points[0], Points + 1, nRings - 1, &x,
-				       &y);
+	    Vect_get_point_in_poly_isl((const struct line_pnts *) Points[0],
+				       (const struct line_pnts **) Points + 1, nRings - 1,
+				       &x, &y);
 	if (ret < -1) {
 	    G_warning(_("Unable to calculate centroid for area %d"),
 		      outer_area);

+ 27 - 27
lib/vector/Vlib/cats.c

@@ -7,10 +7,8 @@
  *
  * (C) 2001-2009 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.
+ * This program is free software under the GNU General Public License
+ * (>=v2).  Read the file COPYING that comes with GRASS for details.
  *
  * \author Original author CERL, probably Dave Gerdes or Mike
  * Higgins
@@ -72,7 +70,8 @@ struct line_cats *Vect__new_cats_struct()
 }
 
 /*!
-   \brief Frees all memory associated with line_cats structure, including the struct itself.
+   \brief Frees all memory associated with line_cats structure,
+   including the struct itself.
 
    \param p line_cats structure
 
@@ -92,7 +91,8 @@ int Vect_destroy_cats_struct(struct line_cats *p)
 }
 
 /*!
-   \brief Add new field/cat to category structure if doesn't exist yet.
+   \brief Add new field/cat to category structure if doesn't exist
+   yet.
 
    \param[in] Cats line_cats structure
    \param[in] field layer number
@@ -145,16 +145,16 @@ int Vect_cat_set(struct line_cats *Cats, int field, int cat)
 /*!
    \brief Get first found category of given field.
 
-   'cat' is set to first category found or -1 if field was not found
+   <em>cat</em> is set to first category found or -1 if field was not found
 
-   \param[in] Cats line_cats structure
-   \param[in] field layer number
-   \param[in] cat pointer to variable where cat will be written
+   \param Cats line_cats structure
+   \param field layer number
+   \param[out] cat pointer to variable where cat will be written
 
    \return 1 found
    \return 0 layer does not exist
  */
-int Vect_cat_get(struct line_cats *Cats, int field, int *cat)
+int Vect_cat_get(const struct line_cats *Cats, int field, int *cat)
 {
     register int n;
 
@@ -188,7 +188,7 @@ int Vect_cat_get(struct line_cats *Cats, int field, int *cat)
    \return number of found categories
    \return -1 on invalid field
  */
-int Vect_field_cat_get(struct line_cats *Cats, int field, struct ilist *cats)
+int Vect_field_cat_get(const struct line_cats *Cats, int field, struct ilist *cats)
 {
     int n;
     
@@ -212,8 +212,8 @@ int Vect_field_cat_get(struct line_cats *Cats, int field, struct ilist *cats)
 /*!
    \brief Delete all categories of given layer
 
-   \param[in] Cats line_cats structure
-   \param[in] field layer number
+   \param[in,out] Cats line_cats structure
+   \param field layer number
 
    \return 1 deleted
    \return 0 layer does not exist
@@ -247,9 +247,9 @@ int Vect_cat_del(struct line_cats *Cats, int field)
 /*!
    \brief Delete field/cat from line_cats structure
 
-   \param[in] Cats line_cats structure
-   \param[in] field layer number
-   \param[in] cat category to be deleted or -1 to delete all cats of given field
+   \param[in,out] Cats line_cats structure
+   \param field layer number
+   \param cat category to be deleted or -1 to delete all cats of given field
 
    \return 1 deleted
    \return 0 field/category number does not exist
@@ -423,13 +423,13 @@ int Vect_str_to_cat_list(const char *str, struct cat_list *list)
 /*!
    \brief Convert ordered array of integers to cat_list structure.
 
-   \param[in] vals array of integers
-   \param[in] nvals number of values
+   \param vals array of integers
+   \param nvals number of values
    \param[out] list result cat_list structure
 
    \return number of ranges
  */
-int Vect_array_to_cat_list(int *vals, int nvals, struct cat_list *list)
+int Vect_array_to_cat_list(const int *vals, int nvals, struct cat_list *list)
 {
     int i, range;
 
@@ -463,13 +463,13 @@ int Vect_array_to_cat_list(int *vals, int nvals, struct cat_list *list)
 /*!
    \brief Check if category number is in list.
 
-   \param[in] cat category number
-   \param[in] list cat_list structure
+   \param cat category number
+   \param list cat_list structure
 
    \return TRUE if cat is in list
    \return FALSE if it is not
  */
-int Vect_cat_in_cat_list(int cat, struct cat_list *list)
+int Vect_cat_in_cat_list(int cat, const struct cat_list *list)
 {
     int i;
 
@@ -483,14 +483,14 @@ int Vect_cat_in_cat_list(int cat, struct cat_list *list)
 /*!
    \brief Check if category is in ordered array of integers.
 
-   \param[in] cat category number
-   \param[in] array ordered array of integers
-   \param[in] ncats number of categories in array
+   \param cat category number
+   \param array ordered array of integers
+   \param ncats number of categories in array
 
    \return TRUE if cat is in list
    \return FALSE if it is not
  */
-int Vect_cat_in_array(int cat, int *array, int ncats)
+int Vect_cat_in_array(int cat, const int *array, int ncats)
 {
     int *i;
 

+ 56 - 57
lib/vector/Vlib/cindex.c

@@ -5,13 +5,12 @@
  *
  * Higher level functions for reading/writing/manipulating vectors.
  *
- * \author Radim Blazek
+ * (C) 2001-2009 by the GRASS Development Team
  *
- * (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.
  *
- * This program is free software under the GNU General Public
- *              License (>=v2). Read the file COPYING that comes with GRASS
- *              for details.
+ * \author Radim Blazek
  */
 
 #include <stdlib.h>
@@ -25,7 +24,7 @@
 
 static int cmp_cat(const void *pa, const void *pb);
 
-static void check_status(struct Map_info *Map)
+static void check_status(const struct Map_info *Map)
 {
     if (!Map->plus.cidx_up_to_date)
 	G_fatal_error(_("Category index is not up to date"));
@@ -34,11 +33,11 @@ static void check_status(struct Map_info *Map)
 /*!
    \brief Get number of layer in category index
 
-   \param[in] Map vector map
+   \param Map vector map
 
    \return number of layers
  */
-int Vect_cidx_get_num_fields(struct Map_info *Map)
+int Vect_cidx_get_num_fields(const struct Map_info *Map)
 {
     check_status(Map);
 
@@ -48,12 +47,12 @@ int Vect_cidx_get_num_fields(struct Map_info *Map)
 /*!
    \brief Get layer number for given index 
 
-   \param[in] Map vector map
-   \param[in] index layer index: from 0 to Vect_cidx_get_num_fields() - 1
+   \param Map vector map
+   \param index layer index: from 0 to Vect_cidx_get_num_fields() - 1
 
    \return layer number 
  */
-int Vect_cidx_get_field_number(struct Map_info *Map, int index)
+int Vect_cidx_get_field_number(const struct Map_info *Map, int index)
 {
     check_status(Map);
 
@@ -66,16 +65,16 @@ int Vect_cidx_get_field_number(struct Map_info *Map, int index)
 /*!
    \brief Get layer index for given layer number
 
-   \param[in] Map vector map
-   \param[in] field layer number 
+   \param Map vector map
+   \param field layer number 
 
    \return layer index
    \return -1 if not found 
  */
-int Vect_cidx_get_field_index(struct Map_info *Map, int field)
+int Vect_cidx_get_field_index(const struct Map_info *Map, int field)
 {
     int i;
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
 
     G_debug(2, "Vect_cidx_get_field_index() field = %d", field);
 
@@ -93,13 +92,13 @@ int Vect_cidx_get_field_index(struct Map_info *Map, int field)
 /*!
    \brief Get number of unique categories for given layer index 
 
-   \param[in] Map vector map
-   \param[in] index layer number
+   \param Map vector map
+   \param index layer number
 
    \return number of unique categories
    \return -1 on error
  */
-int Vect_cidx_get_num_unique_cats_by_index(struct Map_info *Map, int index)
+int Vect_cidx_get_num_unique_cats_by_index(const struct Map_info *Map, int index)
 {
     check_status(Map);
 
@@ -112,13 +111,13 @@ int Vect_cidx_get_num_unique_cats_by_index(struct Map_info *Map, int index)
 /*!
    \brief Get number of categories for given layer index 
 
-   \param[in] Map vector map
-   \param[in] index layer index
+   \param Map vector map
+   \param index layer index
 
    \return number of categories
    \return -1 on error
  */
-int Vect_cidx_get_num_cats_by_index(struct Map_info *Map, int index)
+int Vect_cidx_get_num_cats_by_index(const struct Map_info *Map, int index)
 {
     check_status(Map);
     if (index >= Map->plus.n_cidx)
@@ -130,13 +129,13 @@ int Vect_cidx_get_num_cats_by_index(struct Map_info *Map, int index)
 /*!
    \brief Get number of types for given layer index 
 
-   \param[in] Map vector map
-   \param[in] field_index layer index
+   \param Map vector map
+   \param field_index layer index
 
    \return number of types
    \return -1 on error
  */
-int Vect_cidx_get_num_types_by_index(struct Map_info *Map, int field_index)
+int Vect_cidx_get_num_types_by_index(const struct Map_info *Map, int field_index)
 {
     check_status(Map);
     if (field_index >= Map->plus.n_cidx)
@@ -148,17 +147,17 @@ int Vect_cidx_get_num_types_by_index(struct Map_info *Map, int field_index)
 /*!
    \brief Get type count field index and type index
 
-   \param[in] Map vector map
-   \param[in] field_index layer index
-   \param[in] type_index type index
+   \param Map vector map
+   \param field_index layer index
+   \param type_index type index
    \param[out] type feature type
    \param[out] count number of items
 
-   \return 1 OK
+   \return 1 on success
    \return 0 on error
  */
 int
-Vect_cidx_get_type_count_by_index(struct Map_info *Map, int field_index,
+Vect_cidx_get_type_count_by_index(const struct Map_info *Map, int field_index,
 				  int type_index, int *type, int *count)
 {
     check_status(Map);
@@ -168,20 +167,20 @@ Vect_cidx_get_type_count_by_index(struct Map_info *Map, int field_index,
     *type = Map->plus.cidx[field_index].type[type_index][0];
     *count = Map->plus.cidx[field_index].type[type_index][1];
 
-    return (1);
+    return 1;
 }
 
 /*!
    \brief Get count of features of certain type by layer and type
 
-   \param[in] Map vector map
-   \param[in] field layer number
-   \param[in] type feature type
+   \param Map vector map
+   \param field layer number
+   \param type feature type
 
    \return feature count
    \return 0 if no features, no such field or no such type in cidx
  */
-int Vect_cidx_get_type_count(struct Map_info *Map, int field, int type)
+int Vect_cidx_get_type_count(const struct Map_info *Map, int field, int type)
 {
     int i, fi, count = 0;
 
@@ -211,18 +210,18 @@ int Vect_cidx_get_type_count(struct Map_info *Map, int field, int type)
 /*!
    \brief Get number of categories for given field and category index 
 
-   \param[in] Map vector map
-   \param[in] field_index layer index
-   \param[in] cat_index category index
+   \param Map vector map
+   \param field_index layer index
+   \param cat_index category index
    \param[out] cat category number
    \param[out] type feature type
    \param[out] id feature id
 
-   \return 1 OK
+   \return 1 on success
    \return 0 on error
  */
 int
-Vect_cidx_get_cat_by_index(struct Map_info *Map, int field_index,
+Vect_cidx_get_cat_by_index(const struct Map_info *Map, int field_index,
 			   int cat_index, int *cat, int *type, int *id)
 {
     check_status(Map);		/* This check is slow ? */
@@ -254,11 +253,11 @@ static int cmp_cat(const void *pa, const void *pb)
 /*!
    \brief Find next line/area id for given category, start_index and type_mask 
 
-   \param[in] Map vector map
-   \param[in] field_index layer index
-   \param[in] cat category number
-   \param[in] type_mask requested type
-   \param[in] start_index start search at this index (0 - whole category index)
+   \param Map vector map
+   \param field_index layer index
+   \param cat category number
+   \param type_mask requested type
+   \param start_index start search at this index (0 - whole category index)
    \param[out] type returned type
    \param[out] id returned line/area id
 
@@ -266,7 +265,7 @@ static int cmp_cat(const void *pa, const void *pb)
    \return -1 not found
  */
 int
-Vect_cidx_find_next(struct Map_info *Map, int field_index, int cat,
+Vect_cidx_find_next(const struct Map_info *Map, int field_index, int cat,
 		    int type_mask, int start_index, int *type, int *id)
 {
     int *catp, cat_index;
@@ -331,15 +330,15 @@ Vect_cidx_find_next(struct Map_info *Map, int field_index, int cat,
 /*!
    \brief Gind all line/area id's for given category
 
-   \param[in] Map vector map
-   \param[in] layer layer number
-   \param[in] type_mask type of objects to search for
-   \param[in] cat category number
+   \param Map vector map
+   \param layer layer number
+   \param type_mask type of objects to search for
+   \param cat category number
    \param[out] lines array of ids of found lines/points
 
    \return 
  */
-void Vect_cidx_find_all(struct Map_info *Map, int layer, int type_mask,
+void Vect_cidx_find_all(const struct Map_info *Map, int layer, int type_mask,
 			int cat, struct ilist *lines)
 {
     int type, line;
@@ -379,13 +378,13 @@ void Vect_cidx_find_all(struct Map_info *Map, int layer, int type_mask,
 /*!
    \brief Write category index in text form to file
 
-   \param[in] Map vector map
+   \param Map vector map
    \param[out] out output file
 
    \return 1 on success
    \return 0 on error
  */
-int Vect_cidx_dump(struct Map_info *Map, FILE * out)
+int Vect_cidx_dump(const struct Map_info *Map, FILE * out)
 {
     int i, field, nfields, ntypes;
 
@@ -435,7 +434,7 @@ int Vect_cidx_dump(struct Map_info *Map, FILE * out)
 /*!
    \brief Save category index
 
-   \param[in] Map vector map
+   \param Map vector map
 
    \return 0 on success
    \return 1 on error
@@ -477,8 +476,8 @@ int Vect_cidx_save(struct Map_info *Map)
 /*!
    \brief Read category index from file if exists
 
-   \param[in] Map vector map
-   \param[in] head_only Read only header
+   \param Map vector map
+   \param head_only Read only header
 
    \return 0 on success 
    \return 1 if file does not exist
@@ -508,8 +507,8 @@ int Vect_cidx_open(struct Map_info *Map, int head_only)
     fp.file = G_fopen_old(buf, GV_CIDX_ELEMENT, Map->mapset);
 
     if (fp.file == NULL) {	/* category index file is not available */
-	G_warning(_("Unable to open category index file for vector map <%s@%s>"),
-		  Map->name, Map->mapset);
+	G_warning(_("Unable to open category index file for vector map <%s>"),
+		  Vect_get_full_name(Map));
 	return -1;
     }
 

+ 8 - 12
lib/vector/Vlib/clean_nodes.c

@@ -5,16 +5,12 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001-2008
  */
 
 #include <stdlib.h>
@@ -25,13 +21,13 @@
 /*!
    \brief Clean small angles at nodes.
 
-   It may happen that even if the angle between 2 boundaries at node is
-   very small, the calculated angle is 0 because of
-   representation error.  The map must be built at least on level
-   GV_BUILD_BASE
+   It may happen that even if the angle between 2 boundaries at node
+   is very small, the calculated angle is 0 because of representation
+   error. The map must be built at least on level GV_BUILD_BASE
 
    \param Map input map
-   \param Err vector map where error line segments are written
+   \param otype feature type
+   \param[out] Err vector map where error line segments are written
 
    \return number of line modifications
  */

+ 5 - 9
lib/vector/Vlib/close.c

@@ -5,18 +5,14 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
- */
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
+*/
 
 #include <stdlib.h>
 #include <stdio.h>

+ 23 - 20
lib/vector/Vlib/close_nat.c

@@ -1,27 +1,30 @@
+/*!
+   \file close_nat.c
+
+   \brief Vector library - Close map (native format)
+
+   Higher level functions for reading/writing/manipulating vectors.
+
+   (C) 2001-2009 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.
+
+   \author Original author CERL, probably Dave Gerdes or Mike Higgins.
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
+*/
 
-/****************************************************************************
-*
-* MODULE:       Vector library 
-*   	    	
-* AUTHOR(S):    Original author CERL, probably Dave Gerdes or Mike Higgins.
-*               Update to GRASS 5.7 Radim Blazek and David D. Gray.
-*
-* PURPOSE:      Higher level functions for reading/writing/manipulating vectors.
-*
-* COPYRIGHT:    (C) 2001 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.
-*
-*****************************************************************************/
 #include <grass/Vect.h>
 #include <stdlib.h>
 
-/* 
- ** return 0 on success
- **        non-zero on error
- */
+/*!
+  \brief Close vector map file
+
+  \param Map vector map to be closed
+  
+  \return 0 on success
+  \return non-zero on error
+*/
 int V1_close_nat(struct Map_info *Map)
 {
     struct Coor_info CInfo;

+ 39 - 32
lib/vector/Vlib/close_ogr.c

@@ -1,29 +1,34 @@
+/*!
+   \file close_ogr.c
+
+   \brief Vector library - Close map (OGR)
+
+   Higher level functions for reading/writing/manipulating vectors.
+
+   (C) 2001-2009 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.
+
+   \author Original author CERL, probably Dave Gerdes or Mike Higgins.
+   \author Update to GRASS 5.7 Radim Blazek and Piero Cavalieri.
+*/
 
-/*****************************************************************************
-*
-* MODULE:       Vector library 
-*   	    	
-* AUTHOR(S):    Radim Blazek, Piero Cavalieri 
-*
-* PURPOSE:      Higher level functions for reading/writing/manipulating vectors.
-*
-* COPYRIGHT:    (C) 2001 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.
-*
-*****************************************************************************/
-#include <grass/Vect.h>
 #include <stdlib.h>
+#include <grass/Vect.h>
+#include <grass/glocale.h>
 
 #ifdef HAVE_OGR
 #include <ogr_api.h>
 
-/* 
- ** return 0 on success
- **         non-zero on error
- */
+/*!
+  \brief Close OGR layer
+
+  \param Map vector map
+
+  \return 0 on success
+  \return non-zero on error
+*/
 int V1_close_ogr(struct Map_info *Map)
 {
     int i;
@@ -43,21 +48,23 @@ int V1_close_ogr(struct Map_info *Map)
 	Vect_destroy_line_struct(Map->fInfo.ogr.lines[i]);
     }
 
-    free(Map->fInfo.ogr.lines);
-    free(Map->fInfo.ogr.lines_types);
+    G_free(Map->fInfo.ogr.lines);
+    G_free(Map->fInfo.ogr.lines_types);
 
-    free(Map->fInfo.ogr.dsn);
-    free(Map->fInfo.ogr.layer_name);
+    G_free(Map->fInfo.ogr.dsn);
+    G_free(Map->fInfo.ogr.layer_name);
 
     return 0;
 }
 
-/* 
- *  Write OGR specific files (fidx)
- * 
- *  return 0 on success
- *         non-zero on error
- */
+/*!
+  \brief Write OGR specific files (fidx)
+
+  \param Map vector map
+  
+  \return 0 on success
+  \return non-zero on error
+*/
 int V2_close_ogr(struct Map_info *Map)
 {
     char fname[1000], elem[1000];
@@ -79,7 +86,7 @@ int V2_close_ogr(struct Map_info *Map)
 	dig_file_init(&fp);
 	fp.file = fopen(fname, "w");
 	if (fp.file == NULL) {
-	    G_warning("Can't open fidx file for write: %s\n", fname);
+	    G_warning(_("Unable to open fidx file for write <%s>"), fname);
 	    return 1;
 	}
 
@@ -114,7 +121,7 @@ int V2_close_ogr(struct Map_info *Map)
 
     }
 
-    free(Map->fInfo.ogr.offset);
+    G_free(Map->fInfo.ogr.offset);
 
     return 0;
 }

+ 21 - 24
lib/vector/Vlib/constraint.c

@@ -5,33 +5,30 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   These routines can affect the read_next_line funtions
-   by restricting what they return.
-   They are applied on a per map basis.
+   These routines can affect the read_next_line funtions by
+   restricting what they return. They are applied on a per map basis.
 
    These do not affect the lower level direct read functions.
 
-   Normally, All 'Alive' lines will be returned unless overridden
-   by this function.   You can specified all the types you are interested
-   in  (by oring their types together).  You can use this to say 
-   exclude Area type lines.
+   Normally, all 'Alive' lines will be returned unless overridden by
+   this function. You can specified all the types you are interested
+   in (by oring their types together). You can use this to say exclude
+   Area type lines.
 
-   By default all DEAD lines are ignored by the read_next_line () functions
-   This too can be overridden by including their types.
+   By default all DEAD lines are ignored by the read_next_line ()
+   functions This too can be overridden by including their types.
 
-   Refer to  dig_defines for the line type Defines
+   Refer to dig_defines for the line type Defines
 
    All lines can be forced to be read by setting type = -1
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
 
    \date 2001-2008
  */
@@ -54,9 +51,9 @@ Vect_set_constraint_region(struct Map_info *Map,
 			   double b)
 {
     if (n <= s)
-	return (-1);
+	return -1;
     if (e <= w)
-	return (-1);
+	return -1;
 
     Map->Constraint_region_flag = 1;
     Map->Constraint_N = n;
@@ -67,18 +64,18 @@ Vect_set_constraint_region(struct Map_info *Map,
     Map->Constraint_B = b;
     Map->proj = G_projection();
 
-    return (0);
+    return 0;
 }
 
 /*!
    \brief Get constraint box
 
    \param Map vector map
-   \param Box bounding box
+   \param[out] Box bounding box
 
-   \return 0 on success
+   \return 0
  */
-int Vect_get_constraint_box(struct Map_info *Map, BOUND_BOX * Box)
+int Vect_get_constraint_box(const struct Map_info *Map, BOUND_BOX * Box)
 {
     Box->N = Map->Constraint_N;
     Box->S = Map->Constraint_S;
@@ -96,7 +93,7 @@ int Vect_get_constraint_box(struct Map_info *Map, BOUND_BOX * Box)
    \param Map vector map
    \param type constraint type
 
-   \return 0 on success
+   \return 0
  */
 int Vect_set_constraint_type(struct Map_info *Map, int type)
 {
@@ -111,7 +108,7 @@ int Vect_set_constraint_type(struct Map_info *Map, int type)
 
    \param Map vector map
 
-   \return 0 on success
+   \return 0
  */
 int Vect_remove_constraints(struct Map_info *Map)
 {

+ 14 - 16
lib/vector/Vlib/dangles.c

@@ -5,17 +5,13 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001-2008
- */
+*/
 
 #include <stdlib.h>
 #include <grass/gis.h>
@@ -32,21 +28,22 @@ static void dangles(struct Map_info *, int, int, double,
 /*!
    \brief Remove dangles from vector map.
 
-   Remove dangles of given type shorter than maxlength from vector map.
+   Remove dangles of given type shorter than maxlength from vector
+   map.
 
    Line is considered to be a dangle if on at least one end node is no
-   other line of given type(s).  If a dangle is formed by more lines,
+   other line of given type(s). If a dangle is formed by more lines,
    such string of lines is taken as one dangle and either deleted are
    all parts or nothing.
 
-   Optionally deleted dangles are written to error map. 
+   Optionally deleted dangles are written to error map.
 
    Input map must be opened on level 2 for update.
 
    \param Map input map where have to be deleted
    \param type type of dangles (GV_LINES, GV_LINE or GV_BOUNDARY)
    \param maxlength maxlength of dangles or -1 for all dangles
-   \param Err vector map where deleted dangles are written or NULL
+   \param[out] Err vector map where deleted dangles are written or NULL
 
    \return
  */
@@ -62,9 +59,9 @@ Vect_remove_dangles(struct Map_info *Map, int type, double maxlength,
 
    Change boundary dangles to lines. 
 
-   Boundary is considered to be a dangle if on at least one end node is
-   no other boundary.  If a dangle is formed by more boundaries, such
-   string of boundaries is taken as one dangle.
+   Boundary is considered to be a dangle if on at least one end node
+   is no other boundary. If a dangle is formed by more boundaries,
+   such string of boundaries is taken as one dangle.
 
    Optionally deleted dangles are written to error map. 
 
@@ -72,7 +69,7 @@ Vect_remove_dangles(struct Map_info *Map, int type, double maxlength,
 
    \param Map input map where have to be deleted
    \param maxlength maxlength of dangles or -1 for all dangles
-   \param Err vector map where deleted dangles are written or NULL
+   \param[out] Err vector map where deleted dangles are written or NULL
 
    \return 
  */
@@ -97,6 +94,7 @@ Vect_chtype_dangles(struct Map_info *Map, double maxlength,
    \param Map input map where have to be deleted
    \param type type of dangles (GV_LINES, GV_LINE or GV_BOUNDARY)
    \param maxlength maxlength of dangles or -1 for all dangles
+   \param[out] List list of selected features
 
    \return
  */

+ 7 - 11
lib/vector/Vlib/dbcolumns.c

@@ -5,17 +5,13 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2005-2008 by the GRASS Development Team
+   (C) 2005-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Markus Neteler
-
-   \date 2005-2008
- */
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -37,7 +33,7 @@
    \return list of column(s) names on success
    \return NULL on error 
  */
-const char *Vect_get_column_names(struct Map_info *Map, int field)
+const char *Vect_get_column_names(const struct Map_info *Map, int field)
 {
     int num_dblinks, ncols, col;
     struct field_info *fi;
@@ -96,7 +92,7 @@ const char *Vect_get_column_names(struct Map_info *Map, int field)
    \return list of column(s) types on success
    \return NULL on error 
  */
-const char *Vect_get_column_types(struct Map_info *Map, int field)
+const char *Vect_get_column_types(const struct Map_info *Map, int field)
 {
     int num_dblinks, ncols, col;
     struct field_info *fi;
@@ -158,7 +154,7 @@ const char *Vect_get_column_types(struct Map_info *Map, int field)
    \return list of column(s) types on success
    \retutn NULL on error 
  */
-const char *Vect_get_column_names_types(struct Map_info *Map, int field)
+const char *Vect_get_column_names_types(const struct Map_info *Map, int field)
 {
     int num_dblinks, ncols, col;
     struct field_info *fi;

+ 24 - 21
lib/vector/Vlib/dgraph.c

@@ -1,6 +1,22 @@
+/*!
+   \file dgraph.c
+
+   \brief Vector library - intersection (lower level functions)
+
+   Higher level functions for reading/writing/manipulating vectors.
+
+   (C) 2008-2009 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.
+
+   \author Rewritten by Rosen Matev (Google Summer of Code 2008)
+*/
+
 #include <stdlib.h>
 #include <grass/Vect.h>
 #include <grass/gis.h>
+#include <grass/glocale.h>
 #include "dgraph.h"
 #include "e_intersect.h"
 
@@ -80,7 +96,7 @@ void destroy_si_struct(struct seg_intersections *si)
 
 /* internal use */
 void add_ipoint1(struct seg_intersection_list *il, int with, double dist,
-		 int ip)
+			int ip)
 {
     struct seg_intersection *s;
 
@@ -100,8 +116,8 @@ void add_ipoint1(struct seg_intersection_list *il, int with, double dist,
 }
 
 /* adds intersection point to the structure */
-void add_ipoint(struct line_pnts *Points, int first_seg, int second_seg,
-		double x, double y, struct seg_intersections *si)
+void add_ipoint(const struct line_pnts *Points, int first_seg, int second_seg,
+		       double x, double y, struct seg_intersections *si)
 {
     struct intersection_point *t;
 
@@ -134,7 +150,6 @@ void add_ipoint(struct line_pnts *Points, int first_seg, int second_seg,
 void sort_intersection_list(struct seg_intersection_list *il)
 {
     int n, i, j, min;
-
     struct seg_intersection t;
 
     G_debug(4, "sort_intersection_list()");
@@ -158,7 +173,7 @@ void sort_intersection_list(struct seg_intersection_list *il)
     return;
 }
 
-static int compare(const void *a, const void *b)
+int compare(const void *a, const void *b)
 {
     struct intersection_point *aa, *bb;
 
@@ -199,20 +214,14 @@ double get_epsilon(struct line_pnts *Points)
 }
 
 /* currently O(n*n); future implementation O(nlogn) */
-struct seg_intersections *find_all_intersections(struct line_pnts *Points)
+struct seg_intersections *find_all_intersections(const struct line_pnts *Points)
 {
     int i, j, np;
-
     int group, t;
-
     int looped;
-
     double EPSILON = 0.00000001;
-
     double *x, *y;
-
     double x1, y1, x2, y2;
-
     int res;
 
     /*int res2
@@ -371,9 +380,7 @@ void pg_destroy_struct(struct planar_graph *pg)
 int pg_existsedge(struct planar_graph *pg, int v1, int v2)
 {
     struct pg_vertex *v;
-
     struct pg_edge *e;
-
     int i, ecount;
 
     if (pg->v[v1].ecount <= pg->v[v2].ecount)
@@ -420,8 +427,8 @@ void pg_addedge(struct planar_graph *pg, int v1, int v2)
 	return;
 
     if (pg->ecount == pg->eallocated) {
-	G_fatal_error
-	    ("Trying to add more edges to the planar_graph than the initial allocation size allows");
+	G_fatal_error(_("Trying to add more edges to the planar_graph "
+			"than the initial allocation size allows"));
     }
     e = &(pg->e[pg->ecount]);
     e->v1 = v1;
@@ -437,16 +444,12 @@ void pg_addedge(struct planar_graph *pg, int v1, int v2)
     return;
 }
 
-struct planar_graph *pg_create(struct line_pnts *Points)
+struct planar_graph *pg_create(const struct line_pnts *Points)
 {
     struct seg_intersections *si;
-
     struct planar_graph *pg;
-
     struct intersection_point *ip;
-
     struct pg_vertex *vert;
-
     struct pg_edge *edge;
 
     int i, j, t, v;

+ 1 - 1
lib/vector/Vlib/dgraph.h

@@ -33,6 +33,6 @@ struct planar_graph* pg_create_struct(int n, int e);
 void pg_destroy_struct(struct planar_graph *pg);
 int pg_existsedge(struct planar_graph *pg, int v1, int v2);
 void pg_addedge(struct planar_graph *pg, int v1, int v2);
-struct planar_graph* pg_create(struct line_pnts *Points);
+struct planar_graph* pg_create(const struct line_pnts *Points);
 
 #endif

+ 15 - 2
lib/vector/Vlib/e_intersect.c

@@ -1,3 +1,18 @@
+/*!
+   \file e_intersect.c
+
+   \brief Vector library - intersection (lower level functions)
+
+   Higher level functions for reading/writing/manipulating vectors.
+
+   (C) 2008-2009 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.
+
+   \author Rewritten by Rosen Matev (Google Summer of Code 2008)
+*/
+
 #include <stdlib.h>
 #include <math.h>
 #include <grass/gis.h>
@@ -17,9 +32,7 @@
 
 #ifdef ASDASDASFDSAFFDAS
 mpf_t p11, p12, p21, p22, t1, t2;
-
 mpf_t dd, dda, ddb, delta;
-
 mpf_t rra, rrb;
 
 int initialized = 0;

+ 6 - 10
lib/vector/Vlib/error.c

@@ -5,18 +5,14 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
- */
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
+*/
 
 #include <string.h>
 #include <grass/gis.h>
@@ -33,7 +29,7 @@ static int fatal_err = GV_FATAL_EXIT;
 
    \param  err error type
 
-   \return 0 on success
+   \return 0
  */
 int Vect_set_fatal_error(int err)
 {

+ 23 - 26
lib/vector/Vlib/field.c

@@ -5,21 +5,18 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   TODO: see Vect_read_dblinks; activate auto-FID detection once 
-   OGR_L_GetFIDColumn() is working or solution found if FID not available
+   \todo see Vect_read_dblinks(); activate auto-FID detection once
+   OGR_L_GetFIDColumn() is working or solution found if FID not
+   available
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
- */
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -158,7 +155,7 @@ int Vect_map_del_dblink(struct Map_info *Map, int field)
 }
 
 /*!
-   \brief Check if db connection exists in dblinks structure
+   \brief Check if DB connection exists in dblinks structure
 
    \param Map vector map
    \param field layer number
@@ -166,13 +163,13 @@ int Vect_map_del_dblink(struct Map_info *Map, int field)
    \return 1 dblink for field exists
    \return 0 dblink does not exist for field
  */
-int Vect_map_check_dblink(struct Map_info *Map, int field)
+int Vect_map_check_dblink(const struct Map_info *Map, int field)
 {
     return Vect_check_dblink(Map->dblnk, field);
 }
 
 /*!
-   \brief Check if db connection exists in dblinks structure
+   \brief Check if DB connection exists in dblinks structure
 
    \param p pointer to existing dblinks structure
    \param field layer number
@@ -180,7 +177,7 @@ int Vect_map_check_dblink(struct Map_info *Map, int field)
    \return 1 dblink for field exists
    \return 0 dblink does not exist for field
  */
-int Vect_check_dblink(struct dblinks *p, int field)
+int Vect_check_dblink(const struct dblinks *p, int field)
 {
     int i;
 
@@ -196,7 +193,7 @@ int Vect_check_dblink(struct dblinks *p, int field)
 
 
 /*!
-   \brief Add new db connection to dblinks structure
+   \brief Add new DB connection to dblinks structure
 
    \param p pointer to existing dblinks structure
    \param number layer number
@@ -205,7 +202,7 @@ int Vect_check_dblink(struct dblinks *p, int field)
    \param db database name
    \param driver driver name
 
-   \return 0 OK
+   \return 0 on success
    \return -1 error
  */
 int
@@ -359,7 +356,7 @@ struct field_info
 
    \return pointer to new field_info structure
  */
-struct field_info *Vect_get_dblink(struct Map_info *Map, int link)
+struct field_info *Vect_get_dblink(const struct Map_info *Map, int link)
 {
     struct field_info *fi;
 
@@ -390,8 +387,8 @@ struct field_info *Vect_get_dblink(struct Map_info *Map, int link)
 /*!
    \brief Get information about link to database.
 
-   Variables are substituted by values,
-   field is number of requested field
+   Variables are substituted by values, field is number of requested
+   field
 
    \param Map vector map
    \param field layer number
@@ -399,7 +396,7 @@ struct field_info *Vect_get_dblink(struct Map_info *Map, int link)
    \return pointer to new field_info structure
    \return NULL if not found
  */
-struct field_info *Vect_get_field(struct Map_info *Map, int field)
+struct field_info *Vect_get_field(const struct Map_info *Map, int field)
 {
     int i;
     struct field_info *fi = NULL;
@@ -668,7 +665,7 @@ int Vect_read_dblinks(struct Map_info *Map)
 
    \param Map vector map
 
-   \return 0 OK
+   \return 0 on success
    \return -1 on error
  */
 int Vect_write_dblinks(struct Map_info *Map)
@@ -722,7 +719,7 @@ int Vect_write_dblinks(struct Map_info *Map)
 
    \return pointer to new string
  */
-char *Vect_subst_var(const char *in, struct Map_info *Map)
+char *Vect_subst_var(const char *in, const struct Map_info *Map)
 {
     char *c;
     char buf[1000], str[1000];
@@ -767,9 +764,9 @@ char *Vect_subst_var(const char *in, struct Map_info *Map)
 /*!
    \brief Rewrite 'dbln' file
 
-   Should be used by GRASS modules which update
-   database tables, so that other applications know that tables
-   were changed and can reload data.
+   Should be used by GRASS modules which update database tables, so
+   that other applications know that tables were changed and can
+   reload data.
 
    \param Map vector map
 

+ 30 - 33
lib/vector/Vlib/find.c

@@ -5,14 +5,14 @@
  *
  * Higher level functions for reading/writing/manipulating vectors.
  *
- * \author Original author CERL, probably Dave Gerdes or Mike
- * Higgins. Update to GRASS 5.7 Radim Blazek and David D. Gray.
- *
- * (C) 2001-2007 by the GRASS Development Team
+ * (C) 2001-2009 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.
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+
+ * \author Original author CERL, probably Dave Gerdes or Mike
+ * Higgins.
+ * \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 
 #include <math.h>
@@ -26,10 +26,10 @@
 /*!
  * \brief Find the nearest node.
  *
- * \param[in] Map vector map
- * \param[in] ux,uy,uz point coordinates 
- * \param[in] maxdist max distance from the line
- * \param[in] with_z 3D (WITH_Z, WITHOUT_Z)
+ * \param Map vector map
+ * \param ux,uy,uz point coordinates 
+ * \param maxdist max distance from the line
+ * \param with_z 3D (WITH_Z, WITHOUT_Z)
  *
  * \return number of nearest node
  * \return 0 if not found
@@ -92,20 +92,19 @@ Vect_find_node(struct Map_info *Map,
 /*!
  * \brief Find the nearest line.
  *
- * \param[in] map vector map
- * \param[in] ux,uy,uz points coordinates
- * \param[in] type feature type (GV_LINE, GV_POINT, GV_BOUNDARY or GV_CENTROID)
+ * \param map vector map
+ * \param ux,uy,uz points coordinates
+ * \param type feature type (GV_LINE, GV_POINT, GV_BOUNDARY or GV_CENTROID)
  * if only want to search certain types of lines or -1 if search all lines
- * \param[in] maxdist max distance from the line
- * \param[in] with_z 3D (WITH_Z, WITHOUT_Z)
- * \param[in] exclude if > 0 number of line which should be excluded from selection.
+ * \param maxdist max distance from the line
+ * \param with_z 3D (WITH_Z, WITHOUT_Z)
+ * \param exclude if > 0 number of line which should be excluded from selection.
  * May be useful if we need line nearest to other one. 
  *
  * \return number of nearest line
  * \return 0 if not found
  *
  */
-/* original dig_point_to_line() in grass50 */
 int
 Vect_find_line(struct Map_info *map,
 	       double ux, double uy, double uz,
@@ -129,14 +128,14 @@ Vect_find_line(struct Map_info *map,
 /*!
  * \brief Find the nearest line(s).
  *
- * \param[in] map vector map
- * \param[in] ux,uy,uz points coordinates
- * \param[in] type feature type (GV_LINE, GV_POINT, GV_BOUNDARY or GV_CENTROID)
+ * \param map vector map
+ * \param ux,uy,uz points coordinates
+ * \param type feature type (GV_LINE, GV_POINT, GV_BOUNDARY or GV_CENTROID)
  * if only want to search certain types of lines or -1 if search all lines
- * \param[in] maxdist max distance from the line
- * \param[in] with_z 3D (WITH_Z, WITHOUT_Z)
- * \param[in] exclude list of lines which should be excluded from selection
- * \param[in] found list of found lines (or NULL)
+ * \param maxdist max distance from the line
+ * \param with_z 3D (WITH_Z, WITHOUT_Z)
+ * \param exclude list of lines which should be excluded from selection
+ * \param found list of found lines (or NULL)
  *
  * \return number of nearest line
  * \return 0 if not found
@@ -145,7 +144,7 @@ int
 Vect_find_line_list(struct Map_info *map,
 		    double ux, double uy, double uz,
 		    int type, double maxdist, int with_z,
-		    struct ilist *exclude, struct ilist *found)
+		    const struct ilist *exclude, struct ilist *found)
 {
     int choice;
     double new_dist;
@@ -154,7 +153,7 @@ Vect_find_line_list(struct Map_info *map,
     int i, line;
     static struct line_pnts *Points;
     static int first_time = 1;
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     BOUND_BOX box;
     struct ilist *List;
 
@@ -238,13 +237,12 @@ Vect_find_line_list(struct Map_info *map,
 /*!
  * \brief Find the nearest area
  *
- * \param[in] Map vector map
- * \param[in] x,y point coordinates
+ * \param Map vector map
+ * \param x,y point coordinates
  *
  * \return area number
  * \return 0 if not found
  */
-/* original dig_point_to_area() in grass50 */
 int Vect_find_area(struct Map_info *Map, double x, double y)
 {
     int i, ret, area;
@@ -285,13 +283,12 @@ int Vect_find_area(struct Map_info *Map, double x, double y)
 /*!
  * \brief Find the nearest island
  * 
- * \param[in] Map vector map
- * \param[in] x,y points coordinates
+ * \param Map vector map
+ * \param x,y points coordinates
  *
  * \return island number,
  * \return 0 if not found
  */
-/* original dig_point_to_area() in grass50 */
 int Vect_find_island(struct Map_info *Map, double x, double y)
 {
     int i, ret, island, current, current_size, size;

+ 1 - 1
lib/vector/Vlib/geos.c

@@ -8,7 +8,7 @@
  * (C) 2009 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.
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
  *
  * \author Martin Landa <landa.martin gmail.com>
  */

+ 10 - 14
lib/vector/Vlib/graph.c

@@ -5,18 +5,14 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   TODO: Vect_graph_free ( GRAPH *graph )
+   \todo Vect_graph_free ( GRAPH *graph )
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001-2008
  */
 
 #include <stdlib.h>
@@ -92,8 +88,8 @@ void Vect_graph_init(GRAPH * graph, int nodes_costs)
    \brief Build network graph.
 
    Internal format for edge costs is integer, costs are multiplied
-   before conversion to int by 1000. 
-   Costs -1 for infinity i.e. arc or node is closed and cannot be traversed.
+   before conversion to int by 1000.  Costs -1 for infinity i.e. arc
+   or node is closed and cannot be traversed.
 
    \param graph poiter to graph structure
 
@@ -114,8 +110,8 @@ void Vect_graph_build(GRAPH * graph)
    \brief Add edge to graph. 
 
    Internal format for edge costs is integer, costs are multiplied
-   before conversion to int by 1000.  Costs -1 for infinity i.e. arc or
-   node is closed and cannot be traversed.
+   before conversion to int by 1000.  Costs -1 for infinity i.e. arc
+   or node is closed and cannot be traversed.
 
    \param graph poiter to graph structure
    \param from from node
@@ -147,8 +143,8 @@ Vect_graph_add_edge(GRAPH * graph, int from, int to, double costs, int id)
    \brief Set node costs
 
    Internal format for edge costs is integer, costs are multiplied
-   before conversion to int by 1000.  Costs -1 for infinity i.e. arc or
-   node is closed and cannot be traversed.
+   before conversion to int by 1000.  Costs -1 for infinity i.e. arc
+   or node is closed and cannot be traversed.
 
    \param graph poiter to graph structure
    \param node node id

+ 55 - 49
lib/vector/Vlib/header.c

@@ -5,17 +5,13 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 
 #include <stdlib.h>
@@ -34,7 +30,7 @@ static int lookup(const char *file, const char *key, char *value, size_t len);
 
    \return 0 on success
  */
-int Vect_print_header(struct Map_info *Map)
+int Vect_print_header(const struct Map_info *Map)
 {
     fprintf(stdout, "\nSelected information from dig header\n");
     fprintf(stdout, " Organization:  %s\n", Vect_get_organization(Map));
@@ -51,7 +47,7 @@ int Vect_print_header(struct Map_info *Map)
 
    \param Map vector map
 
-   \return 0 on success
+   \return 0
  */
 int Vect_read_header(struct Map_info *Map)
 {
@@ -65,9 +61,9 @@ int Vect_read_header(struct Map_info *Map)
 
    \param Map vector map
 
-   \return 0 on success
+   \return 0
  */
-int Vect_write_header(struct Map_info *Map)
+int Vect_write_header(const struct Map_info *Map)
 {
     /* do some sanity checking here */
     Vect__write_head(Map);
@@ -80,12 +76,12 @@ int Vect_write_header(struct Map_info *Map)
 
    \param Map vector map
 
-   \return GRASS_OK - success
-   \return GRASS_ERR - error
+   \return GRASS_OK on success
+   \return GRASS_ERR on error
  */
-int Vect__write_head(struct Map_info *Map)
+int Vect__write_head(const struct Map_info *Map)
 {
-    char buf[200];
+    char buf[GPATH_MAX];
     FILE *head_fp;
 
     sprintf(buf, "%s/%s", GRASS_VECT_DIRECTORY, Map->name);
@@ -116,13 +112,13 @@ int Vect__write_head(struct Map_info *Map)
 
    \param Map vector map
 
-   \return GRASS_OK - success
-   \return GRASS_ERR - error
+   \return GRASS_OK on success
+   \return GRASS_ERR on error
  */
 int Vect__read_head(struct Map_info *Map)
 {
     FILE *head_fp;
-    char buff[2001];
+    char buff[GPATH_MAX];
     char *ptr;
 
     /* Reset / init */
@@ -198,7 +194,7 @@ int Vect__read_head(struct Map_info *Map)
 
    \return poiter to map name
  */
-const char *Vect_get_name(struct Map_info *Map)
+const char *Vect_get_name(const struct Map_info *Map)
 {
     return (Map->name);
 }
@@ -210,7 +206,7 @@ const char *Vect_get_name(struct Map_info *Map)
 
    \return poiter to mapset name
  */
-const char *Vect_get_mapset(struct Map_info *Map)
+const char *Vect_get_mapset(const struct Map_info *Map)
 {
     return (Map->mapset);
 }
@@ -218,11 +214,12 @@ const char *Vect_get_mapset(struct Map_info *Map)
 /*!
    \brief Get full map name
 
+   Allocated string should be freed by G_free().
    \param Map vector map
 
    \return poiter to map name (name@mapset)
  */
-const char *Vect_get_full_name(struct Map_info *Map)
+const char *Vect_get_full_name(const struct Map_info *Map)
 {
     char *ptr;
 
@@ -239,7 +236,7 @@ const char *Vect_get_full_name(struct Map_info *Map)
    \return 1 map is 3D
    \return 0 map is not 3D
  */
-int Vect_is_3d(struct Map_info *Map)
+int Vect_is_3d(const struct Map_info *Map)
 {
     return (Map->head.with_z);
 }
@@ -267,7 +264,7 @@ int Vect_set_organization(struct Map_info *Map, const char *str)
 
    \return organization string
  */
-const char *Vect_get_organization(struct Map_info *Map)
+const char *Vect_get_organization(const struct Map_info *Map)
 {
     return (Map->head.organization);
 }
@@ -281,13 +278,14 @@ const char *Vect_get_organization(struct Map_info *Map)
    \param Map vector map
    \param str data string
 
-   \return 0 on success
+   \return 0
  */
 int Vect_set_date(struct Map_info *Map, const char *str)
 {
     G_free(Map->head.date);
     Map->head.date = G_store(str);
-    return (0);
+
+    return 0;
 }
 
 /*!
@@ -300,7 +298,7 @@ int Vect_set_date(struct Map_info *Map, const char *str)
 
    \return date of digitization string
  */
-const char *Vect_get_date(struct Map_info *Map)
+const char *Vect_get_date(const struct Map_info *Map)
 {
     return (Map->head.date);
 }
@@ -317,7 +315,8 @@ int Vect_set_person(struct Map_info *Map, const char *str)
 {
     G_free(Map->head.your_name);
     Map->head.your_name = G_store(str);
-    return (0);
+
+    return 0;
 }
 
 /*!
@@ -327,7 +326,7 @@ int Vect_set_person(struct Map_info *Map, const char *str)
 
    \return user name string
  */
-const char *Vect_get_person(struct Map_info *Map)
+const char *Vect_get_person(const struct Map_info *Map)
 {
     return (Map->head.your_name);
 }
@@ -344,7 +343,8 @@ int Vect_set_map_name(struct Map_info *Map, const char *str)
 {
     G_free(Map->head.map_name);
     Map->head.map_name = G_store(str);
-    return (0);
+    
+    return 0;
 }
 
 /*!
@@ -354,7 +354,7 @@ int Vect_set_map_name(struct Map_info *Map, const char *str)
 
    \return map name string
  */
-const char *Vect_get_map_name(struct Map_info *Map)
+const char *Vect_get_map_name(const struct Map_info *Map)
 {
     return (Map->head.map_name);
 }
@@ -371,7 +371,8 @@ int Vect_set_map_date(struct Map_info *Map, const char *str)
 {
     G_free(Map->head.source_date);
     Map->head.source_date = G_store(str);
-    return (0);
+    
+    return 0;
 }
 
 /*!
@@ -381,7 +382,7 @@ int Vect_set_map_date(struct Map_info *Map, const char *str)
 
    \return date when the source map was originally produced string
  */
-const char *Vect_get_map_date(struct Map_info *Map)
+const char *Vect_get_map_date(const struct Map_info *Map)
 {
     return (Map->head.source_date);
 }
@@ -397,7 +398,8 @@ const char *Vect_get_map_date(struct Map_info *Map)
 int Vect_set_scale(struct Map_info *Map, int scale)
 {
     Map->head.orig_scale = scale;
-    return (0);
+    
+    return 0;
 }
 
 /*!
@@ -407,9 +409,9 @@ int Vect_set_scale(struct Map_info *Map, int scale)
 
    \return map scale
  */
-int Vect_get_scale(struct Map_info *Map)
+int Vect_get_scale(const struct Map_info *Map)
 {
-    return ((int)Map->head.orig_scale);
+    return ((int) Map->head.orig_scale);
 }
 
 /*!
@@ -424,7 +426,8 @@ int Vect_set_comment(struct Map_info *Map, const char *str)
 {
     G_free(Map->head.line_3);
     Map->head.line_3 = G_store(str);
-    return (0);
+    
+    return 0;
 }
 
 /*!
@@ -434,7 +437,7 @@ int Vect_set_comment(struct Map_info *Map, const char *str)
 
    \return comment or other info string
  */
-const char *Vect_get_comment(struct Map_info *Map)
+const char *Vect_get_comment(const struct Map_info *Map)
 {
     return (Map->head.line_3);
 }
@@ -450,7 +453,8 @@ const char *Vect_get_comment(struct Map_info *Map)
 int Vect_set_zone(struct Map_info *Map, int zone)
 {
     Map->head.plani_zone = zone;
-    return (0);
+    
+    return 0;
 }
 
 
@@ -461,7 +465,7 @@ int Vect_set_zone(struct Map_info *Map, int zone)
 
    \return projection zone
  */
-int Vect_get_zone(struct Map_info *Map)
+int Vect_get_zone(const struct Map_info *Map)
 {
     return (Map->head.plani_zone);
 }
@@ -471,12 +475,12 @@ int Vect_get_zone(struct Map_info *Map)
 
    \param Map vector map
 
-   \return PROJECTION_XY 0 - x,y (Raw imagery),
-   \return PROJECTION_UTM 1 - UTM   Universal Transverse Mercator,
-   \return PROJECTION_SP  2 - State Plane (in feet),
-   \return PROJECTION_LL  3 - Latitude-Longitude
+   \return PROJECTION_XY  - x,y (Raw imagery),
+   \return PROJECTION_UTM - UTM   Universal Transverse Mercator,
+   \return PROJECTION_SP  - State Plane (in feet),
+   \return PROJECTION_LL  - Latitude-Longitude
  */
-int Vect_get_proj(struct Map_info *Map)
+int Vect_get_proj(const struct Map_info *Map)
 {
     return (Map->proj);
 }
@@ -486,15 +490,16 @@ int Vect_get_proj(struct Map_info *Map)
    \brief Query cartographic projection name of vector map
 
    Returns a pointer to a string which is a printable name for
-   projection code <b>proj</b> (as returned by <i>Vect_get_proj()</i>). Returns
-   NULL if <b>proj</b> is not a valid projection.
+   projection code <em>proj</em> (as returned by
+   Vect_get_proj()).
 
    \param Map vector map
 
    \return poiter to projection name
+   \return NULL if <em>proj</em> is not a valid projection
  */
 
-const char *Vect_get_proj_name(struct Map_info *Map)
+const char *Vect_get_proj_name(const struct Map_info *Map)
 {
     char name[256];
     int n;
@@ -508,6 +513,7 @@ const char *Vect_get_proj_name(struct Map_info *Map)
     }
     if (!lookup(PROJECTION_FILE, "name", name, sizeof(name)))
 	strcpy(name, _("Unknown projection"));
+
     return G_store(name);
 }
 
@@ -533,7 +539,7 @@ int Vect_set_thresh(struct Map_info *Map, double thresh)
 
    \return threshold used for digitization
  */
-double Vect_get_thresh(struct Map_info *Map)
+double Vect_get_thresh(const struct Map_info *Map)
 {
     G_debug(1, "Vect_get_thresh(): thresh = %f", Map->head.digit_thresh);
     return (Map->head.digit_thresh);

+ 12 - 15
lib/vector/Vlib/hist.c

@@ -5,16 +5,12 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001-2008
  */
 
 #include <stdlib.h>
@@ -27,7 +23,7 @@
 
    \param Map vector map
 
-   \return 0 OK
+   \return 0 on success
    \return -1 error
  */
 int Vect_hist_command(struct Map_info *Map)
@@ -45,7 +41,8 @@ int Vect_hist_command(struct Map_info *Map)
     sprintf(buf, "GISDBASE: %s\n", G_gisdbase());	/* Needed ? */
     Vect_hist_write(Map, buf);
 
-    sprintf(buf, "LOCATION: %s MAPSET: %s USER: %s DATE: %s\n", G_location(), G_mapset(), G_whoami(), G_date());	/* Needed ? */
+    sprintf(buf, "LOCATION: %s MAPSET: %s USER: %s DATE: %s\n",
+	    G_location(), G_mapset(), G_whoami(), G_date());	/* Needed ? */
     Vect_hist_write(Map, buf);
 
     return 0;
@@ -73,7 +70,7 @@ int Vect_hist_write(struct Map_info *Map, const char *str)
 /*!
    \brief Reads one line from history file without newline character
 
-   \param s buffer, allocated space must be size+1
+   \param[out] s buffer, allocated space must be size+1
    \param size maximum number of character
    \param Map vector map
 
@@ -81,7 +78,7 @@ int Vect_hist_write(struct Map_info *Map, const char *str)
    \return NULL on error
    \return EOF end of file
  */
-char *Vect_hist_read(char *s, int size, struct Map_info *Map)
+char *Vect_hist_read(char *s, int size, const struct Map_info *Map)
 {
     int ret;
 
@@ -117,12 +114,12 @@ void Vect_hist_rewind(struct Map_info *Map)
    \brief Copy history from one map to another
 
    \param In input vector map
-   \param Out output vector map
+   \param[out] Out output vector map
 
-   \return 0 OK
-   \return -1 error
+   \return 0 on success
+   \return -1 on error
  */
-int Vect_hist_copy(struct Map_info *In, struct Map_info *Out)
+int Vect_hist_copy(const struct Map_info *In, struct Map_info *Out)
 {
     size_t red, ret;
     char buf[1000];

+ 10 - 14
lib/vector/Vlib/init_head.c

@@ -5,21 +5,17 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   Initialize Head structure.  To make sure that we are not writing
-   out garbage to a file.
+   Initialize Head structure. To make sure that we are not writing out
+   garbage to a file.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
- */
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
+*/
 
 #include <string.h>
 #include <grass/gis.h>
@@ -66,11 +62,11 @@ int Vect__init_head(struct Map_info *Map)
    \brief Copy header data from one to another map
 
    \param from target vector map 
-   \param to destination vector map
+   \param[out] to destination vector map
 
-   \return 0 on success
+   \return 0
  */
-int Vect_copy_head_data(struct Map_info *from, struct Map_info *to)
+int Vect_copy_head_data(const struct Map_info *from, struct Map_info *to)
 {
     Vect_set_organization(to, Vect_get_organization(from));
     Vect_set_date(to, Vect_get_date(from));

+ 68 - 71
lib/vector/Vlib/intersect.c

@@ -5,17 +5,64 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 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.
+   Some parts of code taken from grass50 v.spag/linecros.c
+   
+   Based on the following:
+   
+   <code>
+   (ax2-ax1)r1 - (bx2-bx1)r2 = ax2 - ax1
+   (ay2-ay1)r1 - (by2-by1)r2 = ay2 - ay1
+   </code>
+ 
+   Solving for r1 and r2, if r1 and r2 are between 0 and 1, then line
+   segments (ax1,ay1)(ax2,ay2) and (bx1,by1)(bx2,by2) intersect.
+
+   Intersect 2 line segments.
+ 
+   Returns: 0 - do not intersect
+            1 - intersect at one point
+   <pre>
+                 \  /    \  /  \  /
+                  \/      \/    \/
+                  /\             \
+                 /  \             \
+           2 - partial overlap         ( \/                      )
+                ------      a          (    distance < threshold )
+                   ------   b          (                         )
+           3 - a contains b            ( /\                      )
+                ----------  a    ----------- a
+                   ----     b          ----- b
+	     4 - b contains a
+                   ----     a          ----- a
+                ----------  b    ----------- b
+            5 - identical
+                ----------  a
+                ----------  b
+  </pre>
+  Intersection points: 
+  <pre>
+  return  point1 breakes: point2 breaks:    distance1 on:   distance2 on:
+      0        -              -                  -              -  
+      1        a,b            -                  a              b
+      2        a              b                  a              b
+      3        a              a                  a              a
+      4        b              b                  b              b
+      5        -              -                  -              -
+  </pre>
+   Sometimes (often) is important to get the same coordinates for a x
+   b and b x a.  To reach this, the segments a,b are 'sorted' at the
+   beginning, so that for the same switched segments, results are
+   identical. (reason is that double values are always rounded because
+   of limited number of decimal places and for different order of
+   coordinates, the results would be different)
+
+   (C) 2001-2009 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.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek.
-
-   \date 2001-2008
+   \author Update to GRASS 5.7 Radim Blazek.
  */
 
 #include <stdlib.h>
@@ -36,68 +83,18 @@ static int ident(double x1, double y1, double x2, double y2, double thresh);
 static int cross_seg(int id, int *arg);
 static int find_cross(int id, int *arg);
 
-
-/* Some parts of code taken from grass50 v.spag/linecros.c
- * 
- * Based on the following:
- * 
- *     (ax2-ax1)r1 - (bx2-bx1)r2 = ax2 - ax1
- *     (ay2-ay1)r1 - (by2-by1)r2 = ay2 - ay1
- * 
- * Solving for r1 and r2, if r1 and r2 are between 0 and 1,
- * then line segments (ax1,ay1)(ax2,ay2) and (bx1,by1)(bx2,by2)
- * intersect
- * ****************************************************************/
-
 #define D  ((ax2-ax1)*(by1-by2) - (ay2-ay1)*(bx1-bx2))
 #define D1 ((bx1-ax1)*(by1-by2) - (by1-ay1)*(bx1-bx2))
 #define D2 ((ax2-ax1)*(by1-ay1) - (ay2-ay1)*(bx1-ax1))
 
-/* Intersect 2 line segments.
- *
- *  Returns: 0 - do not intersect
- *           1 - intersect at one point
- *                 \  /    \  /  \  /
- *                  \/      \/    \/
- *                  /\             \
- *                 /  \             \
- *           2 - partial overlap         ( \/                      )
- *                ------      a          (    distance < threshold )
- *                   ------   b          (                         )
- *           3 - a contains b            ( /\                      )
- *                ----------  a    ----------- a
- *                   ----     b          ----- b
- *           4 - b contains a
- *                   ----     a          ----- a
- *                ----------  b    ----------- b
- *           5 - identical
- *                ----------  a
- *                ----------  b
- *
- *  Intersection points: 
- *  return  point1 breakes: point2 breaks:    distance1 on:   distance2 on:
- *     0        -              -                  -              -  
- *     1        a,b            -                  a              b
- *     2        a              b                  a              b
- *     3        a              a                  a              a
- *     4        b              b                  b              b
- *     5        -              -                  -              -
- *     
- *  Sometimes (often) is important to get the same coordinates for a x b and b x a.
- *  To reach this, the segments a,b are 'sorted' at the beginning, so that for the same switched segments,
- *  results are identical. (reason is that double values are always rounded because of limited number
- *  of decimal places and for different order of coordinates, the results would be different)
- *     
- */
-
 /*!
  * \brief Check for intersect of 2 line segments.
  *
- * \param[in] ax1,ay1,az1,ax2,ay2,az2 input line a
- * \param[in] bx1,by1,bz1,bx2,by2,bz2 input line b
+ * \param ax1,ay1,az1,ax2,ay2,az2 input line a
+ * \param bx1,by1,bz1,bx2,by2,bz2 input line b
  * \param[out] x1,y1,z1 intersection point1 (case 2-4)
  * \param[out] x2,y2,z2 intersection point2 (case 2-4)
- * \param[in] with_z use z coordinate (3D) (TODO)
+ * \param with_z use z coordinate (3D) (TODO)
  *
  * \return 0 - do not intersect,
  * \return 1 - intersect at one point,
@@ -586,13 +583,13 @@ static int cross_seg(int id, int *arg)
  * intersection with B line. Points (Points->n_points == 1) are not
  * supported.
  *
- * \param[in] APoints first input line 
- * \param[in] BPoints second input line 
+ * \param APoints first input line 
+ * \param BPoints second input line 
  * \param[out] ALines array of new lines created from original A line
  * \param[out] BLines array of new lines created from original B line
  * \param[out] nalines number of new lines (ALines)
  * \param[out] nblines number of new lines (BLines)
- * \param[in] with_z 3D, not supported!
+ * \param with_z 3D, not supported!
  *
  * \return 0 no intersection 
  * \return 1 intersection found
@@ -1120,9 +1117,9 @@ static int find_cross(int id, int *arg)
  *
  * Points (Points->n_points == 1) are also supported.
  *
- * \param[in] APoints first input line 
- * \param[in] BPoints second input line 
- * \param[in] with_z 3D, not supported (only if one or both are points)!
+ * \param APoints first input line 
+ * \param BPoints second input line 
+ * \param with_z 3D, not supported (only if one or both are points)!
  *
  * \return 0 no intersection 
  * \return 1 intersection found
@@ -1294,10 +1291,10 @@ Vect_line_check_intersection(struct line_pnts *APoints,
  * 
  * A wrapper around Vect_line_check_intersection() function.
  *
- * \param[in] APoints first input line 
- * \param[in] BPoints second input line 
+ * \param APoints first input line 
+ * \param BPoints second input line 
  * \param[out] IPoints output with intersection points
- * \param[in] with_z 3D, not supported (only if one or both are points)!
+ * \param with_z 3D, not supported (only if one or both are points)!
  *
  * \return 0 no intersection 
  * \return 1 intersection found

+ 7 - 11
lib/vector/Vlib/legal_vname.c

@@ -3,16 +3,12 @@
 
    \brief Vector library - Check if map name is legal vector map name
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001-2008
  */
 
 #include <string.h>
@@ -27,7 +23,7 @@
 
    Check also for SQL keywords.
 
-   \param[in] s filename to be checked
+   \param s filename to be checked
 
    \return 1 OK
    \return -1 if name does not start with letter A..Za..z or if name does not continue with A..Za..z0..9_@
@@ -83,9 +79,9 @@ int Vect_legal_filename(const char *s)
    - if can find input map
    - if input was found in current mapset, check if input != output
 
-   \param[in] input input name
-   \param[in] output output name
-   \param[in] error error type GV_FATAL_EXIT, GV_FATAL_PRINT, GV_FATAL_RETURN
+   \param input input name
+   \param output output name
+   \param error error type GV_FATAL_EXIT, GV_FATAL_PRINT, GV_FATAL_RETURN
 
    \return 0 OK
    \return 1 error

+ 5 - 9
lib/vector/Vlib/level.c

@@ -3,17 +3,13 @@
 
    \brief Vector library - level info
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 
 #include <grass/Vect.h>
@@ -30,7 +26,7 @@
    \return open level 
    \return -1 on error
  */
-int Vect_level(struct Map_info *Map)
+int Vect_level(const struct Map_info *Map)
 {
     if (Map->open != VECT_OPEN_CODE) {
 	if (Map->open != VECT_CLOSED_CODE)

+ 19 - 21
lib/vector/Vlib/level_two.c

@@ -3,15 +3,13 @@
 
    \brief Vector library - topology level functions
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
    \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
  */
 
 #include <stdlib.h>
@@ -26,7 +24,7 @@
 
    \return number of nodes
  */
-int Vect_get_num_nodes(struct Map_info *map)
+int Vect_get_num_nodes(const struct Map_info *map)
 {
     return (map->plus.n_nodes);
 }
@@ -39,7 +37,7 @@ int Vect_get_num_nodes(struct Map_info *map)
 
    \return number of primitives
  */
-int Vect_get_num_primitives(struct Map_info *map, int type)
+int Vect_get_num_primitives(const struct Map_info *map, int type)
 {
     int num = 0;
 
@@ -66,7 +64,7 @@ int Vect_get_num_primitives(struct Map_info *map, int type)
 
    \return number of features
  */
-int Vect_get_num_lines(struct Map_info *map)
+int Vect_get_num_lines(const struct Map_info *map)
 {
     return (map->plus.n_lines);
 }
@@ -78,7 +76,7 @@ int Vect_get_num_lines(struct Map_info *map)
 
    \return number of areas
  */
-int Vect_get_num_areas(struct Map_info *map)
+int Vect_get_num_areas(const struct Map_info *map)
 {
     return (map->plus.n_areas);
 }
@@ -90,7 +88,7 @@ int Vect_get_num_areas(struct Map_info *map)
 
    \return number of faces
  */
-int Vect_get_num_faces(struct Map_info *map)
+int Vect_get_num_faces(const struct Map_info *map)
 {
     return (map->plus.n_flines);
 }
@@ -102,7 +100,7 @@ int Vect_get_num_faces(struct Map_info *map)
 
    \return number of islands
  */
-int Vect_get_num_islands(struct Map_info *map)
+int Vect_get_num_islands(const struct Map_info *map)
 {
     return (map->plus.n_isles);
 }
@@ -114,7 +112,7 @@ int Vect_get_num_islands(struct Map_info *map)
 
    \return number of dblinks
  */
-int Vect_get_num_dblinks(struct Map_info *map)
+int Vect_get_num_dblinks(const struct Map_info *map)
 {
     return (map->dblnk->n_fields);
 }
@@ -126,7 +124,7 @@ int Vect_get_num_dblinks(struct Map_info *map)
 
    \return number of updated features
  */
-int Vect_get_num_updated_lines(struct Map_info *map)
+int Vect_get_num_updated_lines(const struct Map_info *map)
 {
     return (map->plus.n_uplines);
 }
@@ -139,7 +137,7 @@ int Vect_get_num_updated_lines(struct Map_info *map)
 
    \return updated line
  */
-int Vect_get_updated_line(struct Map_info *map, int idx)
+int Vect_get_updated_line(const struct Map_info *map, int idx)
 {
     return (map->plus.uplines[idx]);
 }
@@ -151,7 +149,7 @@ int Vect_get_updated_line(struct Map_info *map, int idx)
 
    \return number of updated nodes
  */
-int Vect_get_num_updated_nodes(struct Map_info *map)
+int Vect_get_num_updated_nodes(const struct Map_info *map)
 {
     return (map->plus.n_upnodes);
 }
@@ -164,7 +162,7 @@ int Vect_get_num_updated_nodes(struct Map_info *map)
 
    \return updated node
  */
-int Vect_get_updated_node(struct Map_info *map, int idx)
+int Vect_get_updated_node(const struct Map_info *map, int idx)
 {
     return (map->plus.upnodes[idx]);
 }
@@ -179,7 +177,7 @@ int Vect_get_updated_node(struct Map_info *map, int idx)
    \return 0
  */
 int
-Vect_get_node_coor(struct Map_info *map, int num, double *x, double *y,
+Vect_get_node_coor(const struct Map_info *map, int num, double *x, double *y,
 		   double *z)
 {
     P_NODE *Node;
@@ -203,7 +201,7 @@ Vect_get_node_coor(struct Map_info *map, int num, double *x, double *y,
 
    \return 1
  */
-int Vect_get_line_nodes(struct Map_info *Map, int line, int *n1, int *n2)
+int Vect_get_line_nodes(const struct Map_info *Map, int line, int *n1, int *n2)
 {
 
     if (Map->level < 2)
@@ -228,7 +226,7 @@ int Vect_get_line_nodes(struct Map_info *Map, int line, int *n1, int *n2)
 
    \return 1
  */
-int Vect_get_line_areas(struct Map_info *Map, int line, int *left, int *right)
+int Vect_get_line_areas(const struct Map_info *Map, int line, int *left, int *right)
 {
 
     if (Map->level < 2)
@@ -252,7 +250,7 @@ int Vect_get_line_areas(struct Map_info *Map, int line, int *left, int *right)
 
    \return numbers of lines
  */
-int Vect_get_node_n_lines(struct Map_info *Map, int node)
+int Vect_get_node_n_lines(const struct Map_info *Map, int node)
 {
 
     if (Map->level < 2)
@@ -272,7 +270,7 @@ int Vect_get_node_n_lines(struct Map_info *Map, int node)
 
    \return line id
  */
-int Vect_get_node_line(struct Map_info *Map, int node, int line)
+int Vect_get_node_line(const struct Map_info *Map, int node, int line)
 {
     if (Map->level < 2)
 	G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
@@ -290,7 +288,7 @@ int Vect_get_node_line(struct Map_info *Map, int node, int line)
 
    \return angle of segment of the line connected to the node
  */
-float Vect_get_node_line_angle(struct Map_info *Map, int node, int line)
+float Vect_get_node_line_angle(const struct Map_info *Map, int node, int line)
 {
     if (Map->level < 2)
 	G_fatal_error(_("Vector map <%s> is not open on level >= 2"),
@@ -309,7 +307,7 @@ float Vect_get_node_line_angle(struct Map_info *Map, int node, int line)
    \return 0 for not in area
    \return negative id if area/centroid (?) is duplicate
  */
-int Vect_get_centroid_area(struct Map_info *Map, int centroid)
+int Vect_get_centroid_area(const struct Map_info *Map, int centroid)
 {
     if (Map->level < 2)
 	G_fatal_error(_("Vector map <%s> is not open on level >= 2"),

+ 19 - 23
lib/vector/Vlib/line.c

@@ -3,18 +3,14 @@
 
    \brief Vector library - geometry manipulation
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
- */
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
+*/
 
 #include <stdlib.h>
 #include <math.h>
@@ -110,8 +106,8 @@ int Vect_destroy_line_struct(struct line_pnts *p)
    \return -1 on out of memory
  */
 int
-Vect_copy_xyz_to_pnts(struct line_pnts *Points, double *x, double *y,
-		      double *z, int n)
+Vect_copy_xyz_to_pnts(struct line_pnts *Points, const double *x, const double *y,
+		      const double *z, int n)
 {
     register int i;
 
@@ -307,7 +303,7 @@ int Vect_line_prune_thresh(struct line_pnts *Points, double threshold)
    \return -1 on out of memory
  */
 int
-Vect_append_points(struct line_pnts *Points, struct line_pnts *APoints,
+Vect_append_points(struct line_pnts *Points, const struct line_pnts *APoints,
 		   int direction)
 {
     int i, n, on, an;
@@ -354,7 +350,7 @@ Vect_append_points(struct line_pnts *Points, struct line_pnts *APoints,
    \return number of points copied
  */
 int
-Vect_copy_pnts_to_xyz(struct line_pnts *Points, double *x, double *y,
+Vect_copy_pnts_to_xyz(const struct line_pnts *Points, double *x, double *y,
 		      double *z, int *n)
 {
     register int i;
@@ -388,7 +384,7 @@ Vect_copy_pnts_to_xyz(struct line_pnts *Points, double *x, double *y,
 
  */
 int
-Vect_point_on_line(struct line_pnts *Points, double distance,
+Vect_point_on_line(const struct line_pnts *Points, double distance,
 		   double *x, double *y, double *z, double *angle,
 		   double *slope)
 {
@@ -492,7 +488,7 @@ Vect_point_on_line(struct line_pnts *Points, double distance,
    \return 0 error when start > length or end < 0 or start < 0 or end > length
  */
 int
-Vect_line_segment(struct line_pnts *InPoints, double start, double end,
+Vect_line_segment(const struct line_pnts *InPoints, double start, double end,
 		  struct line_pnts *OutPoints)
 {
     int i, seg1, seg2;
@@ -545,11 +541,11 @@ Vect_line_segment(struct line_pnts *InPoints, double start, double end,
 
    For Lat-Long use Vect_line_geodesic_length() instead.
 
-   \param Points line
+   \param Points line geometry
 
    \return line length
  */
-double Vect_line_length(struct line_pnts *Points)
+double Vect_line_length(const struct line_pnts *Points)
 {
     int j;
     double dx, dy, dz, len = 0;
@@ -573,11 +569,11 @@ double Vect_line_length(struct line_pnts *Points)
 
    If projection is LL, the length is measured along the geodesic.
 
-   \param Points line
+   \param Points line geometry
 
    \return line length
  */
-double Vect_line_geodesic_length(struct line_pnts *Points)
+double Vect_line_geodesic_length(const struct line_pnts *Points)
 {
     int j, dc;
     double dx, dy, dz, dxy, len = 0;
@@ -606,7 +602,7 @@ double Vect_line_geodesic_length(struct line_pnts *Points)
 }
 
 /*!
-   \brief calculate line distance.
+   \brief Calculate line distance.
 
    Sets (if not null):
    - px, py - point on line,
@@ -625,7 +621,7 @@ double Vect_line_geodesic_length(struct line_pnts *Points)
    \return nearest segment (first is 1)
  */
 int
-Vect_line_distance(struct line_pnts *points,
+Vect_line_distance(const struct line_pnts *points,
 		   double ux, double uy, double uz,
 		   int with_z,
 		   double *px, double *py, double *pz,
@@ -765,7 +761,7 @@ double Vect_points_distance(double x1, double y1, double z1,	/* point 1 */
 
    \return 0
  */
-int Vect_line_box(struct line_pnts *Points, BOUND_BOX * Box)
+int Vect_line_box(const struct line_pnts *Points, BOUND_BOX * Box)
 {
     dig_line_box(Points, Box);
     return 0;
@@ -809,7 +805,7 @@ void Vect_line_reverse(struct line_pnts *Points)
    \return -1 no category
    \return category number (>=0)
  */
-int Vect_get_line_cat(struct Map_info *Map, int line, int field)
+int Vect_get_line_cat(const struct Map_info *Map, int line, int field)
 {
 
     static struct line_cats *cats = NULL;

+ 12 - 14
lib/vector/Vlib/list.c

@@ -1,21 +1,19 @@
 
-/**
+/*!
  * \file list.c
  *
  * \brief Vector library - list definition
  *
  * Higher level functions for reading/writing/manipulating vectors.
  *
- * (C) 2001-2008 by the GRASS Development Team
+ * (C) 2001-2009 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.
  *
  * \author Original author CERL, probably Dave Gerdes or Mike Higgins.
- * Update to GRASS 5.7 Radim Blazek and David D. Gray
- *
- * \date 2001-2008
+ * \author Update to GRASS 5.7 Radim Blazek and David D. Gray
  */
 
 #include <stdlib.h>
@@ -88,7 +86,7 @@ int Vect_destroy_list(struct ilist *list)
  * \brief Append new item to the end of list if not yet present 
  *
  * \param[in,out] list pointer to ilist structure
- * \param[in] val new item to append to the end of list
+ * \param val new item to append to the end of list
  *
  * \return 0 on success
  * \return 1 on error
@@ -122,12 +120,12 @@ int Vect_list_append(struct ilist *list, int val)
  * \brief Append new items to the end of list if not yet present 
  *
  * \param[in,out] alist pointer to ilist structure where items will be appended
- * \param[in] blist pointer to ilist structure with new items
+ * \param blist pointer to ilist structure with new items
  *
  * \return 0 on success
  * \return 1 on error
  */
-int Vect_list_append_list(struct ilist *alist, struct ilist *blist)
+int Vect_list_append_list(struct ilist *alist, const struct ilist *blist)
 {
     int i;
 
@@ -144,7 +142,7 @@ int Vect_list_append_list(struct ilist *alist, struct ilist *blist)
  * \brief Remove a given value (item) from list
  *
  * \param[in,out] list pointer to ilist structure
- * \param[in] val to remove
+ * \param val to remove
  *
  * \return 0 on success
  * \return 1 on error
@@ -173,12 +171,12 @@ int Vect_list_delete(struct ilist *list, int val)
  * \brief Delete list from existing list 
  *
  * \param[in,out] alist pointer to original ilist structure,
- * \param[in] blist pointer to ilist structure with items to delete
+ * \param blist pointer to ilist structure with items to delete
  *
  * \return 0 on success
  * \return 1 on error
  */
-int Vect_list_delete_list(struct ilist *alist, struct ilist *blist)
+int Vect_list_delete_list(struct ilist *alist, const struct ilist *blist)
 {
     int i;
 
@@ -194,13 +192,13 @@ int Vect_list_delete_list(struct ilist *alist, struct ilist *blist)
 /**
  * \brief Find a given item in the list
  *
- * \param[in] list pointer to ilist structure
- * \param[in] val value of item
+ * \param list pointer to ilist structure
+ * \param val value of item
  *
  * \return 1 if an item is found
  * \return 0 no found item in the list
 */
-int Vect_val_in_list(struct ilist *list, int val)
+int Vect_val_in_list(const struct ilist *list, int val)
 {
     int i;
 

+ 32 - 34
lib/vector/Vlib/map.c

@@ -5,17 +5,14 @@
  *
  * Higher level functions for reading/writing/manipulating vectors.
  *
- * (C) 2001-2008 by the GRASS Development Team
+ * (C) 2001-2009 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.
+ * This program is free software under the GNU General Public License
+ * (>=v2).  Read the file COPYING that comes with GRASS for details.
  *
  * \author Original author CERL, probably Dave Gerdes or Mike
- * Higgins. Update to GRASS 5.7 Radim Blazek and David D. Gray.
- *
- * \date 2001-2008
+ * Higgins.
+ * \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 
 #include <stdlib.h>
@@ -35,7 +32,7 @@
 /*!
    \brief Copy all alive elements of opened vector map to another opened vector map
 
-   \param[in] In input vector map
+   \param In input vector map
    \param[out] Out output vector map
 
    \return 0 on success
@@ -101,7 +98,7 @@ int Vect_copy_map_lines(struct Map_info *In, struct Map_info *Out)
 /*
    \brief Copy file
 
-   \param[in] src source file
+   \param src source file
    \param[out] dst destination file
 
    \return 0 OK
@@ -145,9 +142,9 @@ static int copy_file(const char *src, const char *dst)
 
    Old vector is deleted
 
-   \param[in] in input vector map name
-   \param[in] mapset mapset name
-   \param[in] out output vector map name
+   \param in input vector map name
+   \param mapset mapset name
+   \param out output vector map name
 
    \return -1 error
    \return 0 success
@@ -297,8 +294,8 @@ Vect_copy(const char *in, const char *mapset, const char *out)
    The original format (native/OGR) is used.
    Old map ('out') is deleted!!!
 
-   \param[in] in input vector map name
-   \param[in] out output vector map name
+   \param in input vector map name
+   \param out output vector map name
 
    \return -1 error
    \return 0 success
@@ -432,7 +429,7 @@ int Vect_rename(const char *in, const char *out)
 /*!
    \brief Delete vector map including attribute tables
 
-   \param[in] map vector map name
+   \param map vector map name
 
    \return -1 error
    \return 0 success
@@ -575,14 +572,14 @@ int Vect_delete(const char *map)
    Notice, that if input map has no tables defined, it will copy
    nothing and return 0 (success).
 
-   \param[in] In input vector map
+   \param In input vector map
    \param[out] Out output vector map
-   \param[in] field layer number
+   \param field layer number
 
    \return 0 on success
    \return -1 on error
  */
-int Vect_copy_tables(struct Map_info *In, struct Map_info *Out, int field)
+int Vect_copy_tables(const struct Map_info *In, struct Map_info *Out, int field)
 {
     int i, n, ret, type;
     struct field_info *Fi, *Fin;
@@ -650,18 +647,18 @@ int Vect_copy_tables(struct Map_info *In, struct Map_info *Out, int field)
 /*!
    \brief Copy table linked to vector map based on type.
 
-   \param[in] In input vector map
+   \param In input vector map
    \param[out] Out output vector map
-   \param[in] field_in input layer number
-   \param[in] field_out output layer number
-   \param[in] field_name layer name
-   \param[in] type feature type
+   \param field_in input layer number
+   \param field_out output layer number
+   \param field_name layer name
+   \param type feature type
 
    \return 0 on success
    \return -1 on error
  */
 int
-Vect_copy_table(struct Map_info *In, struct Map_info *Out, int field_in,
+Vect_copy_table(const struct Map_info *In, struct Map_info *Out, int field_in,
 		int field_out, const char *field_name, int type)
 {
     return Vect_copy_table_by_cats(In, Out, field_in, field_out, field_name,
@@ -671,20 +668,20 @@ Vect_copy_table(struct Map_info *In, struct Map_info *Out, int field_in,
 /*!
    \brief Copy table linked to vector map based on category numbers.
 
-   \param[in] In input vector map
+   \param In input vector map
    \param[out] Out output vector map
-   \param[in] field_in input layer number
-   \param[in] field_out output layer number
-   \param[in] field_name layer name
-   \param[in] type feature type
-   \param[in] cats pointer to array of cats or NULL
-   \param[in] ncats number of cats in 'cats'
+   \param field_in input layer number
+   \param field_out output layer number
+   \param field_name layer name
+   \param type feature type
+   \param cats pointer to array of cats or NULL
+   \param ncats number of cats in 'cats'
 
    \return 0 on success
    \return -1 on error
  */
 int
-Vect_copy_table_by_cats(struct Map_info *In, struct Map_info *Out,
+Vect_copy_table_by_cats(const struct Map_info *In, struct Map_info *Out,
 			int field_in, int field_out, const char *field_name,
 			int type, int *cats, int ncats)
 {
@@ -753,7 +750,8 @@ void Vect_set_release_support(struct Map_info *Map)
 }
 
 /*!
-   \brief By default, category index is not updated if vector is changed, this function sets category index update.
+   \brief By default, category index is not updated if vector is
+   changed, this function sets category index update.
 
    WARNING: currently only category for elements is updated 
    not for areas

+ 23 - 26
lib/vector/Vlib/net.c

@@ -5,16 +5,12 @@
  *
  * Higher level functions for reading/writing/manipulating vectors.
  *
- * (C) 2001-2008 by the GRASS Development Team
+ * (C) 2001-2009 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.
+ * This program is free software under the GNU General Public License
+ * (>=v2).  Read the file COPYING that comes with GRASS for details.
  *
  * \author Radim Blazek
- *
- * \date 2001-2008
  */
 
 #include<stdlib.h>
@@ -554,7 +550,7 @@ Vect_net_shortest_path(struct Map_info *Map, int from, int to,
    \return 0 does not exist (was not inserted)
  */
 int
-Vect_net_get_line_cost(struct Map_info *Map, int line, int direction,
+Vect_net_get_line_cost(const struct Map_info *Map, int line, int direction,
 		       double *cost)
 {
     /* dglInt32_t *pEdge; */
@@ -607,7 +603,7 @@ Vect_net_get_line_cost(struct Map_info *Map, int line, int direction,
 
    \return 1
  */
-int Vect_net_get_node_cost(struct Map_info *Map, int node, double *cost)
+int Vect_net_get_node_cost(const struct Map_info *Map, int node, double *cost)
 {
     G_debug(3, "Vect_net_get_node_cost(): node = %d", node);
 
@@ -625,14 +621,14 @@ int Vect_net_get_node_cost(struct Map_info *Map, int node, double *cost)
    \param x,y,z point coordinates (z coordinate NOT USED !)
    \param direction (GV_FORWARD - from point to net, GV_BACKWARD - from net to point)
    \param maxdist maximum distance to the network
-   \param node1 pointer where to store the node number (or NULL)
-   \param node2 pointer where to store the node number (or NULL)
-   \param ln    pointer where to store the nearest line number (or NULL)
-   \param costs1 pointer where to store costs on nearest line to node1 (not costs from x,y,z to the line) (or NULL)
-   \param costs2 pointer where to store costs on nearest line to node2 (not costs from x,y,z to the line) (or NULL)
-   \param Points1 pointer to structure where to store vertices on nearest line to node1 (or NULL)
-   \param Points2 pointer to structure where to store vertices on nearest line to node2 (or NULL)
-   \param pointer where to distance to the line (or NULL)
+   \param[out] node1 pointer where to store the node number (or NULL)
+   \param[out] node2 pointer where to store the node number (or NULL)
+   \param[out] ln    pointer where to store the nearest line number (or NULL)
+   \param[out] costs1 pointer where to store costs on nearest line to node1 (not costs from x,y,z to the line) (or NULL)
+   \param[out] costs2 pointer where to store costs on nearest line to node2 (not costs from x,y,z to the line) (or NULL)
+   \param[out] Points1 pointer to structure where to store vertices on nearest line to node1 (or NULL)
+   \param[out] Points2 pointer to structure where to store vertices on nearest line to node2 (or NULL)
+   \param[out] pointer where to distance to the line (or NULL)
 
    \return number of nodes found (0,1,2)
  */
@@ -844,15 +840,16 @@ int Vect_net_nearest_nodes(struct Map_info *Map,
    \param tx,ty,tz to point x coordinate (z ignored)
    \param fmax maximum distance to the network from 'from'
    \param tmax maximum distance to the network from 'to'
-   \param costs pointer where to store costs on the network (or NULL)
-   \param Points pointer to the structure where to store vertices of shortest path (or NULL)
-   \param List pointer to the structure where list of lines on the network is stored (or NULL)
-   \param FPoints pointer to the structure where to store line from 'from' to first network node (or NULL)
-   \param TPoints pointer to the structure where to store line from last network node to 'to' (or NULL)
-   \param fdist distance from 'from' to the net (or NULL)
-   \param tdist distance from 'to' to the net (or NULL)
-
-   \return 1 OK, 0 not reachable
+   \param[out] costs pointer where to store costs on the network (or NULL)
+   \param[out] Points pointer to the structure where to store vertices of shortest path (or NULL)
+   \param[out] List pointer to the structure where list of lines on the network is stored (or NULL)
+   \param[out] FPoints pointer to the structure where to store line from 'from' to first network node (or NULL)
+   \param[out] TPoints pointer to the structure where to store line from last network node to 'to' (or NULL)
+   \param[out] fdist distance from 'from' to the net (or NULL)
+   \param[out] tdist distance from 'to' to the net (or NULL)
+
+   \return 1 OK
+   \return 0 not reachable
  */
 int
 Vect_net_shortest_path_coor(struct Map_info *Map,

+ 31 - 31
lib/vector/Vlib/open.c

@@ -5,17 +5,14 @@
  *
  * Higher level functions for reading/writing/manipulating vectors.
  *
- * (C) 2001-2008 by the GRASS Development Team
+ * (C) 2001-2009 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.
+ * This program is free software under the GNU General Public License
+ * (>=v2).  Read the file COPYING that comes with GRASS for details.
  *
  * \author Original author CERL, probably Dave Gerdes or Mike
- * Higgins. Update to GRASS 5.7 Radim Blazek and David D. Gray.
- *
- * \date 2001-2008
+ * Higgins.
+ * \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 #include <grass/config.h>
 #include <stdlib.h>
@@ -88,7 +85,7 @@ static void fatal_error(int ferror, char *errmsg)
  * will be downward compatible and which your programs should 
  * support by default.
  *
- * \param[in] level vector (topo) level
+ * \param level vector (topo) level
  *
  * \return 0 on success
  * \return 1 on error
@@ -114,10 +111,10 @@ int Vect_set_open_level(int level)
  * In case of error, the functions respect fatal error settings.
  *
  * \param[out] Map vector map
- * \param[in] name name of vector map to open
- * \param[in] mapset mapset name
- * \param[in] update open for update
- * \param[in] head_only read only header info from 'head', 'dbln', 'topo', 'cidx' is not opened. The header may be opened on level 2 only. 
+ * \param name name of vector map to open
+ * \param mapset mapset name
+ * \param update open for update
+ * \param head_only read only header info from 'head', 'dbln', 'topo', 'cidx' is not opened. The header may be opened on level 2 only. 
  *
  * \return level of openness (1, 2)
  * \return -1 in error
@@ -408,8 +405,8 @@ Vect__open_old(struct Map_info *Map, const char *name, const char *mapset,
  * In case of error, the functions respect fatal error settings.
  *
  * \param[out] Map vector map
- * \param[in] name name of vector map
- * \param[in] mapset mapset name
+ * \param name name of vector map
+ * \param mapset mapset name
  *
  * \return level of openness [1, 2, (3)]
  * \return -1 on error
@@ -425,8 +422,8 @@ int Vect_open_old(struct Map_info *Map, const char *name, const char *mapset)
  * In case of error, the functions respect fatal error settings.
  *
  * \param[out] Map vector map
- * \param[in] name name of vector map to update
- * \param[in] mapset mapset name
+ * \param name name of vector map to update
+ * \param mapset mapset name
  *
  * \return level of openness [1, 2, (3)]
  * \return -1 on error
@@ -462,8 +459,8 @@ Vect_open_update(struct Map_info *Map, const char *name, const char *mapset)
  * In case of error, the functions respect fatal error settings.
  * 
  * \param[out] Map vector map
- * \param[in] name name of vector map to read
- * \param[in] mapset mapset name
+ * \param name name of vector map to read
+ * \param mapset mapset name
  *
  * \return level of openness [1, 2, (3)]
  * \return -1 on error
@@ -480,8 +477,8 @@ Vect_open_old_head(struct Map_info *Map, const char *name, const char *mapset)
  * In case of error, the functions respect fatal error settings.
  *
  * \param[out] Map vector map
- * \param[in] name name of vector map to update
- * \param[in] mapset mapset name
+ * \param name name of vector map to update
+ * \param mapset mapset name
  *
  * \return level of openness [1, 2, (3)]
  * \return -1 on error
@@ -512,8 +509,8 @@ Vect_open_update_head(struct Map_info *Map, const char *name,
  * \brief Open new vector for reading/writing
  *
  * \param[out] Map vector map
- * \param[in] name name of vector map
- * \param[in] with_z 2D/3D vector map
+ * \param name name of vector map
+ * \param with_z 2D/3D vector map
  *
  * \return 1 on success
  * \return -1 on error
@@ -606,13 +603,13 @@ int Vect_open_new(struct Map_info *Map, const char *name, int with_z)
 /*!
  * \brief Update Coor_info structure
  *
- * \param[in] Map vector map
+ * \param Map vector map
  * \param[out] Info Coor_info structure
  *
  * \return 1 on success
  * \return 0 on error
  */
-int Vect_coor_info(struct Map_info *Map, struct Coor_info *Info)
+int Vect_coor_info(const struct Map_info *Map, struct Coor_info *Info)
 {
     char buf[2000], path[2000];
     struct stat stat_buf;
@@ -646,7 +643,7 @@ int Vect_coor_info(struct Map_info *Map, struct Coor_info *Info)
 	Info->mtime = 0L;
 	break;
     }
-    G_debug(1, "Info->size = %ld, Info->mtime = %ld", Info->size,
+    G_debug(1, "Info->size = %lu, Info->mtime = %ld", (unsigned long) Info->size,
 	    Info->mtime);
 
     return 1;
@@ -655,12 +652,15 @@ int Vect_coor_info(struct Map_info *Map, struct Coor_info *Info)
 /*!
  * \brief Gets maptype (native, shape, postgis)
  *
- * \param[in] Map vector map
+ * Note: string is allocated by G_store(). Free allocated memory with
+ * G_free().
+ *
+ * \param Map vector map
  *
  * \return maptype string on success
  * \return error message on error
  */
-const char *Vect_maptype_info(struct Map_info *Map)
+const char *Vect_maptype_info(const struct Map_info *Map)
 {
     char maptype[1000];
 
@@ -684,7 +684,7 @@ const char *Vect_maptype_info(struct Map_info *Map)
  * \brief Open topo file
  *
  * \param[in,out] Map vector map
- * \param[in] head_only open only head
+ * \param head_only open only head
  *
  * \return 0 on success
  * \return 1 file does not exist
@@ -726,8 +726,8 @@ int Vect_open_topo(struct Map_info *Map, int head_only)
     if (dig_Rd_Plus_head(&fp, Plus) == -1)
 	return -1;
 
-    G_debug(1, "Topo head: coor size = %ld, coor mtime = %ld",
-	    Plus->coor_size, Plus->coor_mtime);
+    G_debug(1, "Topo head: coor size = %lu, coor mtime = %ld",
+	    (unsigned long) Plus->coor_size, Plus->coor_mtime);
 
     /* do checks */
     err = 0;

+ 9 - 13
lib/vector/Vlib/open_nat.c

@@ -5,17 +5,13 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 
 #include <grass/config.h>
@@ -58,7 +54,7 @@ int V1_open_old_nat(struct Map_info *Map, int update)
 	    G_fopen_old(buf, GRASS_VECT_COOR_ELEMENT, Map->mapset);
 
     if (Map->dig_fp.file == NULL) {
-        G_warning("Could not open coor file for vector map <%s>", Map->name);
+        G_warning(_("Unable to open coor file for vector map <%s>"), Map->name);
         return -1;
     }
 
@@ -78,13 +74,13 @@ int V1_open_old_nat(struct Map_info *Map, int update)
     if (!update)
 	dig_file_load(&(Map->dig_fp)); /* has currently no effect, file never loaded */
 
-    return (0);
+    return 0;
 }
 
 /**
    \brief Open/Create new vector map.
 
-   \param Map pointer to vector map
+   \param[out] Map pointer to vector map
    \param name map name
    \param with_z 2D or 3D (unused?)
 
@@ -147,8 +143,8 @@ int check_coor(struct Map_info *Map)
 
     Vect_coor_info(Map, &CInfo);
     dif = CInfo.size - Map->head.size;
-    G_debug(1, "coor size in head = %ld, real coor file size= %ld",
-	    Map->head.size, CInfo.size);
+    G_debug(1, "coor size in head = %lu, real coor file size= %lu",
+	    (unsigned long) Map->head.size, (unsigned long) CInfo.size);
 
     if (dif > 0) {
 	G_warning(_("Coor files of vector map <%s@%s> is larger than it should be "

+ 6 - 10
lib/vector/Vlib/open_ogr.c

@@ -5,17 +5,13 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 
 #include <unistd.h>
@@ -35,7 +31,7 @@
 
    Map->name and Map->mapset must be set before.
 
-   \param Map pointer to vector map
+   \param[out] Map pointer to vector map
    \param update non-zero for write mode, otherwise read-only
    (write mode is currently not supported)
 
@@ -106,7 +102,7 @@ int V1_open_old_ogr(struct Map_info *Map, int update)
 /**
    \brief Open OGR specific level 2 files (feature index)
 
-   \param Map pointer to vector map
+   \param[out] Map pointer to vector map
 
    \return 0 success
    \return -1 error

+ 24 - 17
lib/vector/Vlib/overlap.c

@@ -1,23 +1,30 @@
-/*
- ****************************************************************************
- *
- * MODULE:       Vector library 
- *              
- * AUTHOR(S):    Original author CERL, probably Dave Gerdes or Mike Higgins.
- *               Update to GRASS 5.7 Radim Blazek and David D. Gray.
- *
- * PURPOSE:      Higher level functions for reading/writing/manipulating vectors.
- *
- * COPYRIGHT:    (C) 2001 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.
- *
- *****************************************************************************/
+/*!
+   \file overlap.c
+
+   \brief Vector library - region/window overlap
+
+   Higher level functions for reading/writing/manipulating vectors.
+
+   (C) 2001-2009 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.
+
+   \author Original author CERL, probably Dave Gerdes or Mike Higgins.
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
+ */
 #include <grass/gis.h>
 #include <grass/Vect.h>
 
+/*!
+  Check if region overlaps with map extent.
+
+  \param Map vector map
+  \param n,s,e,w region bounding box
+
+  \return 1 if regions overlap
+  \return 0 if not
+*/
 int
 V__map_overlap(struct Map_info *Map, double n, double s, double e, double w)
 {

+ 6 - 9
lib/vector/Vlib/overlay.c

@@ -8,17 +8,13 @@
    This is file is just example and starting point for writing overlay
    functions!!!
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001
- */
+*/
 
 #include <string.h>
 #include <grass/Vect.h>
@@ -57,7 +53,7 @@ int Vect_overlay_str_to_operator(const char *str)
    \param BList unused ?
    \param BAList unused ?
    \param operator operator code
-   \param OMap output vector map
+   \param[out] OMap output vector map
 
    \return 0 on success
  */
@@ -94,6 +90,7 @@ int Vect_overlay(struct Map_info *AMap, int atype, struct ilist *AList, struct i
    \param BList unused ?
    \param BAList unused ?
    \param operator operator code
+   \param OMap output vector map
 
    \return 1 on success
    \return 0 on error

+ 20 - 24
lib/vector/Vlib/poly.c

@@ -5,17 +5,13 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 
 #include <math.h>
@@ -37,11 +33,10 @@ static int comp_double(double *, double *);
 static int V__within(double, double, double);
 int Vect__intersect_line_with_poly();
 static void destroy_links(struct Slink *);
-static int Vect__divide_and_conquer(struct Slink *, struct line_pnts *,
+static int Vect__divide_and_conquer(struct Slink *, const struct line_pnts *,
 				    struct link_head *, double *, double *,
 				    int);
 
-
 /*!
    \brief Get point inside area and outside all islands.
 
@@ -58,7 +53,7 @@ static int Vect__divide_and_conquer(struct Slink *, struct line_pnts *,
    \return -1 on error
  */
 int
-Vect_get_point_in_area(struct Map_info *Map, int area, double *X, double *Y)
+Vect_get_point_in_area(const struct Map_info *Map, int area, double *X, double *Y)
 {
     static struct line_pnts *Points;
     static struct line_pnts **IPoints;
@@ -92,7 +87,8 @@ Vect_get_point_in_area(struct Map_info *Map, int area, double *X, double *Y)
 				 IPoints[i]))
 	    return -1;
     }
-    return (Vect_get_point_in_poly_isl(Points, IPoints, n_isles, X, Y));
+    return (Vect_get_point_in_poly_isl((const struct line_pnts*) Points,
+				       (const struct line_pnts**) IPoints, n_isles, X, Y));
 
     return -1;
 }
@@ -133,7 +129,7 @@ static int V__within(double a, double x, double b)
    \return -1 on error 
  */
 int
-Vect__intersect_line_with_poly(struct line_pnts *Points,
+Vect__intersect_line_with_poly(const struct line_pnts *Points,
 			       double y, struct line_pnts *Inter)
 {
     int i;
@@ -172,7 +168,7 @@ Vect__intersect_line_with_poly(struct line_pnts *Points,
    \return 0 on success
    \return -1 on error
  */
-int Vect_get_point_in_poly(struct line_pnts *Points, double *X, double *Y)
+int Vect_get_point_in_poly(const struct line_pnts *Points, double *X, double *Y)
 {
     double cent_x, cent_y;
     struct Slink *Head;
@@ -260,7 +256,7 @@ int Vect_get_point_in_poly(struct line_pnts *Points, double *X, double *Y)
  */
 static int
 Vect__divide_and_conquer(struct Slink *Head,
-			 struct line_pnts *Points,
+			 const struct line_pnts *Points,
 			 struct link_head *Token,
 			 double *X, double *Y, int levels)
 {
@@ -322,7 +318,7 @@ static void destroy_links(struct Slink *Head)
    \return -1 on error
  */
 int
-Vect_find_poly_centroid(struct line_pnts *points,
+Vect_find_poly_centroid(const struct line_pnts *points,
 			double *cent_x, double *cent_y)
 {
     int i;
@@ -416,8 +412,8 @@ Vect_find_poly_centroid(struct line_pnts *points,
    \return -1 on error
  */
 int
-Vect_get_point_in_poly_isl(struct line_pnts *Points,
-			   struct line_pnts **IPoints, int n_isles,
+Vect_get_point_in_poly_isl(const struct line_pnts *Points,
+			   const struct line_pnts **IPoints, int n_isles,
 			   double *att_x, double *att_y)
 {
     static struct line_pnts *Intersects;
@@ -546,7 +542,7 @@ Vect_get_point_in_poly_isl(struct line_pnts *Points,
  * Returns: -1 point exactly on segment
  *          number of intersections
  */
-static int segments_x_ray(double X, double Y, struct line_pnts *Points)
+static int segments_x_ray(double X, double Y, const struct line_pnts *Points)
 {
     double x1, x2, y1, y2;
     double x_inter;
@@ -663,7 +659,7 @@ static int segments_x_ray(double X, double Y, struct line_pnts *Points)
    \return 1 - inside 
    \return 2 - on the boundary (exactly may be said only for vertex of vertical/horizontal line)
  */
-int Vect_point_in_poly(double X, double Y, struct line_pnts *Points)
+int Vect_point_in_poly(double X, double Y, const struct line_pnts *Points)
 {
     int n_intersects;
 
@@ -693,14 +689,14 @@ int Vect_point_in_poly(double X, double Y, struct line_pnts *Points)
    \return 2 - on the boundary (exactly may be said only for vertex of vertical/horizontal line)
  */
 int
-Vect_point_in_area_outer_ring(double X, double Y, struct Map_info *Map,
+Vect_point_in_area_outer_ring(double X, double Y, const struct Map_info *Map,
 			      int area)
 {
     static int first = 1;
     int n_intersects, inter;
     int i, line;
     static struct line_pnts *Points;
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_LINE *Line;
     P_AREA *Area;
 
@@ -758,13 +754,13 @@ Vect_point_in_area_outer_ring(double X, double Y, struct Map_info *Map,
    \return 1 - inside 
    \return 2 - on the boundary (exactly may be said only for vertex of vertical/horizontal line)
  */
-int Vect_point_in_island(double X, double Y, struct Map_info *Map, int isle)
+int Vect_point_in_island(double X, double Y, const struct Map_info *Map, int isle)
 {
     static int first = 1;
     int n_intersects, inter;
     int i, line;
     static struct line_pnts *Points;
-    struct Plus_head *Plus;
+    const struct Plus_head *Plus;
     P_LINE *Line;
     P_ISLE *Isle;
 

+ 8 - 10
lib/vector/Vlib/read.c

@@ -5,15 +5,13 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
    \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001-2008
  */
 
 #include <grass/config.h>
@@ -66,7 +64,7 @@ static int (*V2_read_line_array[]) () = {
    \return -1 out of memory
    \return -2 EOF   
  */
-int Vect_read_next_line(struct Map_info *Map,
+int Vect_read_next_line(const struct Map_info *Map,
 			struct line_pnts *line_p, struct line_cats *line_c)
 {
 
@@ -91,7 +89,7 @@ int Vect_read_next_line(struct Map_info *Map,
    \return -1 out of memory,
    \return -2 EOF   
  */
-int Vect_read_line(struct Map_info *Map,
+int Vect_read_line(const struct Map_info *Map,
 		   struct line_pnts *line_p, struct line_cats *line_c, int line)
 {
 
@@ -117,7 +115,7 @@ int Vect_read_line(struct Map_info *Map,
    \return 1 if feature alive
    \return 0 if feature is dead
  */
-int Vect_line_alive(struct Map_info *Map, int line)
+int Vect_line_alive(const struct Map_info *Map, int line)
 {
     if (Map->plus.Line[line] != NULL)
 	return 1;
@@ -134,7 +132,7 @@ int Vect_line_alive(struct Map_info *Map, int line)
    \return 1 if node alive
    \return 0 if node is dead
  */
-int Vect_node_alive(struct Map_info *Map, int node)
+int Vect_node_alive(const struct Map_info *Map, int node)
 {
     if (Map->plus.Node[node] != NULL)
 	return 1;
@@ -151,7 +149,7 @@ int Vect_node_alive(struct Map_info *Map, int node)
    \return 1 if area alive
    \return 0 if area is dead
  */
-int Vect_area_alive(struct Map_info *Map, int area)
+int Vect_area_alive(const struct Map_info *Map, int area)
 {
     if (Map->plus.Area[area] != NULL)
 	return 1;
@@ -168,7 +166,7 @@ int Vect_area_alive(struct Map_info *Map, int area)
    \return 1 if isle alive
    \return 0 if isle is dead
  */
-int Vect_isle_alive(struct Map_info *Map, int isle)
+int Vect_isle_alive(const struct Map_info *Map, int isle)
 {
     if (Map->plus.Isle[isle] != NULL)
 	return 1;
@@ -187,7 +185,7 @@ int Vect_isle_alive(struct Map_info *Map, int isle)
   \return feature offset
   \return -1 on error
 */
-off_t Vect_get_line_offset(const struct Map_info *Map, int line)
+off_t Vect_get_line_offset(const const struct Map_info *Map, int line)
 {
     if (line < 1 || line > Map->plus.n_lines)
 	return -1;

+ 16 - 20
lib/vector/Vlib/read_nat.c

@@ -10,17 +10,13 @@
    - Vect_read_constraint_type()
    - Vect_remove_constraints()
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  */
 
 #include <grass/config.h>
@@ -37,8 +33,8 @@ Vect__Read_line_nat(struct Map_info *,
  * \brief Read line from coor file on given offset.
  *
  * \param Map vector map 
- * \param Points container used to store line points within
- * \param Cats container used to store line categories within
+ * \param[out] Points container used to store line points within
+ * \param[out] Cats container used to store line categories within
  * \param offset given offset 
  *
  * \return line type
@@ -58,8 +54,8 @@ V1_read_line_nat(struct Map_info *Map,
  * \brief Read next line from coor file.
  *
  * \param Map vector map layer
- * \param line_p container used to store line points within
- * \param line_c container used to store line categories within
+ * \param[out] line_p container used to store line points within
+ * \param[out] line_c container used to store line categories within
  *
  * \return line type
  * \return 0 dead line
@@ -113,8 +109,8 @@ V1_read_next_line_nat(struct Map_info *Map,
  * \brief Reads any specified line, this is NOT affected by constraints
  *
  * \param Map vector map layer
- * \param line_p container used to store line points within
- * \param line_c container used to store line categories within
+ * \param[out] line_p container used to store line points within
+ * \param[out] line_c container used to store line categories within
  * \param line line id
  *
  * \return line type ( > 0 )
@@ -144,8 +140,8 @@ V2_read_line_nat(struct Map_info *Map,
  * \brief Reads next unread line each time called.  Use Vect_rewind to reset.
  *
  * \param Map vector map layer
- * \param line_p container used to store line points within
- * \param line_c container used to store line categories within
+ * \param[out] line_p container used to store line points within
+ * \param[out] line_c container used to store line categories within
  * 
  * \return line type ( > 0 )
  * \return 0 dead line
@@ -201,8 +197,8 @@ V2_read_next_line_nat(struct Map_info *Map,
  * \brief Read line from coor file 
  *
  * \param Map vector map layer
- * \param p container used to store line points within
- * \param c container used to store line categories within
+ * \param[out] p container used to store line points within
+ * \param[out] c container used to store line categories within
  * \param offset given offset
  *
  * \return line type ( > 0 )
@@ -222,7 +218,7 @@ Vect__Read_line_nat(struct Map_info *Map,
     char rhead, nc;
     short field;
 
-    G_debug(3, "Vect__Read_line_nat: offset = %ld", offset);
+    G_debug(3, "Vect__Read_line_nat: offset = %lu", (unsigned long) offset);
 
     Map->head.last_offset = offset;
 
@@ -335,7 +331,7 @@ Vect__Read_line_nat(struct Map_info *Map,
 	dig_fseek(&(Map->dig_fp), size, SEEK_CUR);
     }
 
-    G_debug(3, "    off = %ld", dig_ftell(&(Map->dig_fp)));
+    G_debug(3, "    off = %lu", (unsigned long) dig_ftell(&(Map->dig_fp)));
 
     if (dead)
 	return 0;

+ 12 - 16
lib/vector/Vlib/read_ogr.c

@@ -5,16 +5,12 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek, Piero Cavalieri
-
-   \date 2001
  */
 
 #include <grass/gis.h>
@@ -30,7 +26,7 @@
  * ftype : if > 0 use this type (because parts of Polygon are read as wkbLineString)
  *
  * \param Map vector map layer
- * \param hGeom OGR geometry
+ * \param[out] hGeom OGR geometry
  * \param ftype feature type
  * 
  * \return 0 OK
@@ -132,8 +128,8 @@ static int cache_feature(struct Map_info *Map, OGRGeometryH hGeom, int ftype)
  *   - Vect_remove_constraints()
  *
  * \param Map vector map layer
- * \param line_p container used to store line points within
- * \param line_c container used to store line categories within
+ * \param[out] line_p container used to store line points within
+ * \param[out] line_c container used to store line categories within
  *
  * \return  line type
  * \return  -2 no more features (EOF)
@@ -231,8 +227,8 @@ V1_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
  * \brief Read next line from OGR layer.
  *
  * \param Map vector map layer
- * \param line_p container used to store line points within
- * \param line_c container used to store line categories within
+ * \param[out] line_p container used to store line points within
+ * \param[out] line_c container used to store line categories within
  *
  * \return  line type
  * \return  -2 no more features (EOF)
@@ -254,12 +250,12 @@ V2_read_next_line_ogr(struct Map_info *Map, struct line_pnts *line_p,
  * \param Map vector map layer
  * \param hGeom OGR geometry
  * \param offset given offset
- * \param Points container used to store line pointes within
+ * \param[out] Points container used to store line pointes within
  *
  * \return 0 OK
  * \return 1 error
  */
-static int read_line(struct Map_info *Map, OGRGeometryH hGeom, long offset,
+static int read_line(const struct Map_info *Map, OGRGeometryH hGeom, long offset,
 		     struct line_pnts *Points)
 {
     int i, nPoints;
@@ -313,8 +309,8 @@ static int read_line(struct Map_info *Map, OGRGeometryH hGeom, long offset,
  * \brief Read line from layer on given offset.
  *
  * \param Map vector map layer
- * \param line_p container used to store line points within
- * \param line_c container used to store line categories within
+ * \param[out] line_p container used to store line points within
+ * \param[out] line_c container used to store line categories within
  * \param line line id
  *
  * \return line type

+ 7 - 12
lib/vector/Vlib/remove_areas.c

@@ -5,16 +5,12 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001
  */
 
 #include <stdlib.h>
@@ -25,13 +21,12 @@
 /*!
    \brief Remove small areas from the map map.
 
-   Centroid of the area and the longest boundary 
-   with adjacent area is removed.
-   Map topology must be built GV_BUILD_CENTROIDS.
+   Centroid of the area and the longest boundary with adjacent area is
+   removed.  Map topology must be built GV_BUILD_CENTROIDS.
 
-   \param Map vector map
+   \param[in,out] Map vector map
    \param thresh maximum area size for removed areas
-   \param Err vector map where removed lines and centroids are written
+   \param[out] Err vector map where removed lines and centroids are written
    \param removed_area  pointer to where total size of removed area is stored or NULL
 
    \return number of removed areas 

+ 9 - 12
lib/vector/Vlib/remove_duplicates.c

@@ -5,16 +5,12 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001
  */
 
 #include <stdlib.h>
@@ -23,14 +19,15 @@
 #include <grass/glocale.h>
 
 /*!
-   \brief Remove duplicate lines from vector map.
+   \brief Remove duplicate features from vector map.
 
-   Remove duplicate lines of given types from vector map. Duplicate lines may be optionally 
-   written to error map. Input map must be opened on level 2 for update. Categories are merged.
+   Remove duplicate lines of given types from vector map. Duplicate
+   lines may be optionally written to error map. Input map must be
+   opened on level 2 for update. Categories are merged.
 
-   \param Map vector map where duplicate lines will be deleted
+   \param[in,out] Map vector map where duplicate lines will be deleted
    \param type type of line to be delete
-   \param Err vector map where duplicate lines will be written or NULL
+   \param[out] Err vector map where duplicate lines will be written or NULL
 
    \return void
  */

+ 5 - 9
lib/vector/Vlib/rewind.c

@@ -5,18 +5,14 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
-   Update to GRASS 5.7 Radim Blazek and David D. Gray.
-
-   \date 2001
- */
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
+*/
 
 #include <grass/Vect.h>
 #include <grass/glocale.h>

+ 32 - 21
lib/vector/Vlib/rewind_nat.c

@@ -1,31 +1,42 @@
-/*
- ****************************************************************************
- *
- * MODULE:       Vector library 
- *              
- * AUTHOR(S):    Original author CERL, probably Dave Gerdes or Mike Higgins.
- *               Update to GRASS 5.7 Radim Blazek and David D. Gray.
- *
- * PURPOSE:      Higher level functions for reading/writing/manipulating vectors.
- *
- * COPYRIGHT:    (C) 2001 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.
- *
- *****************************************************************************/
+/*!
+   \file rewind.c
+
+   \brief Vector library - rewind data (native format)
+
+   Higher level functions for reading/writing/manipulating vectors.
+
+   (C) 2001-2009 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.
+
+   \author Original author CERL, probably Dave Gerdes or Mike Higgins.
+   \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
+*/
+
 #include <grass/Vect.h>
 
-/* Rewind vector data file to cause reads to start at beginning.
- ** returns 0 on success
- **        -1 on error
- */
+/*!
+  \brief Rewind vector data file to cause reads to start at beginning (level 1)
+
+  \param Map vector map
+
+  \return 0 on success
+  \return -1 on error
+*/
 int V1_rewind_nat(struct Map_info *Map)
 {
     return (dig_fseek(&(Map->dig_fp), Map->head.head_size, SEEK_SET));
 }
 
+/*!
+  \brief Rewind vector data file to cause reads to start at beginning (level 2)
+
+  \param Map vector map
+
+  \return 0 on success
+  \return -1 on error
+*/
 int V2_rewind_nat(struct Map_info *Map)
 {
     Map->next_line = 1;

+ 29 - 18
lib/vector/Vlib/rewind_ogr.c

@@ -1,28 +1,31 @@
+/*!
+   \file rewind.c
+
+   \brief Vector library - rewind data (native format)
+
+   Higher level functions for reading/writing/manipulating vectors.
+
+   (C) 2001-2009 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.
+
+   \author Radim Blazek, Piero Cavalieri 
+*/
 
-/****************************************************************************
-*
-* MODULE:       Vector library 
-*   	    	
-* AUTHOR(S):    Radim Blazek, Piero Cavalieri 
-*
-* PURPOSE:      Higher level functions for reading/writing/manipulating vectors.
-*
-* COPYRIGHT:    (C) 2001 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.
-*
-*****************************************************************************/
 #include <grass/gis.h>
 #include <grass/Vect.h>
 
 #ifdef HAVE_OGR
 #include <ogr_api.h>
 
-/* Rewind vector data file to cause reads to start at beginning. 
- ** returns 0 on success
- **        -1 on error
+/*!
+  \brief Rewind vector data file to cause reads to start at beginning (level 1)
+
+  \param Map vector map
+  
+  \return 0 on success
+  \return -1 on error
  */
 int V1_rewind_ogr(struct Map_info *Map)
 {
@@ -36,6 +39,14 @@ int V1_rewind_ogr(struct Map_info *Map)
     return 0;
 }
 
+/*!
+  \brief Rewind vector data file to cause reads to start at beginning (level 2)
+
+  \param Map vector map
+
+  \return 0 on success
+  \return -1 on error
+ */
 int V2_rewind_ogr(struct Map_info *Map)
 {
     G_debug(2, "V2_rewind_ogr(): name = %s", Map->name);

+ 10 - 15
lib/vector/Vlib/select.c

@@ -5,16 +5,12 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001
  */
 
 #include <stdlib.h>
@@ -24,8 +20,8 @@
 /*!
    \brief Select lines by box.
 
-   Select lines whose boxes overlap specified box!!!
-   It means that selected line may or may not overlap the box.
+   Select lines whose boxes overlap specified box!!!  It means that
+   selected line may or may not overlap the box.
 
    \param Map vector map
    \param Box bounding box
@@ -35,7 +31,7 @@
    \return number of lines
  */
 int
-Vect_select_lines_by_box(struct Map_info *Map, BOUND_BOX * Box,
+Vect_select_lines_by_box(struct Map_info *Map, const BOUND_BOX * Box,
 			 int type, struct ilist *list)
 {
     int i, line, nlines;
@@ -89,7 +85,7 @@ Vect_select_lines_by_box(struct Map_info *Map, BOUND_BOX * Box,
    \return number of areas
  */
 int
-Vect_select_areas_by_box(struct Map_info *Map, BOUND_BOX * Box,
+Vect_select_areas_by_box(struct Map_info *Map, const BOUND_BOX * Box,
 			 struct ilist *list)
 {
     int i;
@@ -140,7 +136,7 @@ Vect_select_areas_by_box(struct Map_info *Map, BOUND_BOX * Box,
    \return number of isles
  */
 int
-Vect_select_isles_by_box(struct Map_info *Map, BOUND_BOX * Box,
+Vect_select_isles_by_box(struct Map_info *Map, const BOUND_BOX * Box,
 			 struct ilist *list)
 {
     G_debug(3, "Vect_select_isles_by_box()");
@@ -168,7 +164,7 @@ Vect_select_isles_by_box(struct Map_info *Map, BOUND_BOX * Box,
    \return number of nodes
  */
 int
-Vect_select_nodes_by_box(struct Map_info *Map, BOUND_BOX * Box,
+Vect_select_nodes_by_box(struct Map_info *Map, const BOUND_BOX * Box,
 			 struct ilist *list)
 {
     struct Plus_head *plus;
@@ -292,8 +288,7 @@ Vect_select_lines_by_polygon(struct Map_info *Map, struct line_pnts *Polygon,
    Polygons should be closed, i.e. first and last points must be identical.
 
    Warning : values in list may be duplicate!
-
-
+   
    \param Map vector map
    \param Polygon outer ring
    \param nisles number of islands or 0

+ 11 - 15
lib/vector/Vlib/sindex.c

@@ -5,16 +5,12 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001
  */
 
 #include <stdlib.h>
@@ -31,7 +27,7 @@
 
    \return void
  */
-void Vect_spatial_index_init(SPATIAL_INDEX * si)
+void Vect_spatial_index_init(SPATIAL_INDEX *si)
 {
     G_debug(1, "Vect_spatial_index_init()");
 
@@ -47,7 +43,7 @@ void Vect_spatial_index_init(SPATIAL_INDEX * si)
 
    \return void
  */
-void Vect_spatial_index_destroy(SPATIAL_INDEX * si)
+void Vect_spatial_index_destroy(SPATIAL_INDEX *si)
 {
     G_debug(1, "Vect_spatial_index_destroy()");
 
@@ -57,13 +53,13 @@ void Vect_spatial_index_destroy(SPATIAL_INDEX * si)
 /*!
    \brief Add a new item to spatial index
 
-   \param  si pointer to spatial index structure
+   \param[in,out] si pointer to spatial index structure
    \param id item identifier
    \param box pointer to item bounding box
 
    \return void
  */
-void Vect_spatial_index_add_item(SPATIAL_INDEX * si, int id, BOUND_BOX * box)
+void Vect_spatial_index_add_item(SPATIAL_INDEX *si, int id, const BOUND_BOX *box)
 {
     struct Rect rect;
 
@@ -81,7 +77,7 @@ void Vect_spatial_index_add_item(SPATIAL_INDEX * si, int id, BOUND_BOX * box)
 /*!
    \brief Delete item from spatial index
 
-   \param  si pointer to spatial index structure
+   \param[in,out] si pointer to spatial index structure
    \param id item identifier
 
    \return void
@@ -115,7 +111,7 @@ void Vect_spatial_index_del_item(SPATIAL_INDEX * si, int id)
    To be used in modules.
    Map must be opened on level 2.
 
-   \param Map pointer to vector map
+   \param[in,out] Map pointer to vector map
    \param out print progress here
 
    \return 0 OK
@@ -245,14 +241,14 @@ static int _add_item(int id, struct ilist *list)
 /*!
    \brief Select items by bounding box to list
 
-   \param  si pointer to spatial index structure
+   \param si pointer to spatial index structure
    \param box bounding box
    \param list pointer to list where selected items are stored
 
    \return number of selected items
  */
 int
-Vect_spatial_index_select(SPATIAL_INDEX * si, BOUND_BOX * box,
+Vect_spatial_index_select(const SPATIAL_INDEX * si, const BOUND_BOX * box,
 			  struct ilist *list)
 {
     struct Rect rect;

+ 25 - 28
lib/vector/Vlib/snap.c

@@ -7,15 +7,11 @@
  *
  * (C) 2001-2009 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.
+ * This program is free software under the GNU General Public License
+ * (>=v2).  Read the file COPYING that comes with GRASS for details.
  *
  * \author Radim Blazek
- *         update to GRASS 7 Markus Metz
- *
- * \date 2009
+ * \author update to GRASS 7 Markus Metz
  */
 
 #include <stdlib.h>
@@ -79,24 +75,17 @@ int compare_snappnts(const void *Xpnta, const void *Xpntb)
 }
 
 /*!
- * \brief Snap selected lines to existing vertex in threshold.
- *
- * Snap selected lines to existing vertices.
- * 
- * \warning Lines are not necessarily snapped to nearest vertex, but to vertex in threshold! 
- *
- * Lines showing how vertices were snapped may be optionally written to error map. 
- * Input map must be opened on level 2 for update at least on GV_BUILD_BASE.
- *
- * \param[in] Map input map where vertices will be snapped
- * \param[in] List_lines list of lines to snap
- * \param[in] thresh threshold in which snap vertices
- * \param[out] Err vector map where lines representing snap are written or NULL
- *
- * \return void
- */
-
-/* As mentioned above, lines are not necessarily snapped to nearest vertex! For example:
+  \brief Snap selected lines to existing vertex in threshold.
+  
+  Snap selected lines to existing vertices.
+  
+  \warning Lines are not necessarily snapped to nearest vertex, but to vertex in threshold! 
+  
+  Lines showing how vertices were snapped may be optionally written to error map. 
+  Input map must be opened on level 2 for update at least on GV_BUILD_BASE.
+  
+  As mentioned above, lines are not necessarily snapped to nearest vertex! For example:
+  <pre>
    |                    
    | 1         line 3 is snapped to line 1,
    |           then line 2 is not snapped to common node at lines 1 and 3,
@@ -106,16 +95,24 @@ int compare_snappnts(const void *Xpnta, const void *Xpntb)
    |
    | 2
    |    
-
+   </pre>
+   
    The algorithm selects anchor vertices and snaps non-anchor vertices
    to these anchors.
    The distance between anchor vertices is always > threshold.
    If there is more than one anchor vertex within threshold around a
    non-anchor vertex, this vertex is snapped to the nearest anchor
    vertex within threshold.
- */
+
+   \param Map input map where vertices will be snapped
+   \param List_lines list of lines to snap
+   \param thresh threshold in which snap vertices
+   \param[out] Err vector map where lines representing snap are written or NULL
+   
+   \return void
+*/
 void
-Vect_snap_lines_list(struct Map_info *Map, struct ilist *List_lines,
+Vect_snap_lines_list(struct Map_info *Map, const struct ilist *List_lines,
 		     double thresh, struct Map_info *Err)
 {
     struct line_pnts *Points, *NPoints;

+ 3 - 7
lib/vector/Vlib/tin.c

@@ -5,16 +5,12 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001
  */
 
 #include <grass/Vect.h>

+ 4 - 8
lib/vector/Vlib/type.c

@@ -5,16 +5,12 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2). Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001
  */
 
 #include <grass/gis.h>
@@ -28,7 +24,7 @@
    \return types
    \return -1 on error
  */
-int Vect_option_to_types(struct Option *type_opt)
+int Vect_option_to_types(const struct Option *type_opt)
 {
     int i = 0;
     int type = 0;

+ 14 - 17
lib/vector/Vlib/window.c

@@ -1,20 +1,17 @@
-/*
- ****************************************************************************
- *
- * MODULE:       Vector library 
- *              
- * AUTHOR(S):    Original author CERL, probably Dave Gerdes or Mike Higgins.
- *               Update to GRASS 5.7 Radim Blazek and David D. Gray.
- *
- * PURPOSE:      Higher level functions for reading/writing/manipulating vectors.
- *
- * COPYRIGHT:    (C) 2001 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.
- *
- *****************************************************************************/
+/*!
+   \file window.c
+
+   \brief Vector library - window/region
+
+   Higher level functions for reading/writing/manipulating vectors.
+
+   (C) 2001-2009 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.
+
+   \author Radim Blazek
+ */
 #include <grass/Vect.h>
 
 /*

+ 6 - 9
lib/vector/Vlib/write.c

@@ -5,16 +5,13 @@
 
    Higher level functions for reading/writing/manipulating vectors.
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
+   This program is free software under the GNU General Public License
+   (>=v2). Read the file COPYING that comes with GRASS for details.
 
    \author Radim Blazek
-
-   \date 2001
+   \author Updated by Martin Landa <landa.martin gmail.com> (restore lines)
  */
 
 #include <grass/config.h>
@@ -126,7 +123,7 @@ static int (*Vect_restore_line_array[][3]) () = {
  */
 off_t
 Vect_write_line(struct Map_info *Map,
-		int type, struct line_pnts *points, struct line_cats *cats)
+		int type, const struct line_pnts *points, const struct line_cats *cats)
 {
     off_t offset;
 
@@ -174,7 +171,7 @@ Vect_write_line(struct Map_info *Map,
 int
 Vect_rewrite_line(struct Map_info *Map,
 		  int line,
-		  int type, struct line_pnts *points, struct line_cats *cats)
+		  int type, const struct line_pnts *points, const struct line_cats *cats)
 {
     long ret;
 

+ 15 - 17
lib/vector/Vlib/write_nat.c

@@ -11,7 +11,7 @@
     - Delete feature
     - Restore feature
 
-   (C) 2001-2008 by the GRASS Development Team
+   (C) 2001-2009 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.
@@ -19,8 +19,6 @@
    \author Original author CERL, probably Dave Gerdes or Mike Higgins.
    \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
    \author V*_restore_line() by Martin Landa <landa.martin gmail.com> (2008)
-
-   \date 2001
  */
 
 #include <grass/config.h>
@@ -131,7 +129,7 @@ static void add_area_cats_to_cidx(struct Map_info *Map, int area)
     Note that 1) and 2) is done by the same code.
 */
 static void add_line_to_topo(struct Map_info *Map, int line,
-			     struct line_pnts *points, struct line_cats *cats)
+			     const struct line_pnts *points, const struct line_cats *cats)
 {
     int first, s, n, i;
     int type, node, next_line, area, side, sel_area, new_area[2];
@@ -299,8 +297,8 @@ static void add_line_to_topo(struct Map_info *Map, int line,
     return;
 }
 
-off_t V1__rewrite_line_nat(struct Map_info *Map, off_t offset, int type,
-			  struct line_pnts *points, struct line_cats *cats);
+static off_t V1__rewrite_line_nat(struct Map_info *Map, off_t offset, int type,
+				  const struct line_pnts *points, const struct line_cats *cats);
 
 /*!
   \brief Writes feature to 'coor' file
@@ -314,7 +312,7 @@ off_t V1__rewrite_line_nat(struct Map_info *Map, off_t offset, int type,
   \return -1 on error
 */
 off_t V1_write_line_nat(struct Map_info *Map,
-		       int type, struct line_pnts *points, struct line_cats *cats)
+		       int type, const struct line_pnts *points, const struct line_cats *cats)
 {
     off_t offset;
 
@@ -340,7 +338,7 @@ off_t V1_write_line_nat(struct Map_info *Map,
   \return -1 on error
 */
 off_t V2_write_line_nat(struct Map_info *Map,
-		       int type, struct line_pnts *points, struct line_cats *cats)
+			int type, const struct line_pnts *points, const struct line_cats *cats)
 {
     int line;
     off_t offset;
@@ -399,9 +397,9 @@ off_t V2_write_line_nat(struct Map_info *Map,
   \return -1 on error
 */
 off_t V1_rewrite_line_nat(struct Map_info *Map,
-			 off_t offset,
-			 int type,
-			 struct line_pnts *points, struct line_cats *cats)
+			  off_t offset,
+			  int type,
+			  const struct line_pnts *points, const struct line_cats *cats)
 {
     int old_type;
     struct line_pnts *old_points;
@@ -461,7 +459,7 @@ off_t V1_rewrite_line_nat(struct Map_info *Map,
 int V2_rewrite_line_nat(struct Map_info *Map,
 			int line,
 			int type,
-			struct line_pnts *points, struct line_cats *cats)
+			const struct line_pnts *points, const struct line_cats *cats)
 {
     /* TODO: this is just quick shortcut because we have already V2_delete_nat()
      *        and V2_write_nat() this function first deletes old line
@@ -487,9 +485,9 @@ int V2_rewrite_line_nat(struct Map_info *Map,
   \return -1 on error
 */
 off_t V1__rewrite_line_nat(struct Map_info *Map,
-			  off_t offset,
-			  int type,
-			  struct line_pnts *points, struct line_cats *cats)
+			   off_t offset,
+			   int type,
+			   const struct line_pnts *points, const struct line_cats *cats)
 {
     int i, n_points;
     char rhead, nc;
@@ -588,7 +586,7 @@ int V1_delete_line_nat(struct Map_info *Map, off_t offset)
     char rhead;
     GVFILE *dig_fp;
 
-    G_debug(3, "V1_delete_line_nat(), offset = %ld", offset);
+    G_debug(3, "V1_delete_line_nat(), offset = %lu", (unsigned long) offset);
 
     dig_set_cur_port(&(Map->head.port));
     dig_fp = &(Map->dig_fp);
@@ -827,7 +825,7 @@ int V1_restore_line_nat(struct Map_info *Map, off_t offset)
     char rhead;
     GVFILE *dig_fp;
     
-    G_debug(3, "V1_restore_line_nat(), offset = %ld", offset);
+    G_debug(3, "V1_restore_line_nat(), offset = %lu", (unsigned long) offset);
     
     dig_set_cur_port(&(Map->head.port));
     dig_fp = &(Map->dig_fp);

+ 1 - 1
lib/vector/diglib/box.c

@@ -21,7 +21,7 @@
  *  dig_line_box ()
  *  set box to points extent
  */
-int dig_line_box(struct line_pnts *Points, BOUND_BOX * Box)
+int dig_line_box(const struct line_pnts *Points, BOUND_BOX * Box)
 {
     int i;
 

+ 2 - 2
lib/vector/diglib/plus_line.c

@@ -19,7 +19,7 @@
 #include <stdlib.h>
 #include <grass/Vect.h>
 
-static int add_line(struct Plus_head *plus, int lineid, int type, struct line_pnts *Points,
+static int add_line(struct Plus_head *plus, int lineid, int type, const struct line_pnts *Points,
 		    off_t offset)
 {
     int node, lp;
@@ -101,7 +101,7 @@ static int add_line(struct Plus_head *plus, int lineid, int type, struct line_pn
  * \return line id
  */
 int
-dig_add_line(struct Plus_head *plus, int type, struct line_pnts *Points,
+dig_add_line(struct Plus_head *plus, int type, const struct line_pnts *Points,
 	     off_t offset)
 {
     int ret;

+ 1 - 1
lib/vector/diglib/plus_node.c

@@ -40,7 +40,7 @@ static double dist_squared(double, double, double, double);
  */
 int
 dig_node_add_line(struct Plus_head *plus, int nodeid, int lineid,
-		  struct line_pnts *points, int type)
+		  const struct line_pnts *points, int type)
 {
     register int i, j, nlines;
     float angle;

+ 8 - 8
lib/vector/diglib/portable.c

@@ -460,7 +460,7 @@ int dig__fread_port_P(plus_t * buf, int cnt, GVFILE * fp)
 
 /***************************** WRITE ************************************/
 
-int dig__fwrite_port_D(double *buf,	/* DOUBLE */
+int dig__fwrite_port_D(const double *buf,	/* DOUBLE */
 		       int cnt, GVFILE * fp)
 {
     int i, j;
@@ -486,7 +486,7 @@ int dig__fwrite_port_D(double *buf,	/* DOUBLE */
     return 0;
 }
 
-int dig__fwrite_port_F(float *buf,	/* FLOAT */
+int dig__fwrite_port_F(const float *buf,	/* FLOAT */
 		       int cnt, GVFILE * fp)
 {
     int i, j;
@@ -512,7 +512,7 @@ int dig__fwrite_port_F(float *buf,	/* FLOAT */
     return 0;
 }
 
-int dig__fwrite_port_O(off_t *buf,	/* OFF_T */
+int dig__fwrite_port_O(const off_t *buf,	/* OFF_T */
 		       int cnt, GVFILE * fp, int port_off_t_size)
 {
     int i, j;
@@ -565,7 +565,7 @@ int dig__fwrite_port_O(off_t *buf,	/* OFF_T */
     return 0;
 }
 
-int dig__fwrite_port_L(long *buf,	/* LONG */
+int dig__fwrite_port_L(const long *buf,	/* LONG */
 		       int cnt, GVFILE * fp)
 {
     int i, j;
@@ -608,7 +608,7 @@ int dig__fwrite_port_L(long *buf,	/* LONG */
     return 0;
 }
 
-int dig__fwrite_port_I(int *buf,	/* INT */
+int dig__fwrite_port_I(const int *buf,	/* INT */
 		       int cnt, GVFILE * fp)
 {
     int i, j;
@@ -651,7 +651,7 @@ int dig__fwrite_port_I(int *buf,	/* INT */
     return 0;
 }
 
-int dig__fwrite_port_S(short *buf,	/* SHORT */
+int dig__fwrite_port_S(const short *buf,	/* SHORT */
 		       int cnt, GVFILE * fp)
 {
     int i, j;
@@ -695,13 +695,13 @@ int dig__fwrite_port_S(short *buf,	/* SHORT */
 }
 
 /* plus_t is defined as int so we only retype pointer and use int function */
-int dig__fwrite_port_P(plus_t * buf,	/* PLUS_T->INT */
+int dig__fwrite_port_P(const plus_t * buf,	/* PLUS_T->INT */
 		       int cnt, GVFILE * fp)
 {
     return (dig__fwrite_port_I((int *)buf, cnt, fp));
 }
 
-int dig__fwrite_port_C(char *buf,	/* CHAR */
+int dig__fwrite_port_C(const char *buf,	/* CHAR */
 		       int cnt, GVFILE * fp)
 {
     if (dig_fwrite(buf, PORT_CHAR, cnt, fp) == cnt)

+ 4 - 4
lib/vector/diglib/spindex.c

@@ -382,7 +382,7 @@ static int _add_item(int id, struct ilist *list)
    \return -1 on error
  */
 int
-dig_select_nodes(struct Plus_head *Plus, BOUND_BOX * box, struct ilist *list)
+dig_select_nodes(struct Plus_head *Plus, const BOUND_BOX * box, struct ilist *list)
 {
     struct Rect rect;
 
@@ -450,7 +450,7 @@ int dig_find_node(struct Plus_head *Plus, double x, double y, double z)
    \return number of selected lines
  */
 int
-dig_select_lines(struct Plus_head *Plus, BOUND_BOX * box, struct ilist *list)
+dig_select_lines(struct Plus_head *Plus, const BOUND_BOX * box, struct ilist *list)
 {
     struct Rect rect;
 
@@ -479,7 +479,7 @@ dig_select_lines(struct Plus_head *Plus, BOUND_BOX * box, struct ilist *list)
    \return number of selected areas
  */
 int
-dig_select_areas(struct Plus_head *Plus, BOUND_BOX * box, struct ilist *list)
+dig_select_areas(struct Plus_head *Plus, const BOUND_BOX * box, struct ilist *list)
 {
     struct Rect rect;
 
@@ -508,7 +508,7 @@ dig_select_areas(struct Plus_head *Plus, BOUND_BOX * box, struct ilist *list)
    \return number of selected isles
  */
 int
-dig_select_isles(struct Plus_head *Plus, BOUND_BOX * box, struct ilist *list)
+dig_select_isles(struct Plus_head *Plus, const BOUND_BOX * box, struct ilist *list)
 {
     struct Rect rect;
 

+ 0 - 9
vector/v.buffer2/local_proto.h

@@ -1,9 +0,0 @@
-#ifndef LOCAL_PROTO_H
-#define LOCAL_PROTO_H
-
-void Vect_line_buffer2(struct line_pnts *Points, double da, double db, double dalpha, int round, int caps, double tol, struct line_pnts **oPoints, struct line_pnts ***iPoints, int *inner_count);
-void Vect_area_buffer2(struct Map_info *Map, int area, double da, double db, double dalpha, int round, int caps, double tol, struct line_pnts **oPoints, struct line_pnts ***iPoints, int *inner_count);
-void Vect_point_buffer2(double px, double py, double da, double db, double dalpha, int round, double tol, struct line_pnts **oPoints);
-void Vect_line_parallel2(struct line_pnts *InPoints, double da, double db, double dalpha, int side, int round, double tol, struct line_pnts *OutPoints);
-
-#endif

+ 0 - 1
vector/v.buffer2/main.c

@@ -22,7 +22,6 @@
 #include <grass/Vect.h>
 #include <grass/dbmi.h>
 #include <grass/glocale.h>
-#include "local_proto.h"
 
 #define PI M_PI
 #ifndef MIN

+ 0 - 9
vector/v.parallel2/local_proto.h

@@ -1,9 +0,0 @@
-#ifndef LOCAL_PROTO_H
-#define LOCAL_PROTO_H
-
-void Vect_line_buffer2(struct line_pnts *Points, double da, double db, double dalpha, int round, int caps, double tol, struct line_pnts **oPoints, struct line_pnts ***iPoints, int *inner_count);
-void Vect_area_buffer2(struct Map_info *Map, int area, double da, double db, double dalpha, int round, int caps, double tol, struct line_pnts **oPoints, struct line_pnts ***iPoints, int *inner_count);
-void Vect_point_buffer2(double px, double py, double da, double db, double dalpha, int round, double tol, struct line_pnts **oPoints);
-void Vect_line_parallel2(struct line_pnts *InPoints, double da, double db, double dalpha, int side, int round, double tol, struct line_pnts *OutPoints);
-
-#endif

+ 0 - 1
vector/v.parallel2/main.c

@@ -21,7 +21,6 @@
 #include <grass/gis.h>
 #include <grass/Vect.h>
 #include <grass/glocale.h>
-#include "local_proto.h"
 
 int main(int argc, char *argv[])
 {