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