21 #include <grass/gis.h>
22 #include <grass/Vect.h>
39 int type,
struct ilist *list)
42 struct Plus_head *plus;
44 static struct ilist *LocList =
NULL;
46 G_debug(3,
"Vect_select_lines_by_box()");
47 G_debug(3,
" Box(N,S,E,W,T,B): %e, %e, %e, %e, %e, %e", Box->N, Box->S,
48 Box->E, Box->W, Box->T, Box->B);
51 if (!(plus->Spidx_built)) {
52 G_debug(3,
"Building spatial index.");
61 G_debug(3,
" %d lines selected (all types)", nlines);
64 for (i = 0; i < nlines; i++) {
65 line = LocList->value[i];
66 if (plus->Line[line] ==
NULL)
68 Line = plus->Line[line];
69 if (!(Line->type & type))
74 G_debug(3,
" %d lines of requested type", list->n_values);
76 return list->n_values;
102 debug_level = atoi(dstr);
106 G_debug(3,
"Vect_select_areas_by_box()");
107 G_debug(3,
"Box(N,S,E,W,T,B): %e, %e, %e, %e, %e, %e", Box->N, Box->S,
108 Box->E, Box->W, Box->T, Box->B);
110 if (!(Map->plus.Spidx_built)) {
111 G_debug(3,
"Building spatial index.");
116 G_debug(3,
" %d areas selected", list->n_values);
118 if (debug_level > 2) {
119 for (i = 0; i < list->n_values; i++) {
120 G_debug(3,
" area = %d pointer to area structure = %lx",
122 (
unsigned long)Map->plus.Area[list->value[i]]);
126 return list->n_values;
146 G_debug(3,
"Vect_select_isles_by_box()");
147 G_debug(3,
"Box(N,S,E,W,T,B): %e, %e, %e, %e, %e, %e", Box->N, Box->S,
148 Box->E, Box->W, Box->T, Box->B);
150 if (!(Map->plus.Spidx_built)) {
151 G_debug(3,
"Building spatial index.");
156 G_debug(3,
" %d isles selected", list->n_values);
158 return list->n_values;
174 struct Plus_head *plus;
176 G_debug(3,
"Vect_select_nodes_by_box()");
177 G_debug(3,
"Box(N,S,E,W,T,B): %e, %e, %e, %e, %e, %e", Box->N, Box->S,
178 Box->E, Box->W, Box->T, Box->B);
182 if (!(plus->Spidx_built)) {
183 G_debug(3,
"Building spatial index.");
190 G_debug(3,
" %d nodes selected", list->n_values);
192 return list->n_values;
211 int nisles,
struct line_pnts **Isles,
int type,
216 static struct line_pnts *LPoints =
NULL;
217 static struct ilist *LocList =
NULL;
220 G_debug(3,
"Vect_select_lines_by_polygon() nisles = %d", nisles);
230 box.T = PORT_DOUBLE_MAX;
231 box.B = -PORT_DOUBLE_MAX;
233 G_debug(3,
" %d lines selected by box", LocList->n_values);
236 for (i = 0; i < LocList->n_values; i++) {
237 int j, line, intersect = 0;
239 line = LocList->value[i];
244 for (j = 0; j < LPoints->n_points; j++) {
248 for (k = 0; k < nisles; k++) {
274 for (j = 0; j < nisles; j++) {
285 G_debug(4,
" %d lines selected by polygon", List->n_values);
287 return List->n_values;
309 int nisles,
struct line_pnts **Isles,
313 static struct ilist *BoundList =
NULL;
316 G_debug(3,
"Vect_select_areas_by_polygon() nisles = %d", nisles);
327 for (i = 0; i < BoundList->n_values; i++) {
328 int line, left, right;
330 line = BoundList->value[i];
333 G_debug(4,
"boundary = %d left = %d right = %d", line, left, right);
340 G_debug(4,
" left island -> area = %d", area);
348 else if (right < 0) {
350 G_debug(4,
" right island -> area = %d", area);
362 G_debug(3,
" %d areas selected by polygon", List->n_values);
364 return List->n_values;
int Vect_select_isles_by_box(struct Map_info *Map, BOUND_BOX *Box, struct ilist *list)
Select isles by box.
char * G__getenv(const char *name)
Get environment variable.
int Vect_get_isle_area(struct Map_info *Map, int isle)
Returns area for isle.
int dig_list_add(struct ilist *list, int val)
int Vect_select_nodes_by_box(struct Map_info *Map, BOUND_BOX *Box, struct ilist *list)
Select nodes by box.
int Vect_build_sidx_from_topo(struct Map_info *Map)
Create spatial index from topo if necessary.
int dig_line_box(struct line_pnts *Points, BOUND_BOX *Box)
int Vect_get_line_areas(struct Map_info *Map, int line, int *left, int *right)
Get area/isle ids on the left and right.
float Box[8][3]
Vertices for box.
struct line_pnts * Vect_new_line_struct()
Creates and initializes a struct line_pnts.
struct ilist * Vect_new_list(void)
Creates and initializes a struct ilist.
int Vect_line_check_intersection(struct line_pnts *APoints, struct line_pnts *BPoints, int with_z)
Check if 2 lines intersect.
int dig_select_isles(struct Plus_head *Plus, BOUND_BOX *box, struct ilist *list)
Select isles by box.
int Vect_find_area(struct Map_info *Map, double x, double y)
Find the nearest area.
int dig_select_areas(struct Plus_head *Plus, BOUND_BOX *box, struct ilist *list)
Select areas by box.
int dig_select_nodes(struct Plus_head *Plus, BOUND_BOX *box, struct ilist *list)
Select nodes by bbox.
int Vect_select_lines_by_polygon(struct Map_info *Map, struct line_pnts *Polygon, int nisles, struct line_pnts **Isles, int type, struct ilist *List)
Select lines by Polygon with optional isles.
int Vect_select_areas_by_polygon(struct Map_info *Map, struct line_pnts *Polygon, int nisles, struct line_pnts **Isles, struct ilist *List)
Select areas by Polygon with optional isles.
int dig_select_lines(struct Plus_head *Plus, BOUND_BOX *box, struct ilist *list)
Select lines by box.
int Vect_select_lines_by_box(struct Map_info *Map, BOUND_BOX *Box, int type, struct ilist *list)
Select lines by box.
int Vect_point_in_poly(double X, double Y, struct line_pnts *Points)
Determines if a point (X,Y) is inside a polygon.
int Vect_select_areas_by_box(struct Map_info *Map, BOUND_BOX *Box, struct ilist *list)
Select areas by box.
int G_debug(int level, const char *msg,...)
Print debugging message.
int Vect_read_line(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line)
Read vector feature.