Hi,

This is a WHERE clause I have to dynamically create everytime I do a query
to my geographic database. It's fairly obvious: every object in the database
is checked against a bounding box, which is a Rectangle with x=minx, y=miny,
width=maxx, height=maxy:

    public static final String createRegionWhereClause ( Rectangle r )
    {
        return
        "(maxX BETWEEN " + r.x + " AND " + r.width + " AND maxY BETWEEN " +
r.y + " AND " + r.height + " OR " +
        "minX BETWEEN " + r.x + " AND " + r.width + " AND maxY BETWEEN " +
r.y + " AND " + r.height + " OR " +
        "maxX BETWEEN " + r.x + " AND " + r.width + " AND minY BETWEEN " +
r.y + " AND " + r.height + " OR " +
        "minX BETWEEN " + r.x + " AND " + r.width + " AND minY BETWEEN " +
r.y + " AND " + r.height + " OR " +
        "minX BETWEEN " + r.x + " AND " + r.width + " AND maxY > " +
r.height + " AND minY < " + r.y + " OR " +
        "maxx BETWEEN " + r.x + " AND " + r.width + " AND maxY > " +
r.height + " AND minY < " + r.y + " OR " +
        "minY BETWEEN " + r.y + " AND " + r.height + " AND minX < " + r.x +
" AND maxX > " + r.width + " OR " +
        "maxY BETWEEN " + r.y + " AND " + r.height + " AND minX < " + r.x +
" AND maxX > " + r.width + " OR " +
        "minX < " + r.x + " AND maxX > " + r.width + " AND minY < " + r.y +
" AND maxY > " + r.height + " )";
    }

Whilst I already get very good results doing things this way, this is now
optimization time, and I was wondering if there was speedier way to execute
a such query, maybe using a user function written in C.

What do you think ?

Candide Kemmler


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to