20 static int cmp_int(
const void *a,
const void *
b)
22 return (*(
int *)a - *(
int *)
b);
25 static int boxlist_add_sorted(
struct boxlist *
list,
int id)
29 if (
list->n_values > 0) {
30 if (bsearch(&
id,
list->id,
list->n_values,
sizeof(
int), cmp_int))
34 if (
list->n_values ==
list->alloc_values) {
35 size_t size = (
list->n_values + 100) *
sizeof(
int);
38 list->alloc_values =
list->n_values + 100;
42 if (
list->n_values > 0) {
43 for (i =
list->n_values; i > 0; i--) {
44 if (
list->id[i - 1] <
id)
74 int i, c, atype, aline, bline;
75 int nlines, nacats_orig, npoints;
76 int na1, na2, nb1, nb2, nodelines, nline;
89 G_debug(1,
"nlines = %d", nlines);
99 for (aline = 1; aline <= nlines; aline++) {
112 G_debug(3,
"Line %d pruned, %d vertices removed", aline,
126 for (i = 0; i < nodelines; i++) {
134 boxlist_add_sorted(List, nline);
139 ABox.
E = ABox.
W = APoints->
x[0];
140 ABox.
N = ABox.
S = APoints->
y[0];
141 ABox.
T = ABox.
B = APoints->
z[0];
148 for (i = 0; i < List->
n_values; i++) {
150 G_debug(3,
" j = %d bline = %d", i, bline);
160 if ((na1 == nb1 && na2 != nb2) || (na1 == nb2 && na2 != nb1))
181 nacats_orig = ACats->
n_cats;
183 for (c = 0; c < BCats->
n_cats; c++)
186 if (ACats->
n_cats > nacats_orig) {
187 G_debug(4,
"cats merged: n_cats %d -> %d", nacats_orig,
196 G_debug(3,
"nlines = %d\n", nlines);
220 const struct line_pnts *BPoints,
int with_z)
233 for (k = 0; k < APoints->
n_points; k++) {
234 if (APoints->
x[k] != BPoints->
x[k] || APoints->
y[k] != BPoints->
y[k] ||
235 (with_z && APoints->
z[k] != BPoints->
z[k])) {
243 for (k = 0; k < APoints->
n_points; k++) {
244 if (APoints->
x[k] != BPoints->
x[npoints - k - 1] ||
245 APoints->
y[k] != BPoints->
y[npoints - k - 1] ||
246 (with_z && APoints->
z[k] != BPoints->
z[npoints - k - 1])) {
void G_percent(long, long, int)
Print percent complete messages.
void void G_verbose_message(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
off_t Vect_rewrite_line(struct Map_info *, off_t, int, const struct line_pnts *, const struct line_cats *)
Rewrites existing feature (topological level required)
int Vect_reset_boxlist(struct boxlist *)
Reset boxlist structure.
int Vect_get_line_nodes(struct Map_info *, int, int *, int *)
Get line nodes.
plus_t Vect_get_num_lines(struct Map_info *)
Fetch number of features (points, lines, boundaries, centroids) in vector map.
int Vect_cat_set(struct line_cats *, int, int)
Add new field/cat to category structure if doesn't exist yet.
int Vect_get_line_type(struct Map_info *, int)
Get line type.
struct boxlist * Vect_new_boxlist(int)
Creates and initializes a struct boxlist.
void Vect_destroy_boxlist(struct boxlist *)
Frees all memory associated with a struct boxlist, including the struct itself.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int Vect_line_alive(struct Map_info *, int)
Check if feature is alive or dead (topological level required)
int Vect_delete_line(struct Map_info *, off_t)
Delete existing feature (topological level required)
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int Vect_select_lines_by_box(struct Map_info *, const struct bound_box *, int, struct boxlist *)
Select lines with bounding boxes by box.
int Vect_get_node_n_lines(struct Map_info *, int)
Get number of lines for node.
int Vect_get_node_line(struct Map_info *, int, int)
Get line id for node line index.
int Vect_line_prune(struct line_pnts *)
Remove duplicate points, i.e. zero length segments.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
int Vect_is_3d(struct Map_info *)
Check if vector map is 3D.
int Vect_line_check_duplicate(const struct line_pnts *APoints, const struct line_pnts *BPoints, int with_z)
Check for duplicate lines.
void Vect_remove_duplicates(struct Map_info *Map, int type, struct Map_info *Err)
Remove duplicate features from vector map.
List of bounding boxes with id.
int n_values
Number of items in the list.
int * field
Array of layers (fields)
int * cat
Array of categories.
int n_cats
Number of categories attached to element.
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
int n_points
Number of points.
double * z
Array of Z coordinates.