R*Tree Geometry Callback functions

27 views
Skip to first unread message

a.furieri

unread,
Oct 13, 2010, 5:04:50 AM10/13/10
to SpatiaLite Users
Hi all,

last week (October 8) SQLite v.3.7.3 was
released: this latest version implements
an interesting feature I've already integrated
into SpatiaLite.

Here is a quick preliminary report.
---------------------------------------------
a new API is now supported:
sqlite3_rtree_geometry_callback()

this allows to implement user-defined
SQL functions inspecting the R*Tree
Spatial Index in an easiest way

here you can get a full reference:
http://www.sqlite.org/rtree.html#customquery


SpatiaLite's support:
---------------------------------------------
SELECT *
FROM GeoNames
WHERE ROWID IN (
SELECT pkid
FROM idx_GeoNames_geometry
WHERE pkid MATCH
RTreeIntersects(11.9, 43.0, 12.4, 43.5)
);

the following new SQL functions are now
available for R*Tree queries:

RTreeIntersect(x1, y1, x2, y2)
RTreeWithin(x1, y1, x2, y2)
RTreeContains(x1, y1, x2, y1)

[x1,y1] and [x2,y2] are two arbitrary
points defining the MBR extent to be
inspected.

adhering to SQLite's rules, we can now
query the R*Tree using this syntax:

... WHERE pkid MATCH mbr-funct(..)

this seems to be a significant improvement:
as you surely remember, the previous R*Tree
implementation required to use SQL queries like:

SELECT *
FROM GeoNames
WHERE ROWID IN (
SELECT pkid
FROM idx_GeoNames_geometry
WHERE pkid xmax >= 11.9 and ymax >= 43.0
AND xmin <= 12.4 AND ymin <= 43.5
);

Please note: you can safely continue using
"old styled" queries.
But the new syntax decisively seems to be by far
simpler, clearer and most user friendly.

To be released ASAP :-)

bye Sandro
Reply all
Reply to author
Forward
0 new messages