cevin/geohash

PHP 地理哈希库

1.0 2016-11-21 01:36 UTC

This package is auto-updated.

Last update: 2024-09-22 21:13:37 UTC


README

什么是 GeoHash

链接: http://en.wikipedia.org/wiki/Geohash

用法

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', ......)

许可协议

反996许可协议