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)
30 if (bsearch(&
id, list->
id, list->
n_values,
sizeof(
int), cmp_int))
35 size_t size = (list->
n_values + 100) *
sizeof(
int);
43 for (i = list->
n_values; i > 0; i--) {
44 if (list->
id[i - 1] <
id)
46 list->
id[i] = list->
id[i - 1];
73 int i, c, atype, btype, aline, bline;
74 int nlines, nacats_orig, npoints;
75 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, npoints - APoints->
n_points);
125 for (i = 0; i < nodelines; i++) {
133 boxlist_add_sorted(List, nline);
138 ABox.
E = ABox.
W = APoints->
x[0];
139 ABox.
N = ABox.
S = APoints->
y[0];
140 ABox.
T = ABox.
B = APoints->
z[0];
147 for (i = 0; i < List->
n_values; i++) {
149 G_debug(3,
" j = %d bline = %d", i, bline);
157 if (atype & GV_LINES) {
159 if ((na1 == nb1 && na2 != nb2) ||
160 (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);
215 const struct line_pnts *BPoints,
int with_z)
228 for (k = 0; k < APoints->
n_points; k++) {
229 if (APoints->
x[k] != BPoints->
x[k] ||
230 APoints->
y[k] != BPoints->
y[k] ||
231 (with_z && APoints->
z[k] != BPoints->
z[k])) {
239 for (k = 0; k < APoints->
n_points; k++) {
240 if (APoints->
x[k] != BPoints->
x[npoints - k - 1] ||
241 APoints->
y[k] != BPoints->
y[npoints - k - 1] ||
242 (with_z && APoints->
z[k] != BPoints->
z[npoints - k - 1])) {
plus_t Vect_get_num_lines(const struct Map_info *)
Fetch number of features (points, lines, boundaries, centroids) in vector map.
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 n_points
Number of points.
int Vect_line_prune(struct line_pnts *)
Remove duplicate points, i.e. zero length segments.
int n_values
Number of items in the list.
int Vect_get_node_n_lines(const struct Map_info *, int)
Get number of lines for node.
double * x
Array of X coordinates.
int Vect_select_lines_by_box(struct Map_info *, const struct bound_box *, int, struct boxlist *)
Select lines with bounding boxes by box.
Feature geometry info - coordinates.
int Vect_get_node_line(const struct Map_info *, int, int)
Get line id for node line index.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int n_cats
Number of categories attached to element.
int * cat
Array of categories.
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
void Vect_remove_duplicates(struct Map_info *Map, int type, struct Map_info *Err)
Remove duplicate features from vector map.
int Vect_reset_boxlist(struct boxlist *)
Reset boxlist structure.
int Vect_get_line_nodes(const struct Map_info *, int, int *, int *)
Get line nodes.
void G_percent(long, long, int)
Print percent complete messages.
double * y
Array of Y coordinates.
int Vect_is_3d(const struct Map_info *)
Check if vector map is 3D.
int alloc_values
Allocated space for items.
int Vect_delete_line(struct Map_info *, off_t)
Delete existing feature (topological level required)
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
int Vect_line_check_duplicate(const struct line_pnts *APoints, const struct line_pnts *BPoints, int with_z)
Check for duplicate lines.
List of bounding boxes with id.
int Vect_line_alive(const struct Map_info *, int)
Check if feature is alive or dead (topological level required)
double * z
Array of Z coordinates.
int * field
Array of layers (fields)
struct boxlist * Vect_new_boxlist(int)
Creates and initializes a struct boxlist.
void void G_verbose_message(const char *,...) __attribute__((format(printf
int Vect_read_line(const struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int G_debug(int, const char *,...) __attribute__((format(printf
int Vect_get_line_type(const struct Map_info *, int)
Get line type.
int Vect_cat_set(struct line_cats *, int, int)
Add new field/cat to category structure if doesn't exist yet.