Name Date Size #Lines LOC

..04-Jul-2025-

util/H04-Jul-2025-8872

READMEH A D04-Jul-20254.1 KiB12181

geopoly.cH A D04-Jul-202551.1 KiB1,8151,384

rtree.cH A D04-Jul-2025140.3 KiB4,5833,286

rtree.hH A D04-Jul-2025776 3111

rtree1.testH A D04-Jul-202522.9 KiB760697

rtree2.testH A D04-Jul-20253.9 KiB148132

rtree3.testH A D04-Jul-20256.8 KiB271251

rtree4.testH A D04-Jul-20257.5 KiB255233

rtree5.testH A D04-Jul-20252.1 KiB8476

rtree6.testH A D04-Jul-20255 KiB182161

rtree7.testH A D04-Jul-20251.8 KiB7467

rtree8.testH A D04-Jul-20255.8 KiB210189

rtree9.testH A D04-Jul-20254.2 KiB130110

rtreeA.testH A D04-Jul-20257.2 KiB263230

rtreeB.testH A D04-Jul-20252 KiB5146

rtreeC.testH A D04-Jul-20258.9 KiB379338

rtreeD.testH A D04-Jul-20251.4 KiB5648

rtreeE.testH A D04-Jul-20255.3 KiB144125

rtreeF.testH A D04-Jul-20252.3 KiB8574

rtreeG.testH A D04-Jul-20251.5 KiB7060

rtreeH.testH A D04-Jul-20253.5 KiB10491

rtreeI.testH A D04-Jul-20252.2 KiB7569

rtree_perf.tclH A D04-Jul-20251.7 KiB7562

rtree_util.tclH A D04-Jul-20255.2 KiB198134

rtreecheck.testH A D04-Jul-20254 KiB161136

rtreecirc.testH A D04-Jul-20251.5 KiB6759

rtreeconnect.testH A D04-Jul-20251.3 KiB5746

rtreedoc.testH A D04-Jul-202553.2 KiB1,5841,436

rtreedoc2.testH A D04-Jul-202510 KiB347318

rtreedoc3.testH A D04-Jul-20258.2 KiB293248

rtreefuzz001.testH A D04-Jul-202583.8 KiB1,2121,198

sqlite3rtree.hH A D04-Jul-20254 KiB11858

test_rtreedoc.cH A D04-Jul-20259.7 KiB349261

tkt3363.testH A D04-Jul-20251.1 KiB5143

viewrtree.tclH A D04-Jul-20255.3 KiB189157

visual01.txtH A D04-Jul-202521.7 KiB603577

README

1
2This directory contains an SQLite extension that implements a virtual
3table type that allows users to create, query and manipulate r-tree[1]
4data structures inside of SQLite databases. Users create, populate
5and query r-tree structures using ordinary SQL statements.
6
7    1.  SQL Interface
8
9        1.1  Table Creation
10        1.2  Data Manipulation
11        1.3  Data Querying
12        1.4  Introspection and Analysis
13
14    2.  Compilation and Deployment
15
16    3.  References
17
18
191. SQL INTERFACE
20
21  1.1 Table Creation.
22
23    All r-tree virtual tables have an odd number of columns between
24    3 and 11. Unlike regular SQLite tables, r-tree tables are strongly
25    typed.
26
27    The leftmost column is always the pimary key and contains 64-bit
28    integer values. Each subsequent column contains a 32-bit real
29    value. For each pair of real values, the first (leftmost) must be
30    less than or equal to the second. R-tree tables may be
31    constructed using the following syntax:
32
33      CREATE VIRTUAL TABLE <name> USING rtree(<column-names>)
34
35    For example:
36
37      CREATE VIRTUAL TABLE boxes USING rtree(boxno, xmin, xmax, ymin, ymax);
38      INSERT INTO boxes VALUES(1, 1.0, 3.0, 2.0, 4.0);
39
40    Constructing a virtual r-tree table <name> creates the following three
41    real tables in the database to store the data structure:
42
43      <name>_node
44      <name>_rowid
45      <name>_parent
46
47    Dropping or modifying the contents of these tables directly will
48    corrupt the r-tree structure. To delete an r-tree from a database,
49    use a regular DROP TABLE statement:
50
51      DROP TABLE <name>;
52
53    Dropping the main r-tree table automatically drops the automatically
54    created tables.
55
56  1.2 Data Manipulation (INSERT, UPDATE, DELETE).
57
58    The usual INSERT, UPDATE or DELETE syntax is used to manipulate data
59    stored in an r-tree table. Please note the following:
60
61      * Inserting a NULL value into the primary key column has the
62        same effect as inserting a NULL into an INTEGER PRIMARY KEY
63        column of a regular table. The system automatically assigns
64        an unused integer key value to the new record. Usually, this
65        is one greater than the largest primary key value currently
66        present in the table.
67
68      * Attempting to insert a duplicate primary key value fails with
69        an SQLITE_CONSTRAINT error.
70
71      * Attempting to insert or modify a record such that the value
72        stored in the (N*2)th column is greater than that stored in
73        the (N*2+1)th column fails with an SQLITE_CONSTRAINT error.
74
75      * When a record is inserted, values are always converted to
76        the required type (64-bit integer or 32-bit real) as if they
77        were part of an SQL CAST expression. Non-numeric strings are
78        converted to zero.
79
80  1.3 Queries.
81
82    R-tree tables may be queried using all of the same SQL syntax supported
83    by regular tables. However, some query patterns are more efficient
84    than others.
85
86    R-trees support fast lookup by primary key value (O(logN), like
87    regular tables).
88
89    Any combination of equality and range (<, <=, >, >=) constraints
90    on spatial data columns may be used to optimize other queries. This
91    is the key advantage to using r-tree tables instead of creating
92    indices on regular tables.
93
94  1.4 Introspection and Analysis.
95
96    TODO: Describe rtreenode() and rtreedepth() functions.
97
98
992. COMPILATION AND USAGE
100
101  The easiest way to compile and use the RTREE extension is to build
102  and use it as a dynamically loadable SQLite extension. To do this
103  using gcc on *nix:
104
105    gcc -shared rtree.c -o libSqliteRtree.so
106
107  You may need to add "-I" flags so that gcc can find sqlite3ext.h
108  and sqlite3.h. The resulting shared lib, libSqliteRtree.so, may be
109  loaded into sqlite in the same way as any other dynamicly loadable
110  extension.
111
112
1133. REFERENCES
114
115  [1]  Atonin Guttman, "R-trees - A Dynamic Index Structure For Spatial
116       Searching", University of California Berkeley, 1984.
117
118  [2]  Norbert Beckmann, Hans-Peter Kriegel, Ralf Schneider, Bernhard Seeger,
119       "The R*-tree: An Efficient and Robust Access Method for Points and
120       Rectangles", Universitaet Bremen, 1990.
121