On 23/01/2009 12:58 AM, Igor Tandetnik wrote:
> "Sergej Schwarz" <sergej.schw...@gmx.de> wrote in
> message news:20090122133954.74...@gmx.net
>> unfortunately, this does not work, the RTree documentation by SQLite
>> leads to misunderstanding of the concept... The query would results
>> in an empty set.
>>
>> //your query
>> select * from demo where x1>=3 and x2<=19 and y1>=2 and y2<=15;
> 
> That's not at all similar to Dan's query. Try this:
> 
> select * from demo where x1<=19 and x2>=3 and y1<=15 and y2>=2;
> 

Some other comments:

(1) describe the shapes as rectangles rather than the too-general "polygons"
(2) consider
    query1 UNION ... UNION query6
which at least saves the final step of removing duplicates, and may with 
an ultra-smart query engine run faster
(3) consider that 6 queries of the form
    SELECT yadda FROM blah WHERE condition[i]
can be replaced by one query of the form
    SELECT yadda FROM blah WHERE (condition[1]) OR ... OR (condition[6])
(4) note that doing all the algebra to reduce that big expression would 
not result in the same answer as Dan's ... Dan's formula includes the 
case of a big rectangle that completely covers the window plus extra on 
each of the four sides, but the OP's formula doesn't include that case.

By the way, we're all assuming a convention that x1 <= x2 and y1 <= y2, 
aren't we?

HTH,
John
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to