-
Notifications
You must be signed in to change notification settings - Fork 14
/
quadTree.h
52 lines (38 loc) · 1.14 KB
/
quadTree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef _CP_QUAD_TREE_H_
#define _CP_QUAD_TREE_H_
#define MAX_ELE_NUM 100
#define QUADRANT_RU 1
#define QUADRANT_LU 2
#define QUADRANT_LB 3
#define QUADRANT_RB 4
struct Region {
double up;
double bottom;
double left;
double right;
};
struct ElePoint {
double lng;
double lat;
char desc[16];
};
struct QuadTreeNode {
int depth;
int is_leaf;
struct Region region;
struct QuadTreeNode *LU;
struct QuadTreeNode *LB;
struct QuadTreeNode *RU;
struct QuadTreeNode *RB;
int ele_num;
struct ElePoint *ele_list[MAX_ELE_NUM];
};
void initNode(struct QuadTreeNode *node, int depth, struct Region region);
void insertEle(struct QuadTreeNode *node, struct ElePoint ele);
void deleteEle(struct QuadTreeNode *node, struct ElePoint ele);
void splitNode(struct QuadTreeNode *node);
void combineNode(struct QuadTreeNode *node);
void queryEle(struct QuadTreeNode tree, struct ElePoint ele);
void initRegion(struct Region *region, double up, double bottom, double left, double right);
struct QuadTreeNode *createChildNode(struct QuadTreeNode *node, double bottom, double up, double left, double right);
#endif