Geometric Data Structures: grid files and tree variants Dr. M. Gavrilova Geometric data structures Grid files Trees Variants Regular grid (mesh) Grid file Quad tree k-d tree Interval tree Voronoi diagrams BST – search trees, O(n) AVL, IPR – balanced O(log n) B-trees – for indexing and searching in data bases: ◦ Grow from the leaf level ◦ More compact – faster search B+, B* - used for indexing, store data in leaves, nodes are more full Spatial queries Point location Stabbing query (which intervals/polygons contain the point) Window query – which objects (polygons, points) are intersecting the given window (polygon) Point query – find an object containing a point (find Voronoi region containing a point) Window query – find an object overlapping a rectangle Spatial join – join parts of objects satisfying some relationship (intersection, adjacency, containment) Geometric, 1-dimensional tree Interval is defined by (x1,x2) Split at the middle (5), again at the middle (3,7), again at the middle (2,8) All intervals intersecting a middle point are stored at the corresponding root.
(4,6) (4,8)
(6,9) (2,4)
1 2 3 4 5 6 7 8 9 (7.5,8.5) Finding intervals – by finding x1, x2 against the nodes Find interval containing specific value – from the root Sort intervals within each node of the tree according to their coorsinates Cost of the “stabbing query”– finding all intervals containing the specified value is O(log n + k), where k is the number of reported intervals. Constructs the minimal bounding box (mbb) Check validity (predicate) on mbb Refinement step verifies if actual objects satisfy the predicate. Fixed grid: Stored as a 2D array, each entry contains a link to a list of points (object) stored in a grid.
a,b Too many points in one grid cell: Split the cell! Rectangles may share different grid cells Duplicates are stored Grid cells are of fixed size In a grid file, the index is dynamically increased in size when overflow happens. The space is split by a vertical or a horizontal line, and then further subdivided when overflow happens! Index is dynamically growing Boundaries of cells of different sizes are stores, thus point and stabbing queries are easy Instead of using an array as an index, use tree!
Quadtree decomposition – cells are indexed by using quaternary B-tree. All cells are squares, not polygons. Search in a tree is faster! Example of a grid file B+ index – actual references to rectangles are stored in the leaves, saving more space+ access time Label nodes according to Z or “pi” order Level of detail increases as the number of quadtree decompositions increases! Decompositions have indexes of a form: 00,01,02,03,10,11,12,13, 2,300 301 ,302 ,303 ,31 ,32 ,33 ◦ Stores as Bplus tree R-tree Each object s decomposed and stored as a set of rectangles Object decomposition: Larger areas of a grid are treated as one element Raster decomposition: Each smaller element s stored separately R-tree ◦ Objects are grouped together according to topological properties not a grid. ◦ More flexibility. R * tree- Optimizes ◦ Node overlapping ◦ Areas covered by the node R+ tree – B+ tree, bounding rectangles do not intersect Used for point location, k –number of the attributes to perform the search Geometric interpretation – to perform search in 2D space – 2-d tree Search components (x,y) interchange! d d c e b f f c a e
b a Define interval tree, grid, grid file, quad-tree, and k-d tree Provide one example of similarity and one example of difference among those data structures