Giter Club home page Giter Club logo

geohash's Introduction

GeoHash

Simple php geohash class like python-geohash.

Getting Started

Install

composer require lvht/geohash

System Requirements

You need PHP >= 5.4.0.

Usage

Encode a coordinate:

use Lvht\GeoHash;
echo GeoHash::encode(117.031689,36.65396);

The result is wwe0x0euu12.

The default precision is 0.00001 which can be changed by the third parameter of encode method.

Find the neighbors for a given geohash:

use Lvht\GeoHash;
var_dump(GeoHash::expand('wwe0x0'));

and the result is:

array(8) {
  [0] =>
  string(11) "wwe0wc7zzzz"
  [1] =>
  string(11) "wwe0x17zzzz"
  [2] =>
  string(11) "wwe0x37zzzz"
  [3] =>
  string(11) "wwe0wb7zzzz"
  [4] =>
  string(11) "wwe0x27zzzz"
  [5] =>
  string(11) "wwe0qz7zzzz"
  [6] =>
  string(11) "wwe0rp7zzzz"
  [7] =>
  string(11) "wwe0rr7zzzz"
}

Decode a geohash string:

Use Lvht\GeoHash;
var_dump(GeoHash::decode('wwe0x0'));

and the result is:

array(4) {
  [0] =>
  double(117.0263671875)    # min longitude
  [1] =>
  double(117.03735351562)   # max longitude
  [2] =>
  double(36.650390625)      # min latitude
  [3] =>
  double(36.655883789062)   # max latitude
}

geohash's People

Contributors

taoso avatar 1d10t avatar thbourlove avatar

Watchers

Tobias Gassmann avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.