/ Changes On Branch rtree-32bit-rounding
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch rtree-32bit-rounding Excluding Merge-Ins

This is equivalent to a diff from bcc72d413e to f607ad27c1

2012-05-29
00:39
In the RTree module, make sure all double-to-float conversions round in a direction to increase the size of element bounding boxes. (check-in: 0abdc2903d user: drh tags: trunk)
00:30
Refactor the float-to-double rounding routines so that they compile without warnings. (Closed-Leaf check-in: f607ad27c1 user: drh tags: rtree-32bit-rounding)
2012-05-28
20:22
Fix the MSVC makefile so that it works with the unicode61 tokenizer. (check-in: 480158143b user: drh tags: trunk)
20:16
Simplification to the coordinate rounding logic in RTree. (check-in: df24072de2 user: drh tags: rtree-32bit-rounding)
19:19
When converting 64-bit floating point coordinates to 32-bit in RTree, take care to round the values such that the size of the bounding box is enlarged. (check-in: f4e8ff03ea user: drh tags: rtree-32bit-rounding)
18:22
Merge the unicode61 tokenizer and the shared-cache-memory database changes into the sessions branch. (check-in: df817e70af user: drh tags: sessions)
17:51
Updates regarding URI query parameters and shared cache in the documentation derived from comments in sqlite.h.in. No changes to code. (check-in: bcc72d413e user: drh tags: trunk)
15:32
Fix Makefile.in so that it works with the new unicode tokenizer of FTS3/4. Update the version number to 3.7.13. (check-in: b8720d0416 user: drh tags: trunk)

Changes to ext/rtree/rtree.c.

  2734   2734       rc = nodeRelease(pRtree, pRoot);
  2735   2735     }else{
  2736   2736       nodeRelease(pRtree, pRoot);
  2737   2737     }
  2738   2738   
  2739   2739     return rc;
  2740   2740   }
         2741  +
         2742  +/*
         2743  +** Rounding constants for float->double conversion.
         2744  +*/
         2745  +#define RNDTOWARDS  (1.0 - 1.0/8388608.0)  /* Round towards zero */
         2746  +#define RNDAWAY     (1.0 + 1.0/8388608.0)  /* Round away from zero */
         2747  +
         2748  +#if !defined(SQLITE_RTREE_INT_ONLY)
         2749  +/*
         2750  +** Convert an sqlite3_value into an RtreeValue (presumably a float)
         2751  +** while taking care to round toward negative or positive, respectively.
         2752  +*/
         2753  +static RtreeValue rtreeValueDown(sqlite3_value *v){
         2754  +  double d = sqlite3_value_double(v);
         2755  +  float f = (float)d;
         2756  +  if( f>d ){
         2757  +    f = (float)(d*(d<0 ? RNDAWAY : RNDTOWARDS));
         2758  +  }
         2759  +  return f;
         2760  +}
         2761  +static RtreeValue rtreeValueUp(sqlite3_value *v){
         2762  +  double d = sqlite3_value_double(v);
         2763  +  float f = (float)d;
         2764  +  if( f<d ){
         2765  +    f = (float)(d*(d<0 ? RNDTOWARDS : RNDAWAY));
         2766  +  }
         2767  +  return f;
         2768  +}
         2769  +#endif /* !defined(SQLITE_RTREE_INT_ONLY) */
         2770  +
  2741   2771   
  2742   2772   /*
  2743   2773   ** The xUpdate method for rtree module virtual tables.
  2744   2774   */
  2745   2775   static int rtreeUpdate(
  2746   2776     sqlite3_vtab *pVtab, 
  2747   2777     int nData, 
................................................................................
  2771   2801       int ii;
  2772   2802   
  2773   2803       /* Populate the cell.aCoord[] array. The first coordinate is azData[3]. */
  2774   2804       assert( nData==(pRtree->nDim*2 + 3) );
  2775   2805   #ifndef SQLITE_RTREE_INT_ONLY
  2776   2806       if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
  2777   2807         for(ii=0; ii<(pRtree->nDim*2); ii+=2){
  2778         -        cell.aCoord[ii].f = (RtreeValue)sqlite3_value_double(azData[ii+3]);
  2779         -        cell.aCoord[ii+1].f = (RtreeValue)sqlite3_value_double(azData[ii+4]);
         2808  +        cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);
         2809  +        cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);
  2780   2810           if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){
  2781   2811             rc = SQLITE_CONSTRAINT;
  2782   2812             goto constraint;
  2783   2813           }
  2784   2814         }
  2785   2815       }else
  2786   2816   #endif