cevin / geohash
Geohash library for php
Installs: 1 819
Dependents: 0
Suggesters: 0
Security: 0
Stars: 19
Watchers: 1
Forks: 3
Open Issues: 1
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2025-04-22 22:23:26 UTC
README
What's GeoHash
LINK: http://en.wikipedia.org/wiki/Geohash
Usage
use Cevin\Geohash; $length = 6; $geohash = new Geohash(); $hash = substr($geohash->encode('latitude','longitude'), 0, $length); $box = $geohash->neighbors($hash); $box[] = $hash; $in_str = "'".implode("','", $box)."'"; // PHP // $sql = "SELECT FROM `table` WHERE LEFT(geohash, {$length}) IN ($in_str)"; // echo $sql; // OUTPUT // SELECT FROM `table` WHERE LEFT(geohash, 6) IN ('xxxxxx','aaaaaa', ......)