37 ndims = (
Plus->with_z != 0) ? 3 : 2;
38 Plus->spidx_with_z = (
Plus->with_z != 0);
40 G_debug(1,
"dig_spidx_init(), %d dims", ndims);
42 if (
Plus->Spidx_file) {
74 if (!
Plus->Spidx_new) {
91 Plus->Node_spidx_offset = 0L;
92 Plus->Line_spidx_offset = 0L;
93 Plus->Area_spidx_offset = 0L;
94 Plus->Isle_spidx_offset = 0L;
95 Plus->Face_spidx_offset = 0L;
96 Plus->Volume_spidx_offset = 0L;
97 Plus->Hole_spidx_offset = 0L;
113 ndims =
Plus->with_z ? 3 : 2;
116 if (
Plus->Node_spidx->fd > -1) {
127 if (!
Plus->Spidx_new)
146 ndims =
Plus->with_z ? 3 : 2;
149 if (
Plus->Line_spidx->fd > -1) {
160 if (!
Plus->Spidx_new)
179 ndims =
Plus->with_z ? 3 : 2;
182 if (
Plus->Area_spidx->fd > -1) {
193 if (!
Plus->Spidx_new)
212 ndims =
Plus->with_z ? 3 : 2;
215 if (
Plus->Isle_spidx->fd > -1) {
226 if (!
Plus->Spidx_new)
244 if (
Plus->Spidx_new) {
246 if (
Plus->Node_spidx->fd > -1)
249 if (
Plus->Spidx_new &&
Plus->Line_spidx->fd > -1)
252 if (
Plus->Area_spidx->fd > -1)
255 if (
Plus->Isle_spidx->fd > -1)
261 if (
Plus->Node_spidx)
264 if (
Plus->Line_spidx)
267 if (
Plus->Area_spidx)
270 if (
Plus->Isle_spidx)
301 G_debug(3,
"dig_spidx_add_node(): node = %d, x,y,z = %f, %f, %f", node,
x,
336 G_debug(3,
"dig_spidx_add_line(): line = %d", line);
370 G_debug(3,
"dig_spidx_add_area(): area = %d", area);
404 G_debug(3,
"dig_spidx_add_isle(): isle = %d",
isle);
440 G_debug(3,
"dig_spidx_del_node(): node = %d", node);
442 Node =
Plus->Node[node];
454 G_fatal_error(
_(
"Unable to delete node %d from spatial index"), node);
483 G_debug(3,
"dig_spidx_del_line(): line = %d", line);
497 G_fatal_error(
_(
"Unable to delete line %d from spatial index"), line);
528 G_debug(3,
"dig_spidx_del_area(): area = %d", area);
530 Area =
Plus->Area[area];
538 Node =
Plus->Node[topo->
N1];
550 G_fatal_error(
_(
"Unable to delete area %d from spatial index"), area);
581 G_debug(3,
"dig_spidx_del_isle(): isle = %d",
isle);
587 Node =
Plus->Node[topo->
N1];
615static int _add_item_with_box(
int id,
const struct RTree_Rect *rect,
638static int _set_item_box(
int id,
const struct RTree_Rect *rect,
678 G_debug(3,
"dig_select_nodes()");
696 return (
list->n_values);
769 G_debug(3,
"dig_select_lines_with_box()");
787 return (
list->n_values);
808 G_debug(3,
"dig_find_line_box()");
816 Line =
Plus->Line[line];
826 Node =
Plus->Node[topo->
N1];
831 Node =
Plus->Node[topo->
N1];
858 G_fatal_error(
"Bug in vector lib: dig_find_line_box() may only be used for "
859 "lines and boundaries.");
885 G_debug(3,
"dig_select_areas_with_box()");
903 return (
list->n_values);
927 G_debug(3,
"dig_find_area_box()");
935 Area =
Plus->Area[area];
938 Node =
Plus->Node[topo->
N1];
981 G_debug(3,
"dig_select_areas_with_box()");
999 return (
list->n_values);
1023 G_debug(3,
"dig_find_isle_box()");
1034 Node =
Plus->Node[topo->
N1];
1046 if (
Plus->Spidx_new)
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
char * G_tempfile(void)
Returns a temporary file name.
void G_ilist_add(struct ilist *, int)
Add item to ilist.
int G_debug(int, const char *,...) __attribute__((format(printf
int rtree_search(struct RTree *, struct RTree_Rect *, SearchHitCallback, void *, struct Plus_head *)
Search spatial index file Can't use regular RTreeSearch() here because sidx must be read with dig__fr...
int dig_boxlist_add(struct boxlist *, int, const struct bound_box *)
Header file for msvc/fcntl.c.
#define G_UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
int SearchHitCallback(int id, const struct RTree_Rect *rect, void *arg)
int dig_select_isles(struct Plus_head *Plus, const struct bound_box *box, struct boxlist *list)
Select isles with boxes by box.
int dig_spidx_del_area(struct Plus_head *Plus, int area)
Delete area from spatial index.
void dig_spidx_free_areas(struct Plus_head *Plus)
Reset spatial index for areas.
int dig_spidx_add_line(struct Plus_head *Plus, int line, const struct bound_box *box)
Add new line to spatial index.
int dig_spidx_del_isle(struct Plus_head *Plus, int isle)
Delete isle from spatial index.
int dig_find_node(struct Plus_head *Plus, double x, double y, double z)
Find one node by coordinates.
int dig_find_isle_box(struct Plus_head *Plus, int isle, struct bound_box *box)
Find box for isle.
void dig_spidx_free_lines(struct Plus_head *Plus)
Free spatial index for lines.
int dig_select_areas(struct Plus_head *Plus, const struct bound_box *box, struct boxlist *list)
Select areas with boxes by box.
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_nodes(struct Plus_head *Plus, const struct bound_box *box, struct ilist *list)
Select nodes by bbox.
void dig_spidx_free_isles(struct Plus_head *Plus)
Reset spatial index for isles.
void dig_spidx_free_nodes(struct Plus_head *Plus)
Free spatial index for nodes.
int dig_spidx_add_area(struct Plus_head *Plus, int area, const struct bound_box *box)
Add new area to spatial index.
int dig_spidx_del_node(struct Plus_head *Plus, int node)
Delete node from spatial index.
int dig_spidx_del_line(struct Plus_head *Plus, int line, double x, double y, double z)
Delete line from spatial index.
int dig_find_line_box(struct Plus_head *Plus, int line, struct bound_box *box)
Find box for line.
void dig_spidx_free(struct Plus_head *Plus)
Free spatial index (nodes, lines, areas, isles)
int dig_spidx_init(struct Plus_head *Plus)
Initit spatial index (nodes, lines, areas, isles)
int dig_select_lines(struct Plus_head *Plus, const struct bound_box *box, struct boxlist *list)
Select lines with boxes by box.
int dig_find_area_box(struct Plus_head *Plus, int area, struct bound_box *box)
Find bounding box for given area.
int dig_spidx_add_isle(struct Plus_head *Plus, int isle, const struct bound_box *box)
Add new island to spatial index.
plus_t * lines
List of boundary lines.
plus_t * lines
List of boundary lines.
void * topo
Topology info.
Topological feature - node.
double z
Z coordinate (used only for 3D data)
Basic topology-related info.
List of bounding boxes with id.
int RTreeDeleteRect(struct RTree_Rect *r, int tid, struct RTree *t)
Delete an item from a R*-Tree.
struct RTree * RTreeCreateTree(int fd, off_t rootpos, int ndims)
Create new empty R*-Tree.
int RTreeInsertRect(struct RTree_Rect *r, int tid, struct RTree *t)
Insert an item into a R*-Tree.
void RTreeDestroyTree(struct RTree *t)
Destroy an R*-Tree.
int RTreeSearch(struct RTree *t, struct RTree_Rect *r, SearchHitCallback *shcb, void *cbarg)
Search an R*-Tree.