Giter Club home page Giter Club logo

pr_geohash's Introduction

pr_geohash

DESCRIPTION:

GeoHash encode/decode library for pure Ruby.

It’s implementation of en.wikipedia.org/wiki/Geohash

FEATURES

  • Encode/decode geohash

  • Calculate adjacent geohash

  • Tested with Ruby 1.8.7 and JRuby 1.3.1

SYNOPSIS:

require "rubyforge"
require "pr_geohash"

#########
# Encode latitude and longitude into geohash

GeoHash.encode(47.6062095, -122.3320708)
# => "c23nb62w20st"

GeoHash.encode(47.6062095, -122.3320708, 6)
# => "c23nb6"

#########
# Decode from geohash

GeoHash.decode("c23nb6")
# => [[47.603759765625, -122.332763671875], [47.6092529296875, -122.32177734375]]

#########
# Calculate adjacent geohash

GeoHash.neighbors("xn774c")
# => ["xn774f", "xn7754", "xn7751", "xn7750", "xn774b", "xn7748", "xn7749", "xn774d"]

=begin
+--------+--------+--------+
| xn774d | xn774f | xn7754 |
+--------+--------+--------+
| xn7749 | xn774c | xn7751 |
+--------+--------+--------+
| xn7748 | xn774b | xn7750 |
+--------+--------+--------+
=end

INSTALL:

  • sudo gem install pr_geohash

LICENSE:

(The MIT License)

Copyright © 2009 Yuichiro MASUI

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Based library is

github.com/davetroy/geohash-js/blob/master/geohash.js

Geohash library for Javascript

Copyright © 2008 David Troy, Roundhouse Technologies LLC

Distributed under the MIT License

pr_geohash's People

Contributors

masuidrive avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pr_geohash's Issues

Add License information to Gemspec

This will make it show up on rubygems.org. I'm doing due diligence on our gems and need to find out the licenses for all the gems. Having it show up on rubygems.org cuts out the step of having to go to the github repo.

Trouble when longitude ~180

1.9.3-p125 :015 > GeoHash.encode(72.888, 179.888, 4)
 => "zuzy" 
1.9.3-p125 :017 > GeoHash.adjacent("zuzy", :right)
TypeError: can't convert nil into String
    from /Users/admin/.rvm/gems/ruby-1.9.3-p125@project/gems/pr_geohash-1.0.0/lib/pr_geohash.rb:69:in `include?'
    from /Users/admin/.rvm/gems/ruby-1.9.3-p125@project/gems/pr_geohash-1.0.0/lib/pr_geohash.rb:69:in `adjacent'
    from /Users/admin/.rvm/gems/ruby-1.9.3-p125@project/gems/pr_geohash-1.0.0/lib/pr_geohash.rb:70:in `adjacent'
    from /Users/admin/.rvm/gems/ruby-1.9.3-p125@project/gems/pr_geohash-1.0.0/lib/pr_geohash.rb:70:in `adjacent'
    from /Users/admin/.rvm/gems/ruby-1.9.3-p125@project/gems/pr_geohash-1.0.0/lib/pr_geohash.rb:70:in `adjacent'
    from /Users/admin/.rvm/gems/ruby-1.9.3-p125@project/gems/pr_geohash-1.0.0/lib/pr_geohash.rb:70:in `adjacent'
    from (irb):17
    from /Users/admin/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start'
    from /Users/admin/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start'
    from /Users/admin/.rvm/gems/ruby-1.9.3-p125@global/gems/railties-3.2.2/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

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.