C++ Implementation of Node-GeoHash
C++ JavaScript Python
Switch branches/tags
Nothing to show
Pull request Compare This branch is 11 commits ahead of gnagel:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
includes/cvv8
src
tests
.gitignore
README.md
binding.gyp
encode_the_world.csv
index.js
index_speed_tests.js
package.json

README.md

Welcome to node-geohash-cpp

node-geohash-cpp is a C++ extension to node based on node-geohash.

Install

npm install cgeohash

Usage

var geohash = require('cgeohash');
sys.puts(geohash.encode(37.8324, 112.5584)); // 'ww8p1r4t8'

var latlon = geohash.decode('ww8p1r4t8');
sys.puts(latlon.latitude);
sys.puts(latlon.longitude);

encode (latitude, longitude, precision=9)

Encode a pair of latitude and longitude into geohash. The third argument is optional, you can specify a length of this hash string, which also affect on the precision of the geohash.

decode (hashstring)

Decode a hash string into pair of latitude and longitude. A javascript object is returned with key latitude and longitude.

neighbor (hashstring, direction)

Find neighbor of a geohash string in certain direction. Direction is a two-element array, i.e. [1,0] means north, [-1,-1] means southwest.

decode_bbox (hashstring)

Decode hashstring into a bound box matches it. Data returned in a four-element array: [minlat, minlon, maxlat, maxlon]

geohash.neighbors (hashstring)

Return neighbors of a geohash string in all 8 directions.

geohash.expand (hashstring)

Return neighbors of a geohash string plus the center geohash string itself, useful for DB queries.

About Geohash

Check Wikipedia for more information.

License

Ruby on Rails is released under the MIT License.