定制 saikiran/geohash 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

saikiran/geohash

最新稳定版本:v1.0.1

Composer 安装命令:

composer require saikiran/geohash

包简介

Geohash Algorithm to encode geographic coordinates to a string of letters and digits

关键字:

README 文档

README

Geohash is a php module that provides below functions.

  • Encoding geographic location into short string of letters and digits.
  • Decoding string of letters and digits to latitude and longitude.
  • Identifying the neighbouring geohashes of a provided geohash.

Installation

The easiest way to install PHP Geohash is with composer. Find it on Packagist.

$ composer require saikiran/geohash

Usage

Encode co-ordinates

use Sk\Geohash\Geohash;

$g = new Geohash();
echo $g->encode(17.38000000, 78.42000000, 5);

The result is

tepfb

Decode geohash into geographical coordinates

use Sk\Geohash\Geohash;

$g = new Geohash();
$coordinates = $g->decode("tepfb", 5);
echo "latitude : " . $coordinates[0] . ",  longitude : " . $coordinates[1];

The result is

latitude : 17.38,  longitude : 78.42

Get geohashes of 8 neighbors of a geohash

use Sk\Geohash\Geohash;

$g = new Geohash();
$hash = $g->encode(25.813646, -80.133761, 7);
$neighbors = $g->getNeighbors($hash);
echo "Hash: $hash\n";
echo "Neighbors: " . json_encode($neighbors) . "\n";

The result is

Hash: 
Neighbors: {"North":"dhx4be2","East":"dhx4be1","South":"dhx4bdb","West":"dhx4b7p","NorthEast":"dhx4be3","SouthEast":"dhx4bdc","SouthWest":"dhx4b6z","NorthWest":"dhx4b7r"}

Running the unit tests

Go to this directory from your project folder

$ cd vendor/saikiran/geohash

Then run these two commands

$ composer install
$ vendor/bin/phpunit tests

See these resources online:

统计信息

  • 总下载量: 387.05k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 43
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 42
  • Watchers: 1
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-09