OLD | NEW |
1 /* | 1 /* |
2 ** 2010 August 28 | 2 ** 2010 August 28 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
11 ************************************************************************* | 11 ************************************************************************* |
12 ** Code for testing all sorts of SQLite interfaces. This code | 12 ** Code for testing all sorts of SQLite interfaces. This code |
13 ** is not included in the SQLite library. | 13 ** is not included in the SQLite library. |
14 */ | 14 */ |
15 | 15 |
16 #include <sqlite3.h> | 16 #include <sqlite3.h> |
| 17 #include <tcl.h> |
17 | 18 |
18 /* Solely for the UNUSED_PARAMETER() macro. */ | 19 /* Solely for the UNUSED_PARAMETER() macro. */ |
19 #include "sqliteInt.h" | 20 #include "sqliteInt.h" |
20 | 21 |
| 22 #ifdef SQLITE_ENABLE_RTREE |
21 /* | 23 /* |
22 ** Type used to cache parameter information for the "circle" r-tree geometry | 24 ** Type used to cache parameter information for the "circle" r-tree geometry |
23 ** callback. | 25 ** callback. |
24 */ | 26 */ |
25 typedef struct Circle Circle; | 27 typedef struct Circle Circle; |
26 struct Circle { | 28 struct Circle { |
27 struct Box { | 29 struct Box { |
28 double xmin; | 30 double xmin; |
29 double xmax; | 31 double xmax; |
30 double ymin; | 32 double ymin; |
31 double ymax; | 33 double ymax; |
32 } aBox[2]; | 34 } aBox[2]; |
33 double centerx; | 35 double centerx; |
34 double centery; | 36 double centery; |
35 double radius; | 37 double radius; |
| 38 double mxArea; |
| 39 int eScoreType; |
36 }; | 40 }; |
37 | 41 |
38 /* | 42 /* |
39 ** Destructor function for Circle objects allocated by circle_geom(). | 43 ** Destructor function for Circle objects allocated by circle_geom(). |
40 */ | 44 */ |
41 static void circle_del(void *p){ | 45 static void circle_del(void *p){ |
42 sqlite3_free(p); | 46 sqlite3_free(p); |
43 } | 47 } |
44 | 48 |
45 /* | 49 /* |
46 ** Implementation of "circle" r-tree geometry callback. | 50 ** Implementation of "circle" r-tree geometry callback. |
47 */ | 51 */ |
48 static int circle_geom( | 52 static int circle_geom( |
49 sqlite3_rtree_geometry *p, | 53 sqlite3_rtree_geometry *p, |
50 int nCoord, | 54 int nCoord, |
51 double *aCoord, | 55 sqlite3_rtree_dbl *aCoord, |
52 int *pRes | 56 int *pRes |
53 ){ | 57 ){ |
54 int i; /* Iterator variable */ | 58 int i; /* Iterator variable */ |
55 Circle *pCircle; /* Structure defining circular region */ | 59 Circle *pCircle; /* Structure defining circular region */ |
56 double xmin, xmax; /* X dimensions of box being tested */ | 60 double xmin, xmax; /* X dimensions of box being tested */ |
57 double ymin, ymax; /* X dimensions of box being tested */ | 61 double ymin, ymax; /* X dimensions of box being tested */ |
58 | 62 |
59 if( p->pUser==0 ){ | 63 xmin = aCoord[0]; |
| 64 xmax = aCoord[1]; |
| 65 ymin = aCoord[2]; |
| 66 ymax = aCoord[3]; |
| 67 pCircle = (Circle *)p->pUser; |
| 68 if( pCircle==0 ){ |
60 /* If pUser is still 0, then the parameter values have not been tested | 69 /* If pUser is still 0, then the parameter values have not been tested |
61 ** for correctness or stored into a Circle structure yet. Do this now. */ | 70 ** for correctness or stored into a Circle structure yet. Do this now. */ |
62 | 71 |
63 /* This geometry callback is for use with a 2-dimensional r-tree table. | 72 /* This geometry callback is for use with a 2-dimensional r-tree table. |
64 ** Return an error if the table does not have exactly 2 dimensions. */ | 73 ** Return an error if the table does not have exactly 2 dimensions. */ |
65 if( nCoord!=4 ) return SQLITE_ERROR; | 74 if( nCoord!=4 ) return SQLITE_ERROR; |
66 | 75 |
67 /* Test that the correct number of parameters (3) have been supplied, | 76 /* Test that the correct number of parameters (3) have been supplied, |
68 ** and that the parameters are in range (that the radius of the circle | 77 ** and that the parameters are in range (that the radius of the circle |
69 ** radius is greater than zero). */ | 78 ** radius is greater than zero). */ |
(...skipping 25 matching lines...) Expand all Loading... |
95 ** points from each half of either of the two infinite bounding boxes. | 104 ** points from each half of either of the two infinite bounding boxes. |
96 */ | 105 */ |
97 pCircle->aBox[0].xmin = pCircle->centerx; | 106 pCircle->aBox[0].xmin = pCircle->centerx; |
98 pCircle->aBox[0].xmax = pCircle->centerx; | 107 pCircle->aBox[0].xmax = pCircle->centerx; |
99 pCircle->aBox[0].ymin = pCircle->centery + pCircle->radius; | 108 pCircle->aBox[0].ymin = pCircle->centery + pCircle->radius; |
100 pCircle->aBox[0].ymax = pCircle->centery - pCircle->radius; | 109 pCircle->aBox[0].ymax = pCircle->centery - pCircle->radius; |
101 pCircle->aBox[1].xmin = pCircle->centerx + pCircle->radius; | 110 pCircle->aBox[1].xmin = pCircle->centerx + pCircle->radius; |
102 pCircle->aBox[1].xmax = pCircle->centerx - pCircle->radius; | 111 pCircle->aBox[1].xmax = pCircle->centerx - pCircle->radius; |
103 pCircle->aBox[1].ymin = pCircle->centery; | 112 pCircle->aBox[1].ymin = pCircle->centery; |
104 pCircle->aBox[1].ymax = pCircle->centery; | 113 pCircle->aBox[1].ymax = pCircle->centery; |
| 114 pCircle->mxArea = (xmax - xmin)*(ymax - ymin) + 1.0; |
105 } | 115 } |
106 | 116 |
107 pCircle = (Circle *)p->pUser; | |
108 xmin = aCoord[0]; | |
109 xmax = aCoord[1]; | |
110 ymin = aCoord[2]; | |
111 ymax = aCoord[3]; | |
112 | |
113 /* Check if any of the 4 corners of the bounding-box being tested lie | 117 /* Check if any of the 4 corners of the bounding-box being tested lie |
114 ** inside the circular region. If they do, then the bounding-box does | 118 ** inside the circular region. If they do, then the bounding-box does |
115 ** intersect the region of interest. Set the output variable to true and | 119 ** intersect the region of interest. Set the output variable to true and |
116 ** return SQLITE_OK in this case. */ | 120 ** return SQLITE_OK in this case. */ |
117 for(i=0; i<4; i++){ | 121 for(i=0; i<4; i++){ |
118 double x = (i&0x01) ? xmax : xmin; | 122 double x = (i&0x01) ? xmax : xmin; |
119 double y = (i&0x02) ? ymax : ymin; | 123 double y = (i&0x02) ? ymax : ymin; |
120 double d2; | 124 double d2; |
121 | 125 |
122 d2 = (x-pCircle->centerx)*(x-pCircle->centerx); | 126 d2 = (x-pCircle->centerx)*(x-pCircle->centerx); |
(...skipping 18 matching lines...) Expand all Loading... |
141 return SQLITE_OK; | 145 return SQLITE_OK; |
142 } | 146 } |
143 } | 147 } |
144 | 148 |
145 /* The specified bounding box does not intersect the circular region. Set | 149 /* The specified bounding box does not intersect the circular region. Set |
146 ** the output variable to zero and return SQLITE_OK. */ | 150 ** the output variable to zero and return SQLITE_OK. */ |
147 *pRes = 0; | 151 *pRes = 0; |
148 return SQLITE_OK; | 152 return SQLITE_OK; |
149 } | 153 } |
150 | 154 |
| 155 /* |
| 156 ** Implementation of "circle" r-tree geometry callback using the |
| 157 ** 2nd-generation interface that allows scoring. |
| 158 */ |
| 159 static int circle_query_func(sqlite3_rtree_query_info *p){ |
| 160 int i; /* Iterator variable */ |
| 161 Circle *pCircle; /* Structure defining circular region */ |
| 162 double xmin, xmax; /* X dimensions of box being tested */ |
| 163 double ymin, ymax; /* X dimensions of box being tested */ |
| 164 int nWithin = 0; /* Number of corners inside the circle */ |
| 165 |
| 166 xmin = p->aCoord[0]; |
| 167 xmax = p->aCoord[1]; |
| 168 ymin = p->aCoord[2]; |
| 169 ymax = p->aCoord[3]; |
| 170 pCircle = (Circle *)p->pUser; |
| 171 if( pCircle==0 ){ |
| 172 /* If pUser is still 0, then the parameter values have not been tested |
| 173 ** for correctness or stored into a Circle structure yet. Do this now. */ |
| 174 |
| 175 /* This geometry callback is for use with a 2-dimensional r-tree table. |
| 176 ** Return an error if the table does not have exactly 2 dimensions. */ |
| 177 if( p->nCoord!=4 ) return SQLITE_ERROR; |
| 178 |
| 179 /* Test that the correct number of parameters (4) have been supplied, |
| 180 ** and that the parameters are in range (that the radius of the circle |
| 181 ** radius is greater than zero). */ |
| 182 if( p->nParam!=4 || p->aParam[2]<0.0 ) return SQLITE_ERROR; |
| 183 |
| 184 /* Allocate a structure to cache parameter data in. Return SQLITE_NOMEM |
| 185 ** if the allocation fails. */ |
| 186 pCircle = (Circle *)(p->pUser = sqlite3_malloc(sizeof(Circle))); |
| 187 if( !pCircle ) return SQLITE_NOMEM; |
| 188 p->xDelUser = circle_del; |
| 189 |
| 190 /* Record the center and radius of the circular region. One way that |
| 191 ** tested bounding boxes that intersect the circular region are detected |
| 192 ** is by testing if each corner of the bounding box lies within radius |
| 193 ** units of the center of the circle. */ |
| 194 pCircle->centerx = p->aParam[0]; |
| 195 pCircle->centery = p->aParam[1]; |
| 196 pCircle->radius = p->aParam[2]; |
| 197 pCircle->eScoreType = (int)p->aParam[3]; |
| 198 |
| 199 /* Define two bounding box regions. The first, aBox[0], extends to |
| 200 ** infinity in the X dimension. It covers the same range of the Y dimension |
| 201 ** as the circular region. The second, aBox[1], extends to infinity in |
| 202 ** the Y dimension and is constrained to the range of the circle in the |
| 203 ** X dimension. |
| 204 ** |
| 205 ** Then imagine each box is split in half along its short axis by a line |
| 206 ** that intersects the center of the circular region. A bounding box |
| 207 ** being tested can be said to intersect the circular region if it contains |
| 208 ** points from each half of either of the two infinite bounding boxes. |
| 209 */ |
| 210 pCircle->aBox[0].xmin = pCircle->centerx; |
| 211 pCircle->aBox[0].xmax = pCircle->centerx; |
| 212 pCircle->aBox[0].ymin = pCircle->centery + pCircle->radius; |
| 213 pCircle->aBox[0].ymax = pCircle->centery - pCircle->radius; |
| 214 pCircle->aBox[1].xmin = pCircle->centerx + pCircle->radius; |
| 215 pCircle->aBox[1].xmax = pCircle->centerx - pCircle->radius; |
| 216 pCircle->aBox[1].ymin = pCircle->centery; |
| 217 pCircle->aBox[1].ymax = pCircle->centery; |
| 218 pCircle->mxArea = 200.0*200.0; |
| 219 } |
| 220 |
| 221 /* Check if any of the 4 corners of the bounding-box being tested lie |
| 222 ** inside the circular region. If they do, then the bounding-box does |
| 223 ** intersect the region of interest. Set the output variable to true and |
| 224 ** return SQLITE_OK in this case. */ |
| 225 for(i=0; i<4; i++){ |
| 226 double x = (i&0x01) ? xmax : xmin; |
| 227 double y = (i&0x02) ? ymax : ymin; |
| 228 double d2; |
| 229 |
| 230 d2 = (x-pCircle->centerx)*(x-pCircle->centerx); |
| 231 d2 += (y-pCircle->centery)*(y-pCircle->centery); |
| 232 if( d2<(pCircle->radius*pCircle->radius) ) nWithin++; |
| 233 } |
| 234 |
| 235 /* Check if the bounding box covers any other part of the circular region. |
| 236 ** See comments above for a description of how this test works. If it does |
| 237 ** cover part of the circular region, set the output variable to true |
| 238 ** and return SQLITE_OK. */ |
| 239 if( nWithin==0 ){ |
| 240 for(i=0; i<2; i++){ |
| 241 if( xmin<=pCircle->aBox[i].xmin |
| 242 && xmax>=pCircle->aBox[i].xmax |
| 243 && ymin<=pCircle->aBox[i].ymin |
| 244 && ymax>=pCircle->aBox[i].ymax |
| 245 ){ |
| 246 nWithin = 1; |
| 247 break; |
| 248 } |
| 249 } |
| 250 } |
| 251 |
| 252 if( pCircle->eScoreType==1 ){ |
| 253 /* Depth first search */ |
| 254 p->rScore = p->iLevel; |
| 255 }else if( pCircle->eScoreType==2 ){ |
| 256 /* Breadth first search */ |
| 257 p->rScore = 100 - p->iLevel; |
| 258 }else if( pCircle->eScoreType==3 ){ |
| 259 /* Depth-first search, except sort the leaf nodes by area with |
| 260 ** the largest area first */ |
| 261 if( p->iLevel==1 ){ |
| 262 p->rScore = 1.0 - (xmax-xmin)*(ymax-ymin)/pCircle->mxArea; |
| 263 if( p->rScore<0.01 ) p->rScore = 0.01; |
| 264 }else{ |
| 265 p->rScore = 0.0; |
| 266 } |
| 267 }else if( pCircle->eScoreType==4 ){ |
| 268 /* Depth-first search, except exclude odd rowids */ |
| 269 p->rScore = p->iLevel; |
| 270 if( p->iRowid&1 ) nWithin = 0; |
| 271 }else{ |
| 272 /* Breadth-first search, except exclude odd rowids */ |
| 273 p->rScore = 100 - p->iLevel; |
| 274 if( p->iRowid&1 ) nWithin = 0; |
| 275 } |
| 276 if( nWithin==0 ){ |
| 277 p->eWithin = NOT_WITHIN; |
| 278 }else if( nWithin>=4 ){ |
| 279 p->eWithin = FULLY_WITHIN; |
| 280 }else{ |
| 281 p->eWithin = PARTLY_WITHIN; |
| 282 } |
| 283 return SQLITE_OK; |
| 284 } |
| 285 /* |
| 286 ** Implementation of "breadthfirstsearch" r-tree geometry callback using the |
| 287 ** 2nd-generation interface that allows scoring. |
| 288 ** |
| 289 ** ... WHERE id MATCH breadthfirstsearch($x0,$x1,$y0,$y1) ... |
| 290 ** |
| 291 ** It returns all entries whose bounding boxes overlap with $x0,$x1,$y0,$y1. |
| 292 */ |
| 293 static int bfs_query_func(sqlite3_rtree_query_info *p){ |
| 294 double x0,x1,y0,y1; /* Dimensions of box being tested */ |
| 295 double bx0,bx1,by0,by1; /* Boundary of the query function */ |
| 296 |
| 297 if( p->nParam!=4 ) return SQLITE_ERROR; |
| 298 x0 = p->aCoord[0]; |
| 299 x1 = p->aCoord[1]; |
| 300 y0 = p->aCoord[2]; |
| 301 y1 = p->aCoord[3]; |
| 302 bx0 = p->aParam[0]; |
| 303 bx1 = p->aParam[1]; |
| 304 by0 = p->aParam[2]; |
| 305 by1 = p->aParam[3]; |
| 306 p->rScore = 100 - p->iLevel; |
| 307 if( p->eParentWithin==FULLY_WITHIN ){ |
| 308 p->eWithin = FULLY_WITHIN; |
| 309 }else if( x0>=bx0 && x1<=bx1 && y0>=by0 && y1<=by1 ){ |
| 310 p->eWithin = FULLY_WITHIN; |
| 311 }else if( x1>=bx0 && x0<=bx1 && y1>=by0 && y0<=by1 ){ |
| 312 p->eWithin = PARTLY_WITHIN; |
| 313 }else{ |
| 314 p->eWithin = NOT_WITHIN; |
| 315 } |
| 316 return SQLITE_OK; |
| 317 } |
| 318 |
151 /* END of implementation of "circle" geometry callback. | 319 /* END of implementation of "circle" geometry callback. |
152 ************************************************************************** | 320 ************************************************************************** |
153 *************************************************************************/ | 321 *************************************************************************/ |
154 | 322 |
155 #include <assert.h> | 323 #include <assert.h> |
156 #include "tcl.h" | 324 #include "tcl.h" |
157 | 325 |
158 typedef struct Cube Cube; | 326 typedef struct Cube Cube; |
159 struct Cube { | 327 struct Cube { |
160 double x; | 328 double x; |
(...skipping 19 matching lines...) Expand all Loading... |
180 ** Implementation of a simple r-tree geom callback to test for intersection | 348 ** Implementation of a simple r-tree geom callback to test for intersection |
181 ** of r-tree rows with a "cube" shape. Cubes are defined by six scalar | 349 ** of r-tree rows with a "cube" shape. Cubes are defined by six scalar |
182 ** coordinates as follows: | 350 ** coordinates as follows: |
183 ** | 351 ** |
184 ** cube(x, y, z, width, height, depth) | 352 ** cube(x, y, z, width, height, depth) |
185 ** | 353 ** |
186 ** The width, height and depth parameters must all be greater than zero. | 354 ** The width, height and depth parameters must all be greater than zero. |
187 */ | 355 */ |
188 static int cube_geom( | 356 static int cube_geom( |
189 sqlite3_rtree_geometry *p, | 357 sqlite3_rtree_geometry *p, |
190 int nCoord, | 358 int nCoord, |
191 double *aCoord, | 359 sqlite3_rtree_dbl *aCoord, |
192 int *piRes | 360 int *piRes |
193 ){ | 361 ){ |
194 Cube *pCube = (Cube *)p->pUser; | 362 Cube *pCube = (Cube *)p->pUser; |
195 | 363 |
196 assert( p->pContext==(void *)&gHere ); | 364 assert( p->pContext==(void *)&gHere ); |
197 | 365 |
198 if( pCube==0 ){ | 366 if( pCube==0 ){ |
199 if( p->nParam!=6 || nCoord!=6 | 367 if( p->nParam!=6 || nCoord!=6 |
200 || p->aParam[3]<=0.0 || p->aParam[4]<=0.0 || p->aParam[5]<=0.0 | 368 || p->aParam[3]<=0.0 || p->aParam[4]<=0.0 || p->aParam[5]<=0.0 |
201 ){ | 369 ){ |
(...skipping 21 matching lines...) Expand all Loading... |
223 && aCoord[2]<=(pCube->y+pCube->height) | 391 && aCoord[2]<=(pCube->y+pCube->height) |
224 && aCoord[3]>=pCube->y | 392 && aCoord[3]>=pCube->y |
225 && aCoord[4]<=(pCube->z+pCube->depth) | 393 && aCoord[4]<=(pCube->z+pCube->depth) |
226 && aCoord[5]>=pCube->z | 394 && aCoord[5]>=pCube->z |
227 ){ | 395 ){ |
228 *piRes = 1; | 396 *piRes = 1; |
229 } | 397 } |
230 | 398 |
231 return SQLITE_OK; | 399 return SQLITE_OK; |
232 } | 400 } |
| 401 #endif /* SQLITE_ENABLE_RTREE */ |
233 | 402 |
234 static int register_cube_geom( | 403 static int register_cube_geom( |
235 void * clientData, | 404 void * clientData, |
236 Tcl_Interp *interp, | 405 Tcl_Interp *interp, |
237 int objc, | 406 int objc, |
238 Tcl_Obj *CONST objv[] | 407 Tcl_Obj *CONST objv[] |
239 ){ | 408 ){ |
240 #ifndef SQLITE_ENABLE_RTREE | 409 #ifndef SQLITE_ENABLE_RTREE |
241 UNUSED_PARAMETER(clientData); | 410 UNUSED_PARAMETER(clientData); |
242 UNUSED_PARAMETER(interp); | 411 UNUSED_PARAMETER(interp); |
243 UNUSED_PARAMETER(objc); | 412 UNUSED_PARAMETER(objc); |
244 UNUSED_PARAMETER(objv); | 413 UNUSED_PARAMETER(objv); |
245 #else | 414 #else |
246 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); | 415 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
247 extern const char *sqlite3TestErrorName(int); | 416 extern const char *sqlite3ErrName(int); |
248 sqlite3 *db; | 417 sqlite3 *db; |
249 int rc; | 418 int rc; |
250 | 419 |
251 if( objc!=2 ){ | 420 if( objc!=2 ){ |
252 Tcl_WrongNumArgs(interp, 1, objv, "DB"); | 421 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
253 return TCL_ERROR; | 422 return TCL_ERROR; |
254 } | 423 } |
255 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 424 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
256 rc = sqlite3_rtree_geometry_callback(db, "cube", cube_geom, (void *)&gHere); | 425 rc = sqlite3_rtree_geometry_callback(db, "cube", cube_geom, (void *)&gHere); |
257 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC); | 426 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); |
258 #endif | 427 #endif |
259 return TCL_OK; | 428 return TCL_OK; |
260 } | 429 } |
261 | 430 |
262 static int register_circle_geom( | 431 static int register_circle_geom( |
263 void * clientData, | 432 void * clientData, |
264 Tcl_Interp *interp, | 433 Tcl_Interp *interp, |
265 int objc, | 434 int objc, |
266 Tcl_Obj *CONST objv[] | 435 Tcl_Obj *CONST objv[] |
267 ){ | 436 ){ |
268 #ifndef SQLITE_ENABLE_RTREE | 437 #ifndef SQLITE_ENABLE_RTREE |
269 UNUSED_PARAMETER(clientData); | 438 UNUSED_PARAMETER(clientData); |
270 UNUSED_PARAMETER(interp); | 439 UNUSED_PARAMETER(interp); |
271 UNUSED_PARAMETER(objc); | 440 UNUSED_PARAMETER(objc); |
272 UNUSED_PARAMETER(objv); | 441 UNUSED_PARAMETER(objv); |
273 #else | 442 #else |
274 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); | 443 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
275 extern const char *sqlite3TestErrorName(int); | 444 extern const char *sqlite3ErrName(int); |
276 sqlite3 *db; | 445 sqlite3 *db; |
277 int rc; | 446 int rc; |
278 | 447 |
279 if( objc!=2 ){ | 448 if( objc!=2 ){ |
280 Tcl_WrongNumArgs(interp, 1, objv, "DB"); | 449 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
281 return TCL_ERROR; | 450 return TCL_ERROR; |
282 } | 451 } |
283 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 452 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
284 rc = sqlite3_rtree_geometry_callback(db, "circle", circle_geom, 0); | 453 rc = sqlite3_rtree_geometry_callback(db, "circle", circle_geom, 0); |
285 Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_STATIC); | 454 if( rc==SQLITE_OK ){ |
| 455 rc = sqlite3_rtree_query_callback(db, "Qcircle", |
| 456 circle_query_func, 0, 0); |
| 457 } |
| 458 if( rc==SQLITE_OK ){ |
| 459 rc = sqlite3_rtree_query_callback(db, "breadthfirstsearch", |
| 460 bfs_query_func, 0, 0); |
| 461 } |
| 462 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); |
286 #endif | 463 #endif |
287 return TCL_OK; | 464 return TCL_OK; |
288 } | 465 } |
289 | 466 |
290 int Sqlitetestrtree_Init(Tcl_Interp *interp){ | 467 int Sqlitetestrtree_Init(Tcl_Interp *interp){ |
291 Tcl_CreateObjCommand(interp, "register_cube_geom", register_cube_geom, 0, 0); | 468 Tcl_CreateObjCommand(interp, "register_cube_geom", register_cube_geom, 0, 0); |
292 Tcl_CreateObjCommand(interp, "register_circle_geom",register_circle_geom,0,0); | 469 Tcl_CreateObjCommand(interp, "register_circle_geom",register_circle_geom,0,0); |
293 return TCL_OK; | 470 return TCL_OK; |
294 } | 471 } |
OLD | NEW |