2017 © Pedro PelĆ”ez
 

project geohash

Class libraries implemented using PHP based on GeoHash algorithms.

image

ccinn/geohash

Class libraries implemented using PHP based on GeoHash algorithms.

  • Tuesday, January 30, 2018
  • by ccinn
  • Repository
  • 1 Watchers
  • 1 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

geohash

Class libraries implemented using PHP based on GeoHash algorithms., (*1)

For details, please refer to the blog ļ¼ˆChineseļ¼‰:, (*2)

https://usblog.crazylaw.cn/index.php/archives/324/, (*3)

Usage

Three API methods are provided., (*4)

  • around($lng, $lat, $interceptLength = 0) Convert the HashCode in the 9 regions of the longitude and latitude., (*5)

  • encode($lng, $lat, $interceptLength = 0) Converts HashCode to the specified latitude and longitude., (*6)

  • distance($centerLng, $centerLat, $pointLng, $pointLat, $lenType = 1, $decimal = 2) Calculate the distance between two latitude and longitude., (*7)

exampleļ¼š, (*8)

require_once 'vendor/autoload.php';

// The base hashcode length must be a multiple of 5, otherwise it will automatically be filled to a multiple of 5.
// The longer the base length of hashcode is, the more options are available to intercept, and the longer it is recommended. 10 is usually enough.
$hashCodeLength = 10;

$geohash = new ccinn\GeoHash($hashCodeLength);

// Search nearby 20 meters
$interceptLength = 8;
$around          = $geohash->around(113.314748, 23.125851, $interceptLength);

var_dump($around, $point = $geohash->encode(113.314851, 23.125839, $interceptLength));

if (in_array($point, $around)) {
    echo 'in_around' . PHP_EOL;
} else {
    echo 'not_in_around' . PHP_EOL;
}

var_dump('distance:' . $geohash->distance(113.314748, 23.125851, 113.314851, 23.125839) . 'm');

The Versions

30/01 2018

dev-master

9999999-dev

Class libraries implemented using PHP based on GeoHash algorithms.

  Sources   Download

by whiteCcinn

30/01 2018

v1.0

1.0.0.0

Class libraries implemented using PHP based on GeoHash algorithms.

  Sources   Download

by whiteCcinn