Geo: output 10 chars of geohash, not 11.
This does not limit the actual precision, because the last digit bits were garbage, and the shift value became even negative in the last iteration.
This commit is contained in:
parent
c65347ab17
commit
009862ab7e
@ -734,14 +734,14 @@ void geohashCommand(client *c) {
|
|||||||
r[1].max = 90;
|
r[1].max = 90;
|
||||||
geohashEncode(&r[0],&r[1],xy[0],xy[1],26,&hash);
|
geohashEncode(&r[0],&r[1],xy[0],xy[1],26,&hash);
|
||||||
|
|
||||||
char buf[12];
|
char buf[11];
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 11; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
int idx = (hash.bits >> (52-((i+1)*5))) & 0x1f;
|
int idx = (hash.bits >> (52-((i+1)*5))) & 0x1f;
|
||||||
buf[i] = geoalphabet[idx];
|
buf[i] = geoalphabet[idx];
|
||||||
}
|
}
|
||||||
buf[11] = '\0';
|
buf[10] = '\0';
|
||||||
addReplyBulkCBuffer(c,buf,11);
|
addReplyBulkCBuffer(c,buf,10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ start_server {tags {"geo"}} {
|
|||||||
r del points
|
r del points
|
||||||
r geoadd points -5.6 42.6 test
|
r geoadd points -5.6 42.6 test
|
||||||
lindex [r geohash points test] 0
|
lindex [r geohash points test] 0
|
||||||
} {ezs42e44yx0}
|
} {ezs42e44yx}
|
||||||
|
|
||||||
test {GEOPOS simple} {
|
test {GEOPOS simple} {
|
||||||
r del points
|
r del points
|
||||||
|
Loading…
x
Reference in New Issue
Block a user