Coder Social home page Coder Social logo

veyrony / libgeohash Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simplegeo/libgeohash

1.0 1.0 0.0 92 KB

A pure C implementation of the Geohash algorithm.

Home Page: http://geohash.org

License: BSD 3-Clause "New" or "Revised" License

C 98.20% Makefile 1.80%

libgeohash's Introduction

libgeohash

Derek Smith

A static library used for encoding/decoding geohashes.

To use libgeohash just run make. Link libgeohash.a and include geohash.h into your project.

Encode

char* geohash_encode(double lat, double lng, int precision);

Takes in latitude and longitude with a desired precision and returns the correct hash value. If precision < 0 or precision > 20, a default value of 6 will be used.

Decode

GeoCoord geohash_decode(char* hash);

Produces an allocated GeoCoord structure which contains the latitude and longitude that was decoded from the geohash. A GeoCoord also provides the bounding box for the geohash (north, east, south, west).

Neighbors

char** geohash_neighbors(char* hash);

Uses the bounding box declared at hash and calculates the 8 neighboring boxes. An example is show below.

  • ezefx ezs48 ezs49
  • ezefr ezs42 ezs43
  • ezefp ezs40 ezs41

The value returned is an array of char* with length of 8. The neighboring positions of values are shown below with each box representing the index of the array.

  • 7 0 1
  • 6 * 2
  • 5 4 3

libgeohash's People

Contributors

wadey avatar veyrony avatar joestump avatar

Stargazers

 avatar

Watchers

James Cloos 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.