Project

plus_codes

0.01
No commit activity in last 3 years
No release in over 3 years
Ruby implementation of Google Open Location Code(Plus+Codes)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
>= 0
 Project Readme

PlusCodes

Ruby implementation of Google Open Location Code(Plus+Codes)

Open Location Code project

Installation

Add this line to your application's Gemfile:

gem 'plus_codes'

And then execute:

$ bundle

Or install it yourself as:

$ gem install plus_codes

Usage

require 'plus_codes/open_location_code'

olc = PlusCodes::OpenLocationCode.new

# Encodes the latitude and longitude into a Plus+Codes
code = olc.encode(47.0000625,8.0000625)
# => "8FVC2222+22"

# Encodes any latitude and longitude into a Plus+Codes with preferred length
code = olc.encode(47.0000625,8.0000625, 16)
# => "8FVC2222+22GCCCCC"

# Decodes a Plus+Codes back into coordinates
code_area = olc.decode(code)
puts code_area
# => lat_lo: 47.000062496 long_lo: 8.0000625 lat_hi: 47.000062504 long_hi: 8.000062530517578 code_len: 16

# Checks if a Plus+Codes is valid or not
olc.valid?(code)
# => true

# Checks if a Plus+Codes is full or not
olc.full?(code)
# => true

# Checks if a Plus+Codes is short or not
olc.short?(code)
# => false

# Shorten a Plus+Codes as possible by given reference latitude and longitude
olc.shorten('9C3W9QCJ+2VX', 51.3708675, -1.217765625)
# => "CJ+2VX"

# Extends a Plus+Codes by given reference latitude and longitude
olc.recover_nearest('CJ+2VX', 51.3708675, -1.217765625)
# => "9C3W9QCJ+2VX"

Contributing

  1. Fork it ( https://github.com/wnameless/plus_codes-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request