39 ndims = (
Plus->with_z != 0) ? 3 : 2;
40 Plus->spidx_with_z = (
Plus->with_z != 0);
42 G_debug(1,
"dig_spidx_init(), %d dims", ndims);
44 if (
Plus->Spidx_file) {
76 if (!
Plus->Spidx_new) {
93 Plus->Node_spidx_offset = 0L;
94 Plus->Line_spidx_offset = 0L;
95 Plus->Area_spidx_offset = 0L;
96 Plus->Isle_spidx_offset = 0L;
97 Plus->Face_spidx_offset = 0L;
98 Plus->Volume_spidx_offset = 0L;
99 Plus->Hole_spidx_offset = 0L;
115 ndims =
Plus->with_z ? 3 : 2;
118 if (
Plus->Node_spidx->fd > -1) {
129 if (!
Plus->Spidx_new)
148 ndims =
Plus->with_z ? 3 : 2;
151 if (
Plus->Line_spidx->fd > -1) {
162 if (!
Plus->Spidx_new)
181 ndims =
Plus->with_z ? 3 : 2;
184 if (
Plus->Area_spidx->fd > -1) {
195 if (!
Plus->Spidx_new)
214 ndims =
Plus->with_z ? 3 : 2;
217 if (
Plus->Isle_spidx->fd > -1) {
228 if (!
Plus->Spidx_new)
246 if (
Plus->Spidx_new) {
248 if (
Plus->Node_spidx->fd > -1)
251 if (
Plus->Spidx_new &&
Plus->Line_spidx->fd > -1)
254 if (
Plus->Area_spidx->fd > -1)
257 if (
Plus->Isle_spidx->fd > -1)
263 if (
Plus->Node_spidx)
266 if (
Plus->Line_spidx)
269 if (
Plus->Area_spidx)
272 if (
Plus->Isle_spidx)
303 G_debug(3,
"dig_spidx_add_node(): node = %d, x,y,z = %f, %f, %f", node,
x,
338 G_debug(3,
"dig_spidx_add_line(): line = %d", line);
372 G_debug(3,
"dig_spidx_add_area(): area = %d", area);
406 G_debug(3,
"dig_spidx_add_isle(): isle = %d",
isle);
442 G_debug(3,
"dig_spidx_del_node(): node = %d", node);
444 Node =
Plus->Node[node];
456 G_fatal_error(
_(
"Unable to delete node %d from spatial index"), node);
485 G_debug(3,
"dig_spidx_del_line(): line = %d", line);
499 G_fatal_error(
_(
"Unable to delete line %d from spatial index"), line);
530 G_debug(3,
"dig_spidx_del_area(): area = %d", area);
532 Area =
Plus->Area[area];
540 Node =
Plus->Node[topo->
N1];
552 G_fatal_error(
_(
"Unable to delete area %d from spatial index"), area);
583 G_debug(3,
"dig_spidx_del_isle(): isle = %d",
isle);
589 Node =
Plus->Node[topo->
N1];
617static int _add_item_with_box(
int id,
const struct RTree_Rect *rect,
640static int _set_item_box(
int id,
const struct RTree_Rect *rect,
680 G_debug(3,
"dig_select_nodes()");
698 return (
list->n_values);
702static int _add_node(
int id,
const struct RTree_Rect *rect
UNUSED,
int *node)
771 G_debug(3,
"dig_select_lines_with_box()");
789 return (
list->n_values);
810 G_debug(3,
"dig_find_line_box()");
818 Line =
Plus->Line[line];
828 Node =
Plus->Node[topo->
N1];
833 Node =
Plus->Node[topo->
N1];
860 G_fatal_error(
"Bug in vector lib: dig_find_line_box() may only be used for "
861 "lines and boundaries.");
887 G_debug(3,
"dig_select_areas_with_box()");
905 return (
list->n_values);
929 G_debug(3,
"dig_find_area_box()");
937 Area =
Plus->Area[area];
940 Node =
Plus->Node[topo->
N1];
983 G_debug(3,
"dig_select_areas_with_box()");
1001 return (
list->n_values);
1025 G_debug(3,
"dig_find_isle_box()");
1036 Node =
Plus->Node[topo->
N1];
1048 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 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.