123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2018/4/2
- * Time: 下午4:13
- */
- define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
- require_once(BASE_ROOT_PATH . '/fooder.php');
- require_once(BASE_ROOT_PATH . '/core/framework/libraries/geohash.php');
- class TestGeohash extends PHPUnit_Framework_TestCase
- {
- public static function setUpBeforeClass()
- {
- Base::run_util();
- }
- public function testAll()
- {
- $geohash = new geohash;
- //得到这点的hash值
- $hash = $geohash->encode(39.98123848, 116.30683690);
- //取前缀,前缀约长范围越小
- $prefix = substr($hash, 0, 6);
- //取出相邻八个区域
- $neighbors = $geohash->neighbors($prefix);
- array_push($neighbors, $prefix);
- print_r($neighbors);
- }
- }
|