https://github.com/beste/latlon-geohash-php
🌍 Gustavo Niemeyer's geocoding system
https://github.com/beste/latlon-geohash-php
geocoding geohash php
Last synced: 5 months ago
JSON representation
🌍 Gustavo Niemeyer's geocoding system
- Host: GitHub
- URL: https://github.com/beste/latlon-geohash-php
- Owner: beste
- License: mit
- Created: 2022-01-19T13:26:14.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2026-02-03T00:33:30.000Z (5 months ago)
- Last Synced: 2026-02-03T13:59:27.856Z (5 months ago)
- Topics: geocoding, geohash, php
- Language: PHP
- Homepage:
- Size: 78.1 KB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Geohash
[](https://packagist.org/packages/beste/latlon-geohash)
[](https://packagist.org/packages/beste/latlon-geohash)
[](https://github.com/beste/latlon-geohash-php/actions/workflows/tests.yml)
[](https://github.com/sponsors/jeromegamez)
Library to convert a [geohash](https://en.wikipedia.org/wiki/Geohash) to/from a latitude/longitude point, and to
determine bounds of a geohash cell and find neighbours of a geohash.
This is a PHP implementation based on [chrisveness/latlon-geohash](https://github.com/chrisveness/latlon-geohash).
More information (with interactive conversion) at
[www.movable-type.co.uk/scripts/geohash.html](https://www.movable-type.co.uk/scripts/geohash.html).
## Usage
```php
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)
```
## Installation
```shell
composer require beste/latlon-geohash
```
## Running tests
```shell
composer test
```