Skip to content

Commit

Permalink
Search list should include self
Browse files Browse the repository at this point in the history
  • Loading branch information
David Troy committed May 30, 2008
1 parent 45c9cd0 commit 6422e85
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ However, 'dqcjqcp84c6e' is not centered inside 'dqcjqc', and searching within 'd
So instead, we can use the mathematical properties of the Geohash to quickly calculate the neighbors of 'dqcjqc'; we find that they are:
'dqcjqf','dqcjqb','dqcjr1','dqcjq9','dqcjqd','dqcjr4','dqcjr0','dqcjq8'

This gives us a bounding box around 'dqcjqcp84c6e' roughly 2km x 1.5km and allows for a database search on fewer than 9 keys:
SELECT * FROM table WHERE LEFT(geohash,6) IN ('dqcjqf','dqcjqb','dqcjr1','dqcjq9','dqcjqd','dqcjr4','dqcjr0','dqcjq8');
This gives us a bounding box around 'dqcjqcp84c6e' roughly 2km x 1.5km and allows for a database search on just 9 keys:
SELECT * FROM table WHERE LEFT(geohash,6) IN ('dqcjqc', 'dqcjqf','dqcjqb','dqcjr1','dqcjq9','dqcjqd','dqcjr4','dqcjr0','dqcjq8');

MORE INFORMATION
GeoHash on Wikipedia (http://en.wikipedia.org/wiki/Geohash)
Expand Down
2 changes: 1 addition & 1 deletion geohash-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function plotGeoHash (gLatLng) {
for (var n in geoHashBox.neighbors) {
boxes.push("'"+geoHashBox.neighbors[n].geohash+"'");
}
boxList.innerHTML += boxes.join(',') + ")";
boxList.innerHTML += boxes.join(',') + geoHashBox.geohash + ")";

searchInfo = document.getElementById("searchInfo");
var xdistance = geoHashBox.neighbors.topleft.corners.topleft.distanceFrom(geoHashBox.neighbors.topright.corners.topright);
Expand Down

0 comments on commit 6422e85

Please sign in to comment.