Socket
Book a DemoInstallSign in
Socket

c_geohash

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

c_geohash

1.1.2
bundlerRubygems
Version published
Maintainers
2
Created
Source

Geohash

Geohash is a latitude/longitude encoding system invented by Gustavo Niemeyer when writing the web service at geohash.org, and put into the public domain. Geohashes offer properties like arbitrary precision, similar prefixes for nearby positions, and the possibility of gradually removing characters from the end of the code to reduce its size (and gradually lose precision).

For more information, see:

  • the Wikipedia article on geohash
  • an interactive JavaScript example of geohash

Features

  • Encode to Geohash format, to an arbitrary level of precision
  • Decode from Geohash format, to an arbitrary level of precision
  • C implementation is over 10 times faster than native Ruby code (we checked)

Requirements

  • GCC and a Gnu-ish build environment (for native extensions)

How to use

GeoHash is very easy to use (and fast) because it's written in C with Ruby bindings.

require 'geohash'

GeoHash.decode('f77')
=> [63.98438, -73.82813]

GeoHash.encode(39.51, -76.24)
=> "dr1bc0edrj"

# Decode a geohash to a bounding box
decode_bbox('dqcw4')
=> [39.0234375, -76.552734375], [39.0673828125, -76.5087890625]]

You can encode or decode to an arbitrary level of precision:

  • Encode latitude and longitude to a geohash with precision digits: encode(lat, lon, precision=10)
  • Decode a geohash to a latitude and longitude with decimals digits: decode(geohash, decimals=5)

To Develop

  • Install gem dependencies: bundle install
  • If using MRI, compile the C extension: bundle exec rake compile (if you're using JRuby, this step is unnecessary)
  • Run tests: bundle exec rake test

Credits

FAQs

Package last updated on 13 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.