source: TI02-CSML/trunk/services/3rdParty/Quadtree-0.1.2/tests/QuadTree.txt @ 2194

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/services/3rdParty/Quadtree-0.1.2/tests/QuadTree.txt@2194
Revision 2194, 950 bytes checked in by lawrence, 13 years ago (diff)

Adding various specs and 3rd party code of interest for the CSML
services development.

Line 
1Testing Quadtree
2================
3
4Make an instance
5
6    >>> from quadtree import Quadtree
7    >>> index = Quadtree((-180, -90, 180, 90), maxdepth=16)
8
9Add 4 items, the last one a point
10
11    >>> index.add(0, [-106, 39, -105, 40])
12    >>> index.add(1, (-100, 25, -95, 30))
13    >>> index.add(2, (40, 50, 45, 55))
14    >>> index.add(3, (-105, 33))
15
16Prune
17
18    >>> index.prune()
19
20Find likely items
21
22    >>> [n for n in index.likely_intersection([-110, 30, -100, 45])]
23    [0, 1, 3]
24    >>> [n for n in index.likely_intersection([10, 40, 40.05, 60])]
25    [2]
26
27We get a hit for the next bounding box even though it doesn't explicity
28intersect with the item -- it does intersect with the tree node containing
29the item.
30
31    >>> [n for n in index.likely_intersection([-110, 35, -108, 45])]
32    [0]
33   
34Tree structure
35
36    >>> tree = index.struct()
37   
38Visualize
39
40    >>> from quadtree.viz import render_graph
41    >>> render_graph(tree, 'quadtree.png')
42   
43
Note: See TracBrowser for help on using the repository browser.