SQLite

Check-in [df24072de2]
Login

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

Overview
Comment:Simplification to the coordinate rounding logic in RTree.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | rtree-32bit-rounding
Files: files | file ages | folders
SHA1: df24072de27555c6b530b02e821ea8b066c554fc
User & Date: drh 2012-05-28 20:16:42.392
Context
2012-05-29
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: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)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/rtree/rtree.c.
2735
2736
2737
2738
2739
2740
2741

2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775

2776
2777
2778
2779
2780
2781
2782
2783
2784
  }else{
    nodeRelease(pRtree, pRoot);
  }

  return rc;
}


/*
** Convert an sqlite3_value into an RtreeValue (presumably a float)
** while taking care to round toward negative or positive, respectively.
*/
static RtreeValue rtreeValueDown(sqlite3_value *v){
#ifdef SQLITE_RTREE_INT_ONLY
  return (RtreeValue)sqlite3_value_double(v);
#else
  double d = sqlite3_value_double(v);
  float f = (float)d;
  if( f>d ){
    if( f<0.0 ){
      f += f/8388608.0;
    }else{
      f -= f/8388608.0;
    }
  }
  return f;
#endif
}
static RtreeValue rtreeValueUp(sqlite3_value *v){
#ifdef SQLITE_RTREE_INT_ONLY
  return (RtreeValue)sqlite3_value_double(v);
#else
  double d = sqlite3_value_double(v);
  float f = (float)d;
  if( f<d ){
    if( f<0.0 ){
      f -= f/8388608.0;
    }else{
      f += f/8388608.0;
    }
  }
  return f;

#endif
}

/*
** The xUpdate method for rtree module virtual tables.
*/
static int rtreeUpdate(
  sqlite3_vtab *pVtab, 
  int nData, 







>





<
<
<










<


<
<
<










>
|
|







2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747



2748
2749
2750
2751
2752
2753
2754
2755
2756
2757

2758
2759



2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
  }else{
    nodeRelease(pRtree, pRoot);
  }

  return rc;
}

#if !defined(SQLITE_RTREE_INT_ONLY)
/*
** Convert an sqlite3_value into an RtreeValue (presumably a float)
** while taking care to round toward negative or positive, respectively.
*/
static RtreeValue rtreeValueDown(sqlite3_value *v){



  double d = sqlite3_value_double(v);
  float f = (float)d;
  if( f>d ){
    if( f<0.0 ){
      f += f/8388608.0;
    }else{
      f -= f/8388608.0;
    }
  }
  return f;

}
static RtreeValue rtreeValueUp(sqlite3_value *v){



  double d = sqlite3_value_double(v);
  float f = (float)d;
  if( f<d ){
    if( f<0.0 ){
      f -= f/8388608.0;
    }else{
      f += f/8388608.0;
    }
  }
  return f;
}
#endif /* !defined(SQLITE_RTREE_INT_ONLY) */


/*
** The xUpdate method for rtree module virtual tables.
*/
static int rtreeUpdate(
  sqlite3_vtab *pVtab, 
  int nData,