sotechn/yii2-geohash
Composer 安装命令:
composer require sotechn/yii2-geohash
包简介
geohash like python-geohash
README 文档
README
Description
Generate geohash, it is a hierarchical spatial data structure which subdivides space into buckets of grid shape, which is one of the many applications of what is known as a Z-order curve, and generally space-filling curves. See more https://en.wikipedia.org/wiki/Geohash
Getting Started
Install
composer require sotechn/yii2-geohash
or add your composer.json
"require": {
...
"sotechn/yii2-geohash": "~0.1.0"
},
System Requirements
You need PHP >= 5.4.0, Yii ~ 2.0.4
Usage
in your config file
/congig/web.php
added component:
'components' => [
...
'geohash' => [
'class' => 'sotechn\geohash\Geohash',
],
]
after you've added it, you can use it
$hash = Yii::$app->geohash->encode($longitude, $latitude, $prec);
and you can also use behavior with model
public function behaviors()
{
return [
...
['class' => \sotechn\geohash\behaviors\Geohash::className(),]
];
}
you can specify their fields to be used and precision that you use in your default project:
[
'class' => \sotechn\geohash\behaviors\Geohash::className(),
'fieldLng' => 'longitude', // default 'lng'
'fieldLat' => 'latitude', // default 'ltd'
'fieldHash' => 'hash', // default 'geohash'
'defaultPrec' => '0.00000001', // default 0.00001
]
统计信息
- 总下载量: 106
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-02-08