vector.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. #ifndef GRASS_VECTORDEFS_H
  2. #define GRASS_VECTORDEFS_H
  3. /*
  4. * "Public" functions, for use in modules
  5. */
  6. /* Points (line) */
  7. struct line_pnts *Vect_new_line_struct(void);
  8. int Vect_append_point(struct line_pnts *, double, double, double);
  9. int Vect_append_points(struct line_pnts *, const struct line_pnts *, int);
  10. int Vect_line_insert_point(struct line_pnts *, int, double, double, double);
  11. int Vect_line_delete_point(struct line_pnts *, int);
  12. int Vect_line_get_point(const struct line_pnts *, int ,
  13. double *, double *, double *);
  14. int Vect_get_num_line_points(const struct line_pnts *);
  15. int Vect_line_prune(struct line_pnts *);
  16. int Vect_line_prune_thresh(struct line_pnts *, double);
  17. void Vect_line_reverse(struct line_pnts *);
  18. int Vect_copy_xyz_to_pnts(struct line_pnts *, const double *, const double *, const double *,
  19. int);
  20. int Vect_copy_pnts_to_xyz(const struct line_pnts *, double *, double *, double *,
  21. int *);
  22. void Vect_reset_line(struct line_pnts *);
  23. void Vect_destroy_line_struct(struct line_pnts *);
  24. int Vect_point_on_line(const struct line_pnts *, double, double *, double *,
  25. double *, double *, double *);
  26. int Vect_line_segment(const struct line_pnts *, double, double, struct line_pnts *);
  27. double Vect_line_length(const struct line_pnts *);
  28. double Vect_line_geodesic_length(const struct line_pnts *);
  29. int Vect_line_distance(const struct line_pnts *, double, double, double, int,
  30. double *, double *, double *, double *, double *,
  31. double *);
  32. int Vect_line_geodesic_distance(const struct line_pnts *, double, double, double, int,
  33. double *, double *, double *, double *, double *,
  34. double *);
  35. void Vect_line_box(const struct line_pnts *, struct bound_box *);
  36. void Vect_line_parallel(struct line_pnts *, double, double, int,
  37. struct line_pnts *);
  38. void Vect_line_parallel2(struct line_pnts *, double, double,
  39. double, int, int, double,
  40. struct line_pnts *);
  41. void Vect_line_buffer(const struct line_pnts *, double, double, struct line_pnts *);
  42. void Vect_line_buffer2(const struct line_pnts *, double, double,
  43. double, int, int, double,
  44. struct line_pnts **,
  45. struct line_pnts ***, int *);
  46. void Vect_area_buffer2(const struct Map_info *, int, double, double,
  47. double, int, int, double,
  48. struct line_pnts **,
  49. struct line_pnts ***, int *);
  50. void Vect_point_buffer2(double, double, double, double,
  51. double, int, double,
  52. struct line_pnts **);
  53. /* Categories */
  54. struct line_cats *Vect_new_cats_struct(void);
  55. int Vect_cat_set(struct line_cats *, int, int);
  56. int Vect_cat_get(const struct line_cats *, int, int *);
  57. int Vect_cat_del(struct line_cats *, int);
  58. int Vect_field_cat_del(struct line_cats *, int, int);
  59. int Vect_field_cat_get(const struct line_cats *, int, struct ilist *);
  60. int Vect_cat_in_array(int, const int *, int);
  61. int Vect_reset_cats(struct line_cats *);
  62. void Vect_destroy_cats_struct(struct line_cats *);
  63. int Vect_get_area_cats(const struct Map_info *, int, struct line_cats *);
  64. int Vect_get_area_cat(const struct Map_info *, int, int);
  65. int Vect_get_line_cat(const struct Map_info *, int, int);
  66. struct cat_list *Vect_cats_set_constraint(struct Map_info *, int, char *, char *);
  67. int Vect_cats_in_constraint(struct line_cats *, int, struct cat_list *);
  68. /* List of categories */
  69. struct cat_list *Vect_new_cat_list(void);
  70. int Vect_str_to_cat_list(const char *, struct cat_list *);
  71. int Vect_array_to_cat_list(const int *, int, struct cat_list *);
  72. int Vect_cat_in_cat_list(int, const struct cat_list *);
  73. void Vect_destroy_cat_list(struct cat_list *);
  74. /* Vector array */
  75. struct varray *Vect_new_varray(int);
  76. int Vect_set_varray_from_cat_string(const struct Map_info *, int, const char *, int,
  77. int, struct varray *);
  78. int Vect_set_varray_from_cat_list(const struct Map_info *, int, struct cat_list *,
  79. int, int, struct varray *);
  80. int Vect_set_varray_from_db(const struct Map_info *, int, const char *, int, int,
  81. struct varray *);
  82. /* DB connection - field info */
  83. struct dblinks *Vect_new_dblinks_struct(void);
  84. void Vect_reset_dblinks(struct dblinks *);
  85. int Vect_add_dblink(struct dblinks *, int, const char *,
  86. const char *, const char *, const char *, const char *);
  87. int Vect_check_dblink(const struct dblinks *, int, const char *);
  88. int Vect_map_add_dblink(struct Map_info *, int, const char *,
  89. const char *, const char *, const char *,
  90. const char *);
  91. int Vect_map_del_dblink(struct Map_info *, int);
  92. void Vect_copy_map_dblinks(const struct Map_info *, struct Map_info *, int);
  93. int Vect_map_check_dblink(const struct Map_info *, int, const char *);
  94. int Vect_read_dblinks(struct Map_info *);
  95. int Vect_write_dblinks(struct Map_info *);
  96. struct field_info *Vect_default_field_info(struct Map_info *, int,
  97. const char *, int);
  98. struct field_info *Vect_get_dblink(const struct Map_info *, int);
  99. struct field_info *Vect_get_field(const struct Map_info *, int);
  100. struct field_info *Vect_get_field_by_name(const struct Map_info *, const char *);
  101. struct field_info *Vect_get_field2(const struct Map_info *, const char *);
  102. int Vect_get_field_number(const struct Map_info *, const char *);
  103. void Vect_set_db_updated(struct Map_info *);
  104. const char *Vect_get_column_names(const struct Map_info *, int);
  105. const char *Vect_get_column_types(const struct Map_info *, int);
  106. const char *Vect_get_column_names_types(const struct Map_info *, int);
  107. /* List of FID (feature ID) (integers) */
  108. struct ilist *Vect_new_list(void);
  109. int Vect_list_append(struct ilist *, int);
  110. int Vect_list_append_list(struct ilist *, const struct ilist *);
  111. int Vect_list_delete(struct ilist *, int);
  112. int Vect_list_delete_list(struct ilist *, const struct ilist *);
  113. int Vect_val_in_list(const struct ilist *, int);
  114. int Vect_reset_list(struct ilist *);
  115. void Vect_destroy_list(struct ilist *);
  116. /* List of bounding boxes with ids */
  117. struct boxlist *Vect_new_boxlist(int);
  118. int Vect_boxlist_append(struct boxlist *, int, const struct bound_box *);
  119. int Vect_boxlist_append_boxlist(struct boxlist *, const struct boxlist *);
  120. int Vect_boxlist_delete(struct boxlist *, int);
  121. int Vect_boxlist_delete_boxlist(struct boxlist *, const struct boxlist *);
  122. int Vect_val_in_boxlist(const struct boxlist *, int);
  123. int Vect_reset_boxlist(struct boxlist *);
  124. void Vect_destroy_boxlist(struct boxlist *);
  125. /* Bounding box (MBR) */
  126. int Vect_point_in_box(double, double, double, const struct bound_box *);
  127. int Vect_box_overlap(const struct bound_box *, const struct bound_box *);
  128. int Vect_box_copy(struct bound_box *, const struct bound_box *);
  129. int Vect_box_extend(struct bound_box *, const struct bound_box *);
  130. int Vect_box_clip(double *, double *, double *, double *, const struct bound_box *);
  131. int Vect_region_box(const struct Cell_head *, struct bound_box *);
  132. /* Category index */
  133. int Vect_cidx_get_num_fields(const struct Map_info *);
  134. int Vect_cidx_get_field_number(const struct Map_info *, int);
  135. int Vect_cidx_get_field_index(const struct Map_info *, int);
  136. int Vect_cidx_get_num_unique_cats_by_index(const struct Map_info *, int);
  137. int Vect_cidx_get_num_cats_by_index(const struct Map_info *, int);
  138. int Vect_cidx_get_num_types_by_index(const struct Map_info *, int);
  139. int Vect_cidx_get_type_count_by_index(const struct Map_info *, int, int, int *,
  140. int *);
  141. int Vect_cidx_get_type_count(const struct Map_info *, int, int);
  142. int Vect_cidx_get_cat_by_index(const struct Map_info *, int, int, int *, int *,
  143. int *);
  144. int Vect_cidx_find_next(const struct Map_info *, int, int, int, int, int *, int *);
  145. void Vect_cidx_find_all(const struct Map_info *, int, int, int, struct ilist *);
  146. int Vect_cidx_dump(const struct Map_info *, FILE *);
  147. int Vect_cidx_save(struct Map_info *);
  148. int Vect_cidx_open(struct Map_info *, int);
  149. /* Set/get map header info */
  150. int Vect_read_header(struct Map_info *);
  151. int Vect_write_header(const struct Map_info *);
  152. const char *Vect_get_name(const struct Map_info *);
  153. const char *Vect_get_mapset(const struct Map_info *);
  154. const char *Vect_get_full_name(const struct Map_info *);
  155. const char *Vect_get_finfo_dsn_name(const struct Map_info *);
  156. char *Vect_get_finfo_layer_name(const struct Map_info *);
  157. const char *Vect_get_finfo_format_info(const struct Map_info *);
  158. const char *Vect_get_finfo_geometry_type(const struct Map_info *);
  159. const struct Format_info *Vect_get_finfo(const struct Map_info *);
  160. int Vect_is_3d(const struct Map_info *);
  161. int Vect_set_organization(struct Map_info *, const char *);
  162. const char *Vect_get_organization(const struct Map_info *);
  163. int Vect_set_date(struct Map_info *, const char *);
  164. const char *Vect_get_date(const struct Map_info *);
  165. int Vect_set_person(struct Map_info *, const char *);
  166. const char *Vect_get_person(const struct Map_info *);
  167. int Vect_set_map_name(struct Map_info *, const char *);
  168. const char *Vect_get_map_name(const struct Map_info *);
  169. int Vect_set_map_date(struct Map_info *, const char *);
  170. const char *Vect_get_map_date(const struct Map_info *);
  171. int Vect_set_comment(struct Map_info *, const char *);
  172. const char *Vect_get_comment(const struct Map_info *);
  173. int Vect_set_scale(struct Map_info *, int);
  174. int Vect_get_scale(const struct Map_info *);
  175. int Vect_set_zone(struct Map_info *, int);
  176. int Vect_get_zone(const struct Map_info *);
  177. int Vect_get_proj(const struct Map_info *);
  178. int Vect_set_proj(struct Map_info *, int);
  179. const char *Vect_get_proj_name(const struct Map_info *);
  180. int Vect_set_thresh(struct Map_info *, double);
  181. double Vect_get_thresh(const struct Map_info *);
  182. int Vect_get_constraint_box(const struct Map_info *, struct bound_box *);
  183. /* Get map level 2 information */
  184. int Vect_level(const struct Map_info *);
  185. int Vect_get_line_type(const struct Map_info *, int);
  186. plus_t Vect_get_num_nodes(const struct Map_info *);
  187. plus_t Vect_get_num_primitives(const struct Map_info *, int);
  188. plus_t Vect_get_num_lines(const struct Map_info *);
  189. plus_t Vect_get_num_areas(const struct Map_info *);
  190. plus_t Vect_get_num_faces(const struct Map_info *);
  191. plus_t Vect_get_num_kernels(const struct Map_info *);
  192. plus_t Vect_get_num_volumes(const struct Map_info *);
  193. plus_t Vect_get_num_islands(const struct Map_info *);
  194. plus_t Vect_get_num_holes(const struct Map_info *);
  195. int Vect_get_line_box(const struct Map_info *, int, struct bound_box *);
  196. int Vect_get_area_box(const struct Map_info *, int, struct bound_box *);
  197. int Vect_get_isle_box(const struct Map_info *, int, struct bound_box *);
  198. int Vect_get_map_box(const struct Map_info *, struct bound_box *);
  199. int V__map_overlap(struct Map_info *, double, double, double, double);
  200. void Vect_set_release_support(struct Map_info *);
  201. void Vect_set_category_index_update(struct Map_info *);
  202. /* Open/close/rewind/set_constraints for map */
  203. int Vect_check_input_output_name(const char *, const char *, int);
  204. int Vect_legal_filename(const char *);
  205. int Vect_set_open_level(int);
  206. int Vect_open_old(struct Map_info *, const char *, const char *);
  207. int Vect_open_old2(struct Map_info *, const char *, const char *, const char *);
  208. int Vect_open_old_head(struct Map_info *, const char *, const char *);
  209. int Vect_open_old_head2(struct Map_info *, const char *, const char *, const char *);
  210. int Vect_open_new(struct Map_info *, const char *, int);
  211. int Vect_open_tmp_new(struct Map_info *, const char *, int);
  212. int Vect_open_update(struct Map_info *, const char *, const char *);
  213. int Vect_open_update2(struct Map_info *, const char *, const char *, const char *);
  214. int Vect_open_update_head(struct Map_info *, const char *, const char *);
  215. int Vect_copy_head_data(const struct Map_info *, struct Map_info *);
  216. int Vect_build(struct Map_info *);
  217. int Vect_topo_check(struct Map_info *, struct Map_info *);
  218. int Vect_get_built(const struct Map_info *);
  219. int Vect_build_partial(struct Map_info *, int);
  220. int Vect_set_constraint_region(struct Map_info *, double, double, double,
  221. double, double, double);
  222. int Vect_set_constraint_type(struct Map_info *, int);
  223. int Vect_set_constraint_field(struct Map_info *, int);
  224. void Vect_remove_constraints(struct Map_info *);
  225. int Vect_rewind(struct Map_info *);
  226. int Vect_close(struct Map_info *);
  227. void Vect_set_error_handler_io(struct Map_info *, struct Map_info *);
  228. /* Read/write lines, nodes, areas */
  229. /* Level 1 and 2 */
  230. int Vect_get_next_line_id(const struct Map_info *);
  231. int Vect_read_next_line(const struct Map_info *, struct line_pnts *,
  232. struct line_cats *);
  233. off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *,
  234. const struct line_cats *);
  235. int Vect_get_num_dblinks(const struct Map_info *);
  236. /* Level 2 only */
  237. int Vect_read_line(const struct Map_info *, struct line_pnts *, struct line_cats *,
  238. int);
  239. off_t Vect_rewrite_line(struct Map_info *, int, int, const struct line_pnts *,
  240. const struct line_cats *);
  241. int Vect_delete_line(struct Map_info *, int);
  242. int Vect_restore_line(struct Map_info *, int, off_t);
  243. int Vect_line_alive(const struct Map_info *, int);
  244. int Vect_node_alive(const struct Map_info *, int);
  245. int Vect_area_alive(const struct Map_info *, int);
  246. int Vect_isle_alive(const struct Map_info *, int);
  247. int Vect_get_line_nodes(const struct Map_info *, int, int *, int *);
  248. int Vect_get_line_areas(const struct Map_info *, int, int *, int *);
  249. off_t Vect_get_line_offset(const struct Map_info *, int);
  250. int Vect_get_node_coor(const struct Map_info *, int, double *, double *, double *);
  251. int Vect_get_node_n_lines(const struct Map_info *, int);
  252. int Vect_get_node_line(const struct Map_info *, int, int);
  253. float Vect_get_node_line_angle(const struct Map_info *, int, int);
  254. double Vect_area_perimeter(const struct line_pnts *);
  255. int Vect_get_area_points(const struct Map_info *, int, struct line_pnts *);
  256. int Vect_get_area_centroid(const struct Map_info *, int);
  257. int Vect_get_area_num_isles(const struct Map_info *, int);
  258. int Vect_get_area_isle(const struct Map_info *, int, int);
  259. double Vect_get_area_area(const struct Map_info *, int);
  260. int Vect_get_area_boundaries(const struct Map_info *, int, struct ilist *);
  261. int Vect_get_isle_points(const struct Map_info *, int, struct line_pnts *);
  262. int Vect_get_isle_area(const struct Map_info *, int);
  263. int Vect_get_isle_boundaries(const struct Map_info *, int, struct ilist *);
  264. int Vect_get_centroid_area(const struct Map_info *, int);
  265. /* Level 2 update only */
  266. int Vect_get_num_updated_lines(const struct Map_info *);
  267. int Vect_get_updated_line(const struct Map_info *, int);
  268. off_t Vect_get_updated_line_offset(const struct Map_info *, int);
  269. int Vect_get_num_updated_nodes(const struct Map_info *);
  270. int Vect_get_updated_node(const struct Map_info *, int);
  271. void Vect_set_updated(struct Map_info *, int);
  272. void Vect_reset_updated(struct Map_info *);
  273. /* History */
  274. int Vect_hist_command(struct Map_info *);
  275. int Vect_hist_write(struct Map_info *, const char *);
  276. int Vect_hist_copy(const struct Map_info *, struct Map_info *);
  277. void Vect_hist_rewind(struct Map_info *);
  278. char *Vect_hist_read(char *, int, const struct Map_info *);
  279. /* Selecting features */
  280. int Vect_select_lines_by_box(struct Map_info *, const struct bound_box *,
  281. int, struct boxlist *);
  282. int Vect_select_areas_by_box(struct Map_info *, const struct bound_box *,
  283. struct boxlist *);
  284. int Vect_select_isles_by_box(struct Map_info *, const struct bound_box *,
  285. struct boxlist *);
  286. int Vect_select_nodes_by_box(struct Map_info *, const struct bound_box *,
  287. struct ilist *);
  288. int Vect_find_node(struct Map_info *, double, double, double, double, int);
  289. int Vect_find_line(struct Map_info *, double, double, double, int, double,
  290. int, int);
  291. int Vect_find_line_list(struct Map_info *, double, double, double, int,
  292. double, int, const struct ilist *, struct ilist *);
  293. int Vect_find_area(struct Map_info *, double, double);
  294. int Vect_find_island(struct Map_info *, double, double);
  295. int Vect_select_lines_by_polygon(struct Map_info *, struct line_pnts *, int,
  296. struct line_pnts **, int, struct ilist *);
  297. int Vect_select_areas_by_polygon(struct Map_info *, struct line_pnts *, int,
  298. struct line_pnts **, struct ilist *);
  299. /* Analysis */
  300. int Vect_tin_get_z(struct Map_info *, double, double, double *, double *,
  301. double *);
  302. /* int Vect_point_in_islands (struct Map_info *, int, double, double); */
  303. int Vect_find_poly_centroid(const struct line_pnts *, double *, double *);
  304. int Vect__intersect_line_with_poly(const struct line_pnts *, double,
  305. struct line_pnts *);
  306. int Vect_get_point_in_area(const struct Map_info *, int, double *, double *);
  307. int Vect_get_point_in_poly(const struct line_pnts *, double *, double *);
  308. int Vect_get_point_in_poly_isl(const struct line_pnts *, const struct line_pnts **, int,
  309. double *, double *);
  310. int Vect_point_in_area(double, double, const struct Map_info *, int, struct bound_box *);
  311. int Vect_point_in_area_outer_ring(double, double, const struct Map_info *, int, struct bound_box *);
  312. int Vect_point_in_island(double, double, const struct Map_info *, int, struct bound_box *);
  313. int Vect_point_in_poly(double, double, const struct line_pnts *);
  314. /* Cleaning */
  315. void Vect_break_lines(struct Map_info *, int, struct Map_info *);
  316. int Vect_break_lines_list(struct Map_info *, struct ilist *, struct ilist *,
  317. int, struct Map_info *);
  318. int Vect_check_line_breaks(struct Map_info *, int, struct Map_info *);
  319. int Vect_check_line_breaks_list(struct Map_info *, struct ilist *, struct ilist *,
  320. int, struct Map_info *);
  321. int Vect_merge_lines(struct Map_info *, int, int *, struct Map_info *);
  322. void Vect_break_polygons(struct Map_info *, int, struct Map_info *);
  323. void Vect_remove_duplicates(struct Map_info *, int, struct Map_info *);
  324. int Vect_line_check_duplicate(const struct line_pnts *,
  325. const struct line_pnts *, int);
  326. void Vect_snap_lines(struct Map_info *, int, double, struct Map_info *);
  327. void Vect_snap_lines_list(struct Map_info *, const struct ilist *, double,
  328. struct Map_info *);
  329. int Vect_snap_line(struct Map_info *, struct ilist *, struct line_pnts *,
  330. double, int, int *, int *);
  331. void Vect_remove_dangles(struct Map_info *, int, double, struct Map_info *);
  332. void Vect_chtype_dangles(struct Map_info *, double, struct Map_info *);
  333. void Vect_select_dangles(struct Map_info *, int, double, struct ilist *);
  334. void Vect_remove_bridges(struct Map_info *, struct Map_info *, int *, int *);
  335. void Vect_chtype_bridges(struct Map_info *, struct Map_info *, int *, int *);
  336. int Vect_remove_small_areas(struct Map_info *, double, struct Map_info *,
  337. double *);
  338. int Vect_clean_small_angles_at_nodes(struct Map_info *, int,
  339. struct Map_info *);
  340. /* Overlay */
  341. int Vect_overlay_str_to_operator(const char *);
  342. int Vect_overlay(struct Map_info *, int, struct ilist *, struct ilist *,
  343. struct Map_info *, int, struct ilist *, struct ilist *,
  344. int, struct Map_info *);
  345. int Vect_overlay_and(struct Map_info *, int, struct ilist *,
  346. struct ilist *, struct Map_info *, int,
  347. struct ilist *, struct ilist *, struct Map_info *);
  348. /* Graph */
  349. void Vect_graph_init(dglGraph_s *, int);
  350. void Vect_graph_build(dglGraph_s *);
  351. void Vect_graph_add_edge(dglGraph_s *, int, int, double, int);
  352. void Vect_graph_set_node_costs(dglGraph_s *, int, double);
  353. int Vect_graph_shortest_path(dglGraph_s *, int, int, struct ilist *, double *);
  354. /* Network (graph) */
  355. int Vect_net_build_graph(struct Map_info *, int, int, int, const char *,
  356. const char *, const char *, int, int);
  357. int Vect_net_shortest_path(struct Map_info *, int, int, struct ilist *,
  358. double *);
  359. dglGraph_s *Vect_net_get_graph(const struct Map_info *);
  360. int Vect_net_get_line_cost(const struct Map_info *, int, int, double *);
  361. int Vect_net_get_node_cost(const struct Map_info *, int, double *);
  362. int Vect_net_nearest_nodes(struct Map_info *, double, double, double, int,
  363. double, int *, int *, int *, double *, double *,
  364. struct line_pnts *, struct line_pnts *, double *);
  365. int Vect_net_shortest_path_coor(struct Map_info *, double, double, double,
  366. double, double, double, double, double,
  367. double *, struct line_pnts *, struct ilist *,
  368. struct line_pnts *, struct line_pnts *,
  369. double *, double *);
  370. int Vect_net_shortest_path_coor2(struct Map_info *, double, double, double,
  371. double, double, double, double, double,
  372. double *, struct line_pnts *, struct ilist *, struct ilist *,
  373. struct line_pnts *, struct line_pnts *,
  374. double *, double *);
  375. /* Miscellaneous */
  376. int Vect_topo_dump(const struct Map_info *, FILE *);
  377. double Vect_points_distance(double, double, double, double, double, double,
  378. int);
  379. int Vect_option_to_types(const struct Option *);
  380. int Vect_copy_map_lines(struct Map_info *, struct Map_info *);
  381. int Vect_copy_map_lines_field(struct Map_info *, int, struct Map_info *);
  382. int Vect_copy(const char *, const char *, const char *);
  383. int Vect_rename(const char *, const char *);
  384. int Vect_copy_table(const struct Map_info *, struct Map_info *, int, int,
  385. const char *, int);
  386. int Vect_copy_table_by_cats(const struct Map_info *, struct Map_info *, int, int,
  387. const char *, int, int *, int);
  388. int Vect_copy_tables(const struct Map_info *, struct Map_info *, int);
  389. int Vect_delete(const char *);
  390. int Vect_segment_intersection(double, double, double, double, double, double,
  391. double, double, double, double, double, double,
  392. double *, double *, double *, double *,
  393. double *, double *, int);
  394. int Vect_line_intersection(struct line_pnts *, struct line_pnts *,
  395. struct bound_box *, struct bound_box *,
  396. struct line_pnts ***, struct line_pnts ***, int *,
  397. int *, int);
  398. int Vect_line_check_intersection(struct line_pnts *, struct line_pnts *, int);
  399. int Vect_line_get_intersections(struct line_pnts *, struct line_pnts *,
  400. struct line_pnts *, int);
  401. char *Vect_subst_var(const char *, const struct Map_info *);
  402. /* Custom spatial index */
  403. void Vect_spatial_index_init(struct spatial_index *, int);
  404. void Vect_spatial_index_destroy(struct spatial_index *);
  405. void Vect_spatial_index_add_item(struct spatial_index *, int, const struct bound_box *);
  406. void Vect_spatial_index_del_item(struct spatial_index *, int, const struct bound_box *);
  407. int Vect_spatial_index_select(const struct spatial_index *, const struct bound_box *, struct ilist *);
  408. /* GRASS ASCII vector format */
  409. int Vect_read_ascii(FILE *, struct Map_info *);
  410. int Vect_read_ascii_head(FILE *, struct Map_info *);
  411. int Vect_write_ascii(FILE *, FILE *, struct Map_info *, int,
  412. int, int, char *, int, int,
  413. int, const struct cat_list *, const char*,
  414. const char **, int);
  415. void Vect_write_ascii_head(FILE *, struct Map_info *);
  416. /* Simple Features */
  417. SF_FeatureType Vect_sfa_get_line_type(const struct line_pnts *, int, int);
  418. int Vect_sfa_get_type(SF_FeatureType);
  419. int Vect_sfa_check_line_type(const struct line_pnts *, int, SF_FeatureType, int);
  420. int Vect_sfa_line_dimension(int);
  421. char *Vect_sfa_line_geometry_type(const struct line_pnts *, int);
  422. int Vect_sfa_line_astext(const struct line_pnts *, int, int, int, FILE *);
  423. int Vect_sfa_is_line_simple(const struct line_pnts *, int, int);
  424. int Vect_sfa_is_line_closed(const struct line_pnts *, int, int);
  425. /*
  426. * Internal functions, MUST NOT be used in modules
  427. */
  428. int Vect_print_header(const struct Map_info *);
  429. void Vect__init_head(struct Map_info *);
  430. /* Open/close/rewind map */
  431. int Vect_coor_info(const struct Map_info *, struct Coor_info *);
  432. const char *Vect_maptype_info(const struct Map_info *);
  433. int Vect_maptype(const struct Map_info *);
  434. int Vect_open_topo(struct Map_info *, int);
  435. int Vect_open_topo_pg(struct Map_info *, int);
  436. int Vect_save_topo(struct Map_info *);
  437. int Vect_open_sidx(struct Map_info *, int);
  438. int Vect_save_sidx(struct Map_info *);
  439. int Vect_sidx_dump(const struct Map_info *, FILE *);
  440. int Vect_build_sidx_from_topo(const struct Map_info *);
  441. int Vect_build_sidx(struct Map_info *);
  442. int Vect_open_fidx(struct Map_info *, struct Format_info_offset *);
  443. int Vect_save_fidx(struct Map_info *, struct Format_info_offset *);
  444. int Vect_fidx_dump(const struct Map_info *, FILE *);
  445. int Vect_save_frmt(struct Map_info *);
  446. int Vect__write_head(const struct Map_info *);
  447. int Vect__read_head(struct Map_info *);
  448. int V1_open_old_nat(struct Map_info *, int);
  449. int V1_open_old_ogr(struct Map_info *, int);
  450. int V1_open_old_pg(struct Map_info *, int);
  451. int V2_open_old_ogr(struct Map_info *);
  452. int V2_open_old_pg(struct Map_info *);
  453. int V1_open_new_nat(struct Map_info *, const char *, int);
  454. int V1_open_new_ogr(struct Map_info *, const char *, int);
  455. int V1_open_new_pg(struct Map_info *, const char *, int);
  456. int V1_rewind_nat(struct Map_info *);
  457. int V1_rewind_ogr(struct Map_info *);
  458. int V1_rewind_pg(struct Map_info *);
  459. int V2_rewind_nat(struct Map_info *);
  460. int V2_rewind_ogr(struct Map_info *);
  461. int V2_rewind_pg(struct Map_info *);
  462. int V1_close_nat(struct Map_info *);
  463. int V1_close_ogr(struct Map_info *);
  464. int V1_close_pg(struct Map_info *);
  465. int V2_close_ogr(struct Map_info *);
  466. int V2_close_pg(struct Map_info *);
  467. /* Read/write lines (internal use only) */
  468. int V1_read_line_nat(struct Map_info *, struct line_pnts *,
  469. struct line_cats *, off_t);
  470. int V1_read_line_ogr(struct Map_info *, struct line_pnts *,
  471. struct line_cats *, off_t);
  472. int V1_read_line_pg(struct Map_info *, struct line_pnts *,
  473. struct line_cats *, off_t);
  474. int V2_read_line_nat(struct Map_info *, struct line_pnts *,
  475. struct line_cats *, int);
  476. int V2_read_line_sfa(struct Map_info *, struct line_pnts *,
  477. struct line_cats *, int);
  478. int V2_read_line_pg(struct Map_info *, struct line_pnts *,
  479. struct line_cats *, int);
  480. int V1_read_next_line_nat(struct Map_info *, struct line_pnts *,
  481. struct line_cats *);
  482. int V1_read_next_line_ogr(struct Map_info *, struct line_pnts *,
  483. struct line_cats *);
  484. int V1_read_next_line_pg(struct Map_info *, struct line_pnts *,
  485. struct line_cats *);
  486. int V2_read_next_line_nat(struct Map_info *, struct line_pnts *,
  487. struct line_cats *);
  488. int V2_read_next_line_ogr(struct Map_info *, struct line_pnts *,
  489. struct line_cats *);
  490. int V2_read_next_line_pg(struct Map_info *, struct line_pnts *,
  491. struct line_cats *);
  492. int V1_delete_line_nat(struct Map_info *, off_t);
  493. int V1_delete_line_ogr(struct Map_info *, off_t);
  494. int V1_delete_line_pg(struct Map_info *, off_t);
  495. int V2_delete_line_nat(struct Map_info *, int);
  496. int V2_delete_line_sfa(struct Map_info *, int);
  497. int V2_delete_line_pg(struct Map_info *, int);
  498. int V1_restore_line_nat(struct Map_info *, off_t);
  499. int V2_restore_line_nat(struct Map_info *, int, off_t);
  500. off_t V1_write_line_nat(struct Map_info *, int, const struct line_pnts *,
  501. const struct line_cats *);
  502. off_t V1_write_line_ogr(struct Map_info *, int, const struct line_pnts *,
  503. const struct line_cats *);
  504. off_t V1_write_line_pg(struct Map_info *, int, const struct line_pnts *,
  505. const struct line_cats *);
  506. off_t V2_write_line_nat(struct Map_info *, int, const struct line_pnts *,
  507. const struct line_cats *);
  508. off_t V2_write_line_sfa(struct Map_info *, int, const struct line_pnts *,
  509. const struct line_cats *);
  510. off_t V2_write_line_pg(struct Map_info *, int, const struct line_pnts *,
  511. const struct line_cats *);
  512. off_t V1_rewrite_line_nat(struct Map_info *, int, int, off_t,
  513. const struct line_pnts *, const struct line_cats *);
  514. off_t V1_rewrite_line_ogr(struct Map_info *, int, int, off_t,
  515. const struct line_pnts *, const struct line_cats *);
  516. off_t V1_rewrite_line_pg(struct Map_info *, int, int, off_t,
  517. const struct line_pnts *, const struct line_cats *);
  518. off_t V2_rewrite_line_nat(struct Map_info *, int, int, off_t,
  519. const struct line_pnts *, const struct line_cats *);
  520. off_t V2_rewrite_line_sfa(struct Map_info *, int, int, off_t,
  521. const struct line_pnts *, const struct line_cats *);
  522. off_t V2_rewrite_line_pg(struct Map_info *, int, int, off_t,
  523. const struct line_pnts *, const struct line_cats *);
  524. /* Build topology */
  525. int Vect_build_nat(struct Map_info *, int);
  526. void Vect__build_downgrade(struct Map_info *, int);
  527. int Vect__build_sfa(struct Map_info *, int);
  528. int Vect_build_ogr(struct Map_info *, int);
  529. int Vect_build_pg(struct Map_info *, int);
  530. int Vect_build_line_area(struct Map_info *, int, int);
  531. int Vect_isle_find_area(struct Map_info *, int);
  532. int Vect_attach_isle(struct Map_info *, int);
  533. int Vect_attach_isles(struct Map_info *, const struct bound_box *);
  534. int Vect_attach_centroids(struct Map_info *, const struct bound_box *);
  535. /* GEOS support */
  536. #ifdef HAVE_GEOS
  537. GEOSGeometry *Vect_read_line_geos(struct Map_info *, int, int*);
  538. GEOSGeometry *Vect_line_to_geos(struct Map_info *, const struct line_pnts*, int);
  539. GEOSGeometry *Vect_read_area_geos(struct Map_info *, int);
  540. GEOSCoordSequence *Vect_get_area_points_geos(struct Map_info *, int);
  541. GEOSCoordSequence *Vect_get_isle_points_geos(struct Map_info *, int);
  542. #endif
  543. /* Raster color tables */
  544. int Vect_read_colors(const char *, const char *, struct Colors *);
  545. int Vect_remove_colors(const char *, const char *);
  546. void Vect_write_colors(const char *, const char *, struct Colors *);
  547. /* Simplified RTree search using an ilist to store rectangle ids */
  548. int RTreeSearch2(struct RTree *, struct RTree_Rect *, struct ilist *);
  549. #endif /* GRASS_VECTORDEFS_H */