2017 © Pedro Peláez
 

library geohash

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

image

saikiran/geohash

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

  • Saturday, April 14, 2018
  • by sk-22
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 150 % Grown

The README.md

Geohash

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., (*1)

Installation

The easiest way to install PHP Geohash is with composer. Find it on Packagist., (*2)

$ composer require saikiran/geohash

Usage

Encode co-ordinates, (*3)

use Sk\Geohash\Geohash;

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

The result is, (*4)

tepfb

Decode geohash into geographical coordinates, (*5)

use Sk\Geohash\Geohash;

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

The result is, (*6)

latitude : 17.38,  longitude : 78.42

Get geohashes of 8 neighbors of a geohash, (*7)

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, (*8)

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, (*9)

$ cd vendor/saikiran/geohash

Then run these two commands, (*10)

$ composer install
$ vendor/bin/phpunit tests

See these resources online:

  • http://geohash.org
  • http://en.wikipedia.org/wiki/Geohash

The Versions

14/04 2018

dev-master

9999999-dev https://github.com/skthon/geohash

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

  Sources   Download

MIT

The Development Requires

by Saikiran Ch

php geohash

04/02 2018

v0.9

0.9.0.0 https://github.com/ImSaikiran/Geohash

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

  Sources   Download

MIT

The Development Requires

by Saikiran Ch

php geohash

11/12 2017

v0.2-alpha

0.2.0.0-alpha https://github.com/ImSaikiran/Geohash

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

  Sources   Download

MIT

The Development Requires

by Saikiran Ch

php geohash