Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created November 14, 2011 20:23
Show Gist options
  • Save springmeyer/1365027 to your computer and use it in GitHub Desktop.
Save springmeyer/1365027 to your computer and use it in GitHub Desktop.
rtree patch
diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c
index 884482e..5e3e44b 100644
--- a/ext/rtree/rtree.c
+++ b/ext/rtree/rtree.c
@@ -105,6 +105,7 @@
#include <string.h>
#include <assert.h>
+#include <stdint.h>
#ifndef SQLITE_AMALGAMATION
#include "sqlite3rtree.h"
@@ -1268,8 +1269,7 @@ static int rtreeFilter(
rc = SQLITE_NOMEM;
}else{
memset(pCsr->aConstraint, 0, sizeof(RtreeConstraint)*argc);
- assert( (idxStr==0 && argc==0)
- || (idxStr && (int)strlen(idxStr)==argc*2) );
+ assert( (idxStr==0 && argc==0) || (int)strlen(idxStr)==argc*2 );
for(ii=0; ii<argc; ii++){
RtreeConstraint *p = &pCsr->aConstraint[ii];
p->op = idxStr[ii*2];
@@ -1570,10 +1570,7 @@ static int ChooseLeaf(
float fMinGrowth = 0.0;
float fMinArea = 0.0;
-#if VARIANT_RSTARTREE_CHOOSESUBTREE
float fMinOverlap = 0.0;
- float overlap;
-#endif
int nCell = NCELL(pNode);
RtreeCell cell;
@@ -1605,6 +1602,7 @@ static int ChooseLeaf(
int bBest = 0;
float growth;
float area;
+ float overlap = 0.0;
nodeGetCell(pRtree, pNode, iCell, &cell);
growth = cellGrowth(pRtree, &cell, pCell);
area = cellArea(pRtree, &cell);
@@ -1612,8 +1610,6 @@ static int ChooseLeaf(
#if VARIANT_RSTARTREE_CHOOSESUBTREE
if( ii==(pRtree->iDepth-1) ){
overlap = cellOverlapEnlargement(pRtree,&cell,pCell,aCell,nCell,iCell);
- }else{
- overlap = 0.0;
}
if( (iCell==0)
|| (overlap<fMinOverlap)
@@ -1621,7 +1617,6 @@ static int ChooseLeaf(
|| (overlap==fMinOverlap && growth==fMinGrowth && area<fMinArea)
){
bBest = 1;
- fMinOverlap = overlap;
}
#else
if( iCell==0||growth<fMinGrowth||(growth==fMinGrowth && area<fMinArea) ){
@@ -1629,6 +1624,7 @@ static int ChooseLeaf(
}
#endif
if( bBest ){
+ fMinOverlap = overlap;
fMinGrowth = growth;
fMinArea = area;
iBest = cell.iRowid;
@max-mapper
Copy link

NERD

@springmeyer
Copy link
Author

lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment