Navit SVN

/work/compile/navit/src/navit/map/csv/quadtree.h

00001 
00020 #ifndef QUADTREE_H
00021 #define QUADTREE_H
00022 
00023 #include <glib.h>
00024 
00025 #define QUADTREE_NODE_CAPACITY 10
00026 
00027 struct quadtree_item {
00028     double longitude;
00029     double latitude;
00030     int ref_count;
00031     int deleted;
00032     void *data;
00033 };
00034 
00035 struct quadtree_node {
00036     int node_num;
00037     struct quadtree_item *items[QUADTREE_NODE_CAPACITY];
00038     struct quadtree_node *aa;
00039     struct quadtree_node *ab;
00040     struct quadtree_node *ba;
00041     struct quadtree_node *bb;
00042     double xmin, xmax, ymin, ymax;
00043     int is_leaf;
00044     struct quadtree_node*parent;
00045     int ref_count;
00046 };
00047 
00048 struct quadtree_iter; 
00049 
00050 struct quadtree_node* quadtree_node_new(struct quadtree_node* parent, double xmin, double xmax, double ymin, double ymax );
00051 struct quadtree_item* quadtree_find_nearest_flood(struct quadtree_node* this_, struct quadtree_item* item, double current_max, struct quadtree_node* toSkip);
00052 struct quadtree_item* quadtree_find_nearest(struct quadtree_node* this_, struct quadtree_item* item);
00053 struct quadtree_item* quadtree_find_item(struct quadtree_node* this_, struct quadtree_item* item);
00054 struct quadtree_node* quadtree_find_containing_node(struct quadtree_node* root, struct quadtree_item* item);
00055 int  quadtree_delete_item(struct quadtree_node* root, struct quadtree_item* item);
00056 void quadtree_find_rect_items(struct quadtree_node* this_, double dXMin, double dXMax, double dYMin, double dYMax, GList**out);
00057 void quadtree_split(struct quadtree_node* this_);
00058 void quadtree_add(struct quadtree_node* this_, struct quadtree_item* item);
00059 void quadtree_destroy(struct quadtree_node* this_);
00060 struct quadtree_iter *quadtree_query(struct quadtree_node *this_, double dXMin, double dXMax, double dYMin, double dYMax,void (*item_free)(void *context, struct quadtree_item *qitem), void *context);
00061 struct quadtree_item * quadtree_item_next(struct quadtree_iter *iter);
00062 void quadtree_query_free(struct quadtree_iter *iter);
00063 void quadtree_item_delete(struct quadtree_iter *iter);
00064 
00065 #endif