{"id":18539698,"url":"https://github.com/jiren/open_location_code","last_synced_at":"2025-05-15T02:35:52.029Z","repository":{"id":32851072,"uuid":"36444717","full_name":"jiren/open_location_code","owner":"jiren","description":"Open Location Codes are a way of encoding location into a form that is easier to use than latitude and longitude. Ref:  https://github.com/google/open-location-code","archived":false,"fork":false,"pushed_at":"2015-06-02T09:47:25.000Z","size":152,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T00:03:21.234Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jiren.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-28T14:39:41.000Z","updated_at":"2015-05-29T08:28:18.000Z","dependencies_parsed_at":"2022-07-24T17:32:07.325Z","dependency_job_id":null,"html_url":"https://github.com/jiren/open_location_code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiren%2Fopen_location_code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiren%2Fopen_location_code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiren%2Fopen_location_code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiren%2Fopen_location_code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiren","download_url":"https://codeload.github.com/jiren/open_location_code/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254263253,"owners_count":22041569,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T19:49:29.552Z","updated_at":"2025-05-15T02:35:52.007Z","avatar_url":"https://github.com/jiren.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenLocationCode\n\nOpen Location Codes are a way of encoding location into a form that is\neasier to use than latitude and longitude.\n\nRef:  https://github.com/google/open-location-code\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'open_location_code'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install open_location_code\n\n## Usage\n\n```ruby\ncode = OpenLocationCode.encode(47.365590, 8.524997) # 8FVC9G8F+6X\ncode = OpenLocationCode.encode(47.365590, 8.524997, 12) #8FVC9G8F+6XQH\n \ncode_area = OpenLocationCode.decode('8FVC9G8F+6XQH')\n#\u003cOpenLocationCode::CodeArea:0x007fe7eb050110 @latitude_lo=47.36557499999997, @longitude_lo=8.524968750000008, @latitude_hi=47.36557499999997, @longitude_hi=8.52500000000001, @code_length=12, @latitude_center=47.36557499999997, @longitude_center=8.52498437500001\u003e\n```\n\n## Rails\n\n  Include `Olc` module and call `has_olc` method\n\n  `has_olc` has default options `{ field: 'open_location_code', latitude: 'latitude', longitude: 'longitude', code_length: 10 }`\n\n\n- ActiveRecord\n\n  Generate migration to add latitude, longitude and open_location_code fields.\n\n```\n  rails g migration add_olc_fields_to_events latitude:float longitude:float open_location_code:string\n```\n\n  In Model:\n\n```ruby\nclass Event \u003c\u003c ActiveRecord::Base\n  include Olc\n\n  has_olc\n\n  # If fields not same as default options\n  has_olc(field: 'olc', latitude: 'lat', longitude: 'lng', code_length: 10)\nend\n```\n\n- Mongoid\n\n  `has_olc` will define field based on passed options[:field] value.\n\n```ruby\nclass Event\n  include Mongoid::Document\n  include Olc\n      \n  field :latitude,   type: Float\n  field :longitude,  type: Float\n\n  has_olc\nend\n```\n\n  \n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\n1. Fork it ( https://github.com/jiren/open_location_code )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiren%2Fopen_location_code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiren%2Fopen_location_code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiren%2Fopen_location_code/lists"}