19 #include <grass/gis.h>
20 #include <grass/Vect.h>
21 #include <grass/glocale.h>
41 Plus->Node_spidx_offset = 0L;
42 Plus->Edge_spidx_offset = 0L;
43 Plus->Line_spidx_offset = 0L;
44 Plus->Area_spidx_offset = 0L;
45 Plus->Isle_spidx_offset = 0L;
46 Plus->Volume_spidx_offset = 0L;
47 Plus->Hole_spidx_offset = 0L;
121 double x,
double y,
double z)
125 G_debug(3,
"dig_spidx_add_node(): node = %d, x,y,z = %f, %f, %f", node, x,
152 G_debug(3,
"dig_spidx_add_line(): line = %d", line);
178 G_debug(3,
"dig_spidx_add_area(): area = %d", area);
205 G_debug(3,
"dig_spidx_add_isle(): isle = %d", isle);
234 G_debug(3,
"dig_spidx_del_node(): node = %d", node);
236 Node = Plus->Node[node];
248 G_fatal_error(_(
"Unable to delete node %d from spatial index"), node);
269 G_debug(3,
"dig_spidx_del_line(): line = %d", line);
271 Line = Plus->Line[line];
273 G_debug(3,
" box(x1,y1,z1,x2,y2,z2): %f %f %f %f %f %f", Line->W,
274 Line->S, Line->B, Line->E, Line->N, Line->T);
288 G_fatal_error(_(
"Unable to delete line %d from spatial index"), line);
309 G_debug(3,
"dig_spidx_del_area(): area = %d", area);
311 Area = Plus->Area[area];
327 G_fatal_error(_(
"Unable to delete area %d from spatial index"), area);
348 G_debug(3,
"dig_spidx_del_isle(): isle = %d", isle);
350 Isle = Plus->Isle[isle];
362 G_fatal_error(_(
"Unable to delete isle %d from spatial index"), isle);
368 static int _add_item(
int id,
struct ilist *list)
389 G_debug(3,
"dig_select_nodes()");
399 RTreeSearch(Plus->Node_spidx, &rect, (
void *)_add_item, list);
401 return (list->n_values);
405 static int _add_node(
int id,
int *node)
438 RTreeSearch(Plus->Node_spidx, &rect, (
void *)_add_node, &node);
457 G_debug(3,
"dig_select_lines()");
467 RTreeSearch(Plus->Line_spidx, &rect, (
void *)_add_item, list);
469 return (list->n_values);
486 G_debug(3,
"dig_select_areas()");
496 RTreeSearch(Plus->Area_spidx, &rect, (
void *)_add_item, list);
498 return (list->n_values);
515 G_debug(3,
"dig_select_isles()");
525 RTreeSearch(Plus->Isle_spidx, &rect, (
void *)_add_item, list);
527 return (list->n_values);
RectReal boundary[NUMSIDES]
int dig_init_list(struct ilist *list)
void dig_spidx_free(struct Plus_head *Plus)
Free spatial index (nodes, lines, areas, isles)
int dig_list_add(struct ilist *list, int val)
int dig_spidx_add_line(struct Plus_head *Plus, int line, BOUND_BOX *box)
Add new line to spatial index.
int dig_spidx_del_node(struct Plus_head *Plus, int node)
Delete node from spatial index.
int RTreeSearch(struct Node *N, struct Rect *R, SearchHitCallback shcb, void *cbarg)
int dig_spidx_init(struct Plus_head *Plus)
Initit spatial index (nodes, lines, areas, isles)
void RTreeDestroyNode(struct Node *)
int RTreeInsertRect(struct Rect *R, int Tid, struct Node **Root, int Level)
int dig_select_isles(struct Plus_head *Plus, BOUND_BOX *box, struct ilist *list)
Select isles by box.
void dig_spidx_free_lines(struct Plus_head *Plus)
Free spatial index for lines.
void dig_spidx_free_areas(struct Plus_head *Plus)
Free spatial index for areas.
int dig_spidx_add_area(struct Plus_head *Plus, int area, BOUND_BOX *box)
Add new area to spatial index.
int dig_spidx_add_isle(struct Plus_head *Plus, int isle, BOUND_BOX *box)
Add new island to spatial index.
int dig_spidx_del_area(struct Plus_head *Plus, int area)
Delete area from spatial index.
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.
void dig_spidx_free_isles(struct Plus_head *Plus)
Free spatial index for isles.
int dig_spidx_del_isle(struct Plus_head *Plus, int isle)
Delete isle from spatial index.
int dig_spidx_add_node(struct Plus_head *Plus, int node, double x, double y, double z)
Add new node to spatial index.
int dig_select_lines(struct Plus_head *Plus, BOUND_BOX *box, struct ilist *list)
Select lines by box.
int G_debug(int level, const char *msg,...)
Print debugging message.
struct Node * RTreeNewIndex(void)
int dig_find_node(struct Plus_head *Plus, double x, double y, double z)
Find one node by coordinates.
int RTreeDeleteRect(struct Rect *R, int Tid, struct Node **Nn)
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
void dig_spidx_free_nodes(struct Plus_head *Plus)
Free spatial index for nodes.
int dig_spidx_del_line(struct Plus_head *Plus, int line)
Delete line from spatial index.