Thanks for the reply,

I misunderstood the concept of dimensions here (i have fairly good knowledge
about r-trees)

Still i am stuck with binding values, and cant really figure out why
(possibly been looking
myself blind on the code ?)

Here is a portion of the code that shows what I do, the bind on index 3
fails:


sqlite3_exec(db, "CREATE VIRTUAL TABLE points_index USING rtree(id, xmin,
xmax, ymin, ymax);", callback, 0, &errmsg);

char *sql_idx = "INSERT INTO points_index (id, xmin, xmax, ymin, ymax)
VALUES (?, ?, ?, ?, ?);";
sqlite3_stmt *stmt_idx = NULL;
tail = NULL;
rc = sqlite3_prepare(db, sql, -1, &stmt_idx, &tail);

for(i=0; i<NUM_POINTS; i++)
{
    /* <snip> */
    rc = sqlite3_bind_int(stmt_idx, 1, i+1);
    if( rc!=SQLITE_OK )
      return sqlerror(db);
    rc = sqlite3_bind_double(stmt_idx, 2, blob.x);
    if( rc!=SQLITE_OK )
      return sqlerror(db);
    rc = sqlite3_bind_double(stmt_idx, 3, blob.x);
    if( rc!=SQLITE_OK )
      return sqlerror(db);
    rc = sqlite3_bind_double(stmt_idx, 4, blob.y);
    if( rc!=SQLITE_OK )
      return sqlerror(db);
    rc = sqlite3_bind_double(stmt_idx, 5, blob.y);
    if( rc!=SQLITE_OK )
      return sqlerror(db);
    /* </snip> */
}


Oyvind




On Tue, Nov 25, 2008 at 4:25 PM, Jay A. Kreibich <[EMAIL PROTECTED]> wrote:

> On Tue, Nov 25, 2008 at 01:26:48PM +0100, Oyvind Idland scratched on the
> wall:
> > Hi,
> >
> > as far as I can see from docs, the r-tree extension uses 32-bit floats to
> > store rectangles.
> >
> > However, when I try to insert this one
> >
> > INSERT INTO points_index (id, x, y) VALUES (3, 731.293, 74.463);
> >
> > i get "SQL error: constraint failed".
> >
> > Reducing the x to 31.293 works.
> >
> > Is the r-tree limitied to WGS84 latitude/longitude coordinates ?
>
>   From this and your other post, I think you're missing a fundamental
>  point about the R-tree extension: it is designed to hold ranges of
>  data, not points.  An R-tree with three values defines a
>  one-dimensional space not as (id, x, y), but as (id, min_x, max_x).
>
>  If you want to do 2D coords, such as lat/long, you need an R-tree
>  with five columns: (id, x_min, x_max, y_min, y_max).  You can put
>  equal values in to define points, or you can define "boxes" of space.
>  Either way, it must be true that (x_min <= x_max) (and so on), hence
>  the bind and constraint errors you're getting.
>
>    -j
>
> --
> Jay A. Kreibich < J A Y  @  K R E I B I.C H >
>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to