beste/latlon-geohash

古斯塔沃·尼梅耶尔的地理编码系统

1.2.0 2023-11-27 11:51 UTC

This package is auto-updated.

Last update: 2024-09-13 19:54:46 UTC


README

Current version Supported PHP version Tests Sponsor

库将地理哈希转换为经纬度点,或将经纬度点转换为地理哈希,并确定地理哈希单元的边界以及找到地理哈希的邻居。

这是基于chrisveness/latlon-geohash的PHP实现。更多信息(带有交互式转换)请访问www.movable-type.co.uk/scripts/geohash.html

使用方法

use Beste\Geohash;

// encode latitude/longitude point to geohash of given precision (number of
// characters in resulting geohash); if precision is not specified, it is
// inferred from precision of latitude/longitude values.
Geohash::encode(float $lat, float $lon, ?int $precision = null)

// return { lat, lon } of centre of given geohash, to appropriate precision.
Geohash::decode(string $geohash)

// return { sw, ne } bounds of given geohash.
Geohash::bounds(string $geohash)

// return adjacent cell to given geohash in specified direction (n/s/e/w).
Geohash::adjacent(string $geohash, string $direction)

// return all 8 adjacent cells (n/ne/e/se/s/sw/w/nw) to given geohash.
Geohash::neighbours(string $geohash)

安装

composer require beste/latlon-geohash

运行测试

composer test