~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to lib/vector/rtree/test.c

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/****************************************************************************
3
 
* MODULE:       R-Tree library 
4
 
*              
5
 
* AUTHOR(S):    Antonin Guttman - original code
6
 
*               Daniel Green (green@superliminal.com) - major clean-up
7
 
*                               and implementation of bounding spheres
8
 
*               
9
 
* PURPOSE:      Multidimensional index
10
 
*
11
 
* COPYRIGHT:    (C) 2001 by the GRASS Development Team
12
 
*
13
 
*               This program is free software under the GNU General Public
14
 
*               License (>=v2). Read the file COPYING that comes with GRASS
15
 
*               for details.
16
 
*****************************************************************************/
17
 
 
18
 
#include <stdio.h>
19
 
#include "index.h"
20
 
 
21
 
struct Rect rects[] = {
22
 
    {{0, 0, 0, 2, 2, 0}},       /* xmin, ymin, zmin, xmax, ymax, zmax (for 3 dimensional RTree) */
23
 
    {{5, 5, 0, 7, 7, 0}},
24
 
    {{8, 5, 0, 9, 6, 0}},
25
 
    {{7, 1, 0, 9, 2, 0}}
26
 
};
27
 
 
28
 
 
29
 
int nrects = sizeof(rects) / sizeof(rects[0]);
30
 
struct Rect search_rect = {
31
 
    {6, 4, 0, 10, 6, 0}         /* search will find above rects that this one overlaps */
32
 
};
33
 
 
34
 
int MySearchCallback(int id, void *arg)
35
 
{
36
 
    /* Note: -1 to make up for the +1 when data was inserted */
37
 
    fprintf(stdout, "Hit data rect %d\n", id - 1);
38
 
    return 1;                   /* keep going */
39
 
}
40
 
 
41
 
int main()
42
 
{
43
 
    struct Node *root = RTreeNewIndex();
44
 
    int i, nhits;
45
 
 
46
 
    fprintf(stdout, "nrects = %d\n", nrects);
47
 
    /*
48
 
     * Insert all the data rects.
49
 
     * Notes about the arguments:
50
 
     * parameter 1 is the rect being inserted,
51
 
     * parameter 2 is its ID. NOTE: *** ID MUST NEVER BE ZERO ***, hence the +1,
52
 
     * parameter 3 is the root of the tree. Note: its address is passed
53
 
     * because it can change as a result of this call, therefore no other parts
54
 
     * of this code should stash its address since it could change undernieth.
55
 
     * parameter 4 is always zero which means to add from the root.
56
 
     */
57
 
    for (i = 0; i < nrects; i++)
58
 
        RTreeInsertRect(&rects[i], i + 1, &root, 0);    /* i+1 is rect ID. Note: root can change */
59
 
    nhits = RTreeSearch(root, &search_rect, MySearchCallback, 0);
60
 
    fprintf(stdout, "Search resulted in %d hits\n", nhits);
61
 
 
62
 
    return 0;
63
 
}