geocodio-gem 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +2 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +67 -0
- data/LICENSE.txt +21 -0
- data/README.md +236 -0
- data/Rakefile +8 -0
- data/lat_long_test.csv +20 -0
- data/lib/geocodio/gem/version.rb +5 -0
- data/lib/geocodio/gem.rb +103 -0
- data/sample_list_test.csv +25 -0
- data/sig/geocodio/gem.rbs +6 -0
- metadata +60 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 119a50bd16f36e540501badeb4a66c82f0f4f86d8f44124e551a83ae16a4d694
|
|
4
|
+
data.tar.gz: ce87a20af357656d68d94436606fed4a8af1a6ce7d8bbf850bf31cc0528afbb1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 02c3e57d64f25def637909ffd69b39c3214a7bcc86ab5932384c1695aa78ccca6cd62f6cba668511d6ee272d63f4de8449d91258f3de6f34526a3b6d1940d41e
|
|
7
|
+
data.tar.gz: c9a5f6b6a41b25b25a654f7ddac1589cb25db4387e7083a0d10b52849362572f8a1ffb0503640fa234c33834bd46b479a76482e79128cf3b630b2ef4db6f6c27
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
## Our Standards
|
|
10
|
+
|
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
|
12
|
+
|
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
|
18
|
+
|
|
19
|
+
Examples of unacceptable behavior include:
|
|
20
|
+
|
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
22
|
+
advances of any kind
|
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
24
|
+
* Public or private harassment
|
|
25
|
+
* Publishing others' private information, such as a physical or email
|
|
26
|
+
address, without their explicit permission
|
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
28
|
+
professional setting
|
|
29
|
+
|
|
30
|
+
## Enforcement Responsibilities
|
|
31
|
+
|
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
33
|
+
|
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
35
|
+
|
|
36
|
+
## Scope
|
|
37
|
+
|
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
39
|
+
|
|
40
|
+
## Enforcement
|
|
41
|
+
|
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at rcorystine@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
|
43
|
+
|
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
45
|
+
|
|
46
|
+
## Enforcement Guidelines
|
|
47
|
+
|
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
|
49
|
+
|
|
50
|
+
### 1. Correction
|
|
51
|
+
|
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
|
53
|
+
|
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
55
|
+
|
|
56
|
+
### 2. Warning
|
|
57
|
+
|
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
|
59
|
+
|
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
|
61
|
+
|
|
62
|
+
### 3. Temporary Ban
|
|
63
|
+
|
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
65
|
+
|
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
|
67
|
+
|
|
68
|
+
### 4. Permanent Ban
|
|
69
|
+
|
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
71
|
+
|
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
73
|
+
|
|
74
|
+
## Attribution
|
|
75
|
+
|
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
78
|
+
|
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
|
80
|
+
|
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
|
82
|
+
|
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
# Specify your gem's dependencies in geocodio-gem.gemspec
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
gem "rake", "~> 13.0"
|
|
9
|
+
|
|
10
|
+
#TESTING
|
|
11
|
+
gem "rspec", "~> 3.0"
|
|
12
|
+
gem "webmock"
|
|
13
|
+
gem "vcr"
|
|
14
|
+
|
|
15
|
+
#API CALLS
|
|
16
|
+
gem "faraday"
|
|
17
|
+
gem "faraday-follow_redirects"
|
|
18
|
+
|
|
19
|
+
#DEBUGGING
|
|
20
|
+
gem "byebug"
|
|
21
|
+
gem "pry"
|
|
22
|
+
|
|
23
|
+
#ENV
|
|
24
|
+
gem "dotenv"
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
geocodio-gem (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
addressable (2.8.1)
|
|
10
|
+
public_suffix (>= 2.0.2, < 6.0)
|
|
11
|
+
byebug (11.1.3)
|
|
12
|
+
coderay (1.1.3)
|
|
13
|
+
crack (0.4.5)
|
|
14
|
+
rexml
|
|
15
|
+
diff-lcs (1.5.0)
|
|
16
|
+
dotenv (2.8.1)
|
|
17
|
+
faraday (2.7.1)
|
|
18
|
+
faraday-net_http (>= 2.0, < 3.1)
|
|
19
|
+
ruby2_keywords (>= 0.0.4)
|
|
20
|
+
faraday-follow_redirects (0.3.0)
|
|
21
|
+
faraday (>= 1, < 3)
|
|
22
|
+
faraday-net_http (3.0.2)
|
|
23
|
+
hashdiff (1.0.1)
|
|
24
|
+
method_source (1.0.0)
|
|
25
|
+
pry (0.14.1)
|
|
26
|
+
coderay (~> 1.1)
|
|
27
|
+
method_source (~> 1.0)
|
|
28
|
+
public_suffix (5.0.1)
|
|
29
|
+
rake (13.0.6)
|
|
30
|
+
rexml (3.2.5)
|
|
31
|
+
rspec (3.12.0)
|
|
32
|
+
rspec-core (~> 3.12.0)
|
|
33
|
+
rspec-expectations (~> 3.12.0)
|
|
34
|
+
rspec-mocks (~> 3.12.0)
|
|
35
|
+
rspec-core (3.12.0)
|
|
36
|
+
rspec-support (~> 3.12.0)
|
|
37
|
+
rspec-expectations (3.12.0)
|
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
39
|
+
rspec-support (~> 3.12.0)
|
|
40
|
+
rspec-mocks (3.12.0)
|
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
42
|
+
rspec-support (~> 3.12.0)
|
|
43
|
+
rspec-support (3.12.0)
|
|
44
|
+
ruby2_keywords (0.0.5)
|
|
45
|
+
vcr (6.1.0)
|
|
46
|
+
webmock (3.18.1)
|
|
47
|
+
addressable (>= 2.8.0)
|
|
48
|
+
crack (>= 0.3.2)
|
|
49
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
50
|
+
|
|
51
|
+
PLATFORMS
|
|
52
|
+
arm64-darwin-21
|
|
53
|
+
|
|
54
|
+
DEPENDENCIES
|
|
55
|
+
byebug
|
|
56
|
+
dotenv
|
|
57
|
+
faraday
|
|
58
|
+
faraday-follow_redirects
|
|
59
|
+
geocodio-gem!
|
|
60
|
+
pry
|
|
61
|
+
rake (~> 13.0)
|
|
62
|
+
rspec (~> 3.0)
|
|
63
|
+
vcr
|
|
64
|
+
webmock
|
|
65
|
+
|
|
66
|
+
BUNDLED WITH
|
|
67
|
+
2.3.17
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 GoldenPavilion
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# Geocodio::Gem
|
|
2
|
+
|
|
3
|
+
Geocodio Gem is a library that allows you to make quick and easy API calls to the [geocod.io](https://geocod.io) API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
8
|
+
|
|
9
|
+
$ bundle add geocodio-gem
|
|
10
|
+
|
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
12
|
+
|
|
13
|
+
$ gem install geocodio-gem
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
To get started, initialize a `Geocodio::Gem` class by passing in your API Key. If you need to generate an API Key, you can do so by logging into your Geocodio account and navigating to the [API Keys](https://dash.geocod.io/apikey) tab.
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
geocodio = Geocodio::Gem.new("YOUR_API_KEY")
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Basic Usage
|
|
24
|
+
|
|
25
|
+
### Geocoding
|
|
26
|
+
|
|
27
|
+
Forward geocoding takes an address and returns coordinates. Geocode a single address by using the `Geocodio::Gem#geocode` method. Pass in an address string within array brackets. We will parse the provided address and respond with a set of coordinates. Your results will return the most accurate locations first.
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
results = geocodio.geocode(["1109 N Highland St, Arlington, VA 22201"])
|
|
31
|
+
|
|
32
|
+
results # => {"input"=>{"address_components"=>{"number"=>"1109", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1109 N Highland St, Arlington, VA 22201"}, "results"=>[{"address_components"=>{"number"=>"1109", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1109 N Highland St, Arlington, VA 22201", "location"=>{"lat"=>38.886672, "lng"=>-77.094735}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Arlington"}]}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To batch geocode a group of addresses, pass multiple address strings into the array. The Gem will automatically recognize the batch request and make the appropriate call.
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
results = geocodio.geocode(["1109 N Highland St, Arlington, VA 22201", "12187 Darnestown Rd, Gaithersburg, MD 20878", "4961 Elm Street, Bethesda, MD"])
|
|
39
|
+
|
|
40
|
+
results # => {"results"=>[{"query"=>"1109 N Highland St, Arlington, VA 22201", "response"=>{"input"=>{"address_components"=>{"number"=>"1109", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1109 N Highland St, Arlington, VA 22201"}, "results"=>[{"address_components"=>{"number"=>"1109", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1109 N Highland St, Arlington, VA 22201", "location"=>{"lat"=>38.886672, "lng"=>-77.094735}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Arlington"}]}}, {"query"=>"12187 Darnestown Rd, Gaithersburg, MD 20878", "response"=>{"input"=>{"address_components"=>{"number"=>"12187", "street"=>"Darnestown", "suffix"=>"Rd", "formatted_street"=>"Darnestown Rd", "city"=>"Gaithersburg", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12187 Darnestown Rd, Gaithersburg, MD 20878"}, "results"=>[{"address_components"=>{"number"=>"12187", "street"=>"Darnestown", "suffix"=>"Rd", "formatted_street"=>"Darnestown Rd", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12187 Darnestown Rd, Gaithersburg, MD 20878", "location"=>{"lat"=>39.118169, "lng"=>-77.251699}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"12185", "street"=>"Darnestown", "suffix"=>"Rd", "formatted_street"=>"Darnestown Rd", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12185 Darnestown Rd, Gaithersburg, MD 20878", "location"=>{"lat"=>39.118093, "lng"=>-77.25167}, "accuracy"=>0.9, "accuracy_type"=>"nearest_rooftop_match", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"12189", "street"=>"Darnestown", "suffix"=>"Rd", "formatted_street"=>"Darnestown Rd", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12189 Darnestown Rd, Gaithersburg, MD 20878", "location"=>{"lat"=>39.118248, "lng"=>-77.251722}, "accuracy"=>0.9, "accuracy_type"=>"nearest_rooftop_match", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"12183", "street"=>"Darnestown", "suffix"=>"Rd", "formatted_street"=>"Darnestown Rd", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12183 Darnestown Rd, Gaithersburg, MD 20878", "location"=>{"lat"=>39.117998, "lng"=>-77.25164}, "accuracy"=>0.9, "accuracy_type"=>"nearest_rooftop_match", "source"=>"Montgomery"}]}}, {"query"=>"4961 Elm Street, Bethesda, MD", "response"=>{"input"=>{"address_components"=>{"number"=>"4961", "street"=>"Elm", "suffix"=>"St", "formatted_street"=>"Elm St", "city"=>"Bethesda", "state"=>"MD", "country"=>"US"}, "formatted_address"=>"4961 Elm St, Bethesda, MD"}, "results"=>[{"address_components"=>{"number"=>"4961", "street"=>"Elm", "suffix"=>"St", "formatted_street"=>"Elm St", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4961 Elm St, Bethesda, MD 20814", "location"=>{"lat"=>38.982196, "lng"=>-77.098161}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"4959", "street"=>"Elm", "suffix"=>"St", "formatted_street"=>"Elm St", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4959 Elm St, Bethesda, MD 20814", "location"=>{"lat"=>38.982198, "lng"=>-77.098084}, "accuracy"=>0.9, "accuracy_type"=>"nearest_rooftop_match", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"4963", "street"=>"Elm", "suffix"=>"St", "formatted_street"=>"Elm St", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4963 Elm St, Bethesda, MD 20814", "location"=>{"lat"=>38.98239, "lng"=>-77.097993}, "accuracy"=>0.9, "accuracy_type"=>"nearest_rooftop_match", "source"=>"Statewide MD"}, {"address_components"=>{"number"=>"4963", "street"=>"Elm", "suffix"=>"St", "formatted_street"=>"Elm St", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4963 Elm St, Bethesda, MD 20814", "location"=>{"lat"=>38.982195, "lng"=>-77.098244}, "accuracy"=>0.9, "accuracy_type"=>"nearest_rooftop_match", "source"=>"Montgomery"}]}}]}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Reverse Geocoding
|
|
44
|
+
|
|
45
|
+
Reverse geocoding takes a pair of coordinates and returns an address. Reverse geocode a single address by using the `Geocodio::Gem#reverse` method. Pass in a string that contains latitude and longitude separate by a comma. We will respond with an address associated with the coordinates. Your results will return the most accurate locations first.
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
results = geocodio.reverse(["38.9002898,-76.9990361"])
|
|
49
|
+
|
|
50
|
+
results # => {"results"=>[{"address_components"=>{"number"=>"508", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"508 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900432, "lng"=>-76.999031}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide DC"}, {"address_components"=>{"number"=>"510", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"510 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900429, "lng"=>-76.998965}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide DC"}, {"address_components"=>{"number"=>"506", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"506 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900437, "lng"=>-76.999099}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide DC"}, {"address_components"=>{"number"=>"504", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"504 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900422, "lng"=>-76.999169}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide DC"}, {"address_components"=>{"number"=>"512", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"512 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900435, "lng"=>-76.998897}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide DC"}, {"address_components"=>{"number"=>"500", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"500 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900203, "lng"=>-76.999507}, "accuracy"=>0.46, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"800", "street"=>"5th", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"5th St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"800 5th St NE, Washington, DC 20002", "location"=>{"lat"=>38.900203, "lng"=>-76.999507}, "accuracy"=>0.46, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"817", "street"=>"6th", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"6th St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"817 6th St NE, Washington, DC 20002", "location"=>{"lat"=>38.900203, "lng"=>-76.998442}, "accuracy"=>0.45, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"774", "street"=>"6th", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"6th St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"774 6th St NE, Washington, DC 20002", "location"=>{"lat"=>38.900078, "lng"=>-76.998443}, "accuracy"=>0.45, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"474", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"474 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900205, "lng"=>-76.99994}, "accuracy"=>0.44, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"540", "street"=>"I", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"I St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"540 I St NE, Washington, DC 20002", "location"=>{"lat"=>38.901323, "lng"=>-76.998836}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"900", "street"=>"5th", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"5th St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"900 5th St NE, Washington, DC 20002", "location"=>{"lat"=>38.901323, "lng"=>-76.999509}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"900", "street"=>"6th", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"6th St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"900 6th St NE, Washington, DC 20002", "location"=>{"lat"=>38.901323, "lng"=>-76.998446}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}]}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
To batch geocode a multiple sets of coordinates, pass each latitude and longitude pair as a separate string into the array. The Gem will automatically recognize the batch request and make the appropriate call.
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
results = geocode.reverse(["38.88674717512318, -77.09464642536076", "39.118308110111954, -77.2516753863881", "38.98237295882022, -77.09805507289941"])
|
|
57
|
+
|
|
58
|
+
results # => {"results"=>[{"query"=>"38.88674717512318, -77.09464642536076", "response"=>{"results"=>[{"address_components"=>{"number"=>"1109", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1109 N Highland St, Arlington, VA 22201", "location"=>{"lat"=>38.886672, "lng"=>-77.094735}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Arlington"}, {"address_components"=>{"number"=>"3030", "street"=>"Clarendon", "suffix"=>"Blvd", "formatted_street"=>"Clarendon Blvd", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"3030 Clarendon Blvd, Arlington, VA 22201", "location"=>{"lat"=>38.886876, "lng"=>-77.094702}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Arlington"}, {"address_components"=>{"number"=>"3020", "street"=>"Clarendon", "suffix"=>"Blvd", "formatted_street"=>"Clarendon Blvd", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"3020 Clarendon Blvd, Arlington, VA 22201", "location"=>{"lat"=>38.886969, "lng"=>-77.094529}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Virginia Geographic Information Network (VGIN)"}, {"address_components"=>{"number"=>"3108", "predirectional"=>"N", "street"=>"Washington", "suffix"=>"Blvd", "formatted_street"=>"N Washington Blvd", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"3108 N Washington Blvd, Arlington, VA 22201", "location"=>{"lat"=>38.885773, "lng"=>-77.094955}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"1027", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1027 N Highland St, Arlington, VA 22201", "location"=>{"lat"=>38.885598, "lng"=>-77.09476}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"3059", "predirectional"=>"N", "street"=>"Washington", "suffix"=>"Blvd", "formatted_street"=>"N Washington Blvd", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"3059 N Washington Blvd, Arlington, VA 22201", "location"=>{"lat"=>38.885574, "lng"=>-77.09456}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"1079", "predirectional"=>"N", "street"=>"Hudson", "suffix"=>"St", "formatted_street"=>"N Hudson St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1079 N Hudson St, Arlington, VA 22201", "location"=>{"lat"=>38.885785, "lng"=>-77.095693}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"3100", "street"=>"10th", "suffix"=>"Rd", "postdirectional"=>"N", "formatted_street"=>"10th Rd N", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"3100 10th Rd N, Arlington, VA 22201", "location"=>{"lat"=>38.8852, "lng"=>-77.094709}, "accuracy"=>0.42, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"1015", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1015 N Highland St, Arlington, VA 22201", "location"=>{"lat"=>38.885058, "lng"=>-77.094687}, "accuracy"=>0.41, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"1014", "predirectional"=>"N", "street"=>"Hudson", "suffix"=>"St", "formatted_street"=>"N Hudson St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1014 N Hudson St, Arlington, VA 22201", "location"=>{"lat"=>38.884985, "lng"=>-77.095586}, "accuracy"=>0.41, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"3201", "street"=>"Washington", "suffix"=>"Blvd", "formatted_street"=>"Washington Blvd", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"3201 Washington Blvd, Arlington, VA 22201", "location"=>{"lat"=>38.885989, "lng"=>-77.096909}, "accuracy"=>0.41, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}]}}, {"query"=>"39.118308110111954, -77.2516753863881", "response"=>{"results"=>[{"address_components"=>{"number"=>"12191", "street"=>"Darnestown", "suffix"=>"Rd", "formatted_street"=>"Darnestown Rd", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12191 Darnestown Rd, Gaithersburg, MD 20878", "location"=>{"lat"=>39.118326, "lng"=>-77.251749}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"12189", "street"=>"Darnestown", "suffix"=>"Rd", "formatted_street"=>"Darnestown Rd", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12189 Darnestown Rd, Gaithersburg, MD 20878", "location"=>{"lat"=>39.118248, "lng"=>-77.251722}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"12193", "street"=>"Darnestown", "suffix"=>"Rd", "formatted_street"=>"Darnestown Rd", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12193 Darnestown Rd, Gaithersburg, MD 20878", "location"=>{"lat"=>39.118376, "lng"=>-77.251707}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"12187", "street"=>"Darnestown", "suffix"=>"Rd", "formatted_street"=>"Darnestown Rd", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12187 Darnestown Rd, Gaithersburg, MD 20878", "location"=>{"lat"=>39.118169, "lng"=>-77.251699}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"12185", "street"=>"Darnestown", "suffix"=>"Rd", "formatted_street"=>"Darnestown Rd", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12185 Darnestown Rd, Gaithersburg, MD 20878", "location"=>{"lat"=>39.118093, "lng"=>-77.25167}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"12184", "street"=>"State Hwy 28", "formatted_street"=>"State Hwy 28", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12184 State Hwy 28, Gaithersburg, MD 20878", "location"=>{"lat"=>39.117781, "lng"=>-77.252536}, "accuracy"=>0.44, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"15998", "street"=>"Quince Orchard", "suffix"=>"Rd", "formatted_street"=>"Quince Orchard Rd", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"15998 Quince Orchard Rd, Gaithersburg, MD 20878", "location"=>{"lat"=>39.117888, "lng"=>-77.25293}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"12182", "street"=>"McDonald Chapel", "suffix"=>"Dr", "formatted_street"=>"McDonald Chapel Dr", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12182 McDonald Chapel Dr, Gaithersburg, MD 20878", "location"=>{"lat"=>39.119427, "lng"=>-77.251898}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"15986", "street"=>"Quince Orchard", "suffix"=>"Rd", "formatted_street"=>"Quince Orchard Rd", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"15986 Quince Orchard Rd, Gaithersburg, MD 20878", "location"=>{"lat"=>39.117709, "lng"=>-77.253041}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"12218", "street"=>"State Hwy 28", "formatted_street"=>"State Hwy 28", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12218 State Hwy 28, Gaithersburg, MD 20878", "location"=>{"lat"=>39.117983, "lng"=>-77.253546}, "accuracy"=>0.42, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"12135", "street"=>"McDonald Chapel", "suffix"=>"Dr", "formatted_street"=>"McDonald Chapel Dr", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12135 McDonald Chapel Dr, Gaithersburg, MD 20878", "location"=>{"lat"=>39.119872, "lng"=>-77.25132}, "accuracy"=>0.42, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"1036", "street"=>"State Hwy 124", "formatted_street"=>"State Hwy 124", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"1036 State Hwy 124, Gaithersburg, MD 20878", "location"=>{"lat"=>39.119961, "lng"=>-77.250987}, "accuracy"=>0.41, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"12114", "street"=>"State Hwy 28", "formatted_street"=>"State Hwy 28", "city"=>"Gaithersburg", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20878", "country"=>"US"}, "formatted_address"=>"12114 State Hwy 28, Gaithersburg, MD 20878", "location"=>{"lat"=>39.116996, "lng"=>-77.249917}, "accuracy"=>0.41, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}]}}, {"query"=>"38.98237295882022, -77.09805507289941", "response"=>{"results"=>[{"address_components"=>{"number"=>"4963", "street"=>"Elm", "suffix"=>"St", "formatted_street"=>"Elm St", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4963 Elm St, Bethesda, MD 20814", "location"=>{"lat"=>38.98239, "lng"=>-77.097993}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide MD"}, {"address_components"=>{"number"=>"4940", "street"=>"Hampden", "suffix"=>"Ln", "formatted_street"=>"Hampden Ln", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4940 Hampden Ln, Bethesda, MD 20814", "location"=>{"lat"=>38.982529, "lng"=>-77.098032}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"4959", "street"=>"Elm", "suffix"=>"St", "formatted_street"=>"Elm St", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4959 Elm St, Bethesda, MD 20814", "location"=>{"lat"=>38.982198, "lng"=>-77.098084}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"4957", "street"=>"Elm", "suffix"=>"St", "formatted_street"=>"Elm St", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4957 Elm St, Bethesda, MD 20814", "location"=>{"lat"=>38.982201, "lng"=>-77.098002}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Montgomery"}, {"address_components"=>{"number"=>"4962", "street"=>"Hampden", "suffix"=>"Ln", "formatted_street"=>"Hampden Ln", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4962 Hampden Ln, Bethesda, MD 20814", "location"=>{"lat"=>38.98247, "lng"=>-77.098252}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide MD"}, {"address_components"=>{"number"=>"4984", "street"=>"Elm", "suffix"=>"St", "formatted_street"=>"Elm St", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4984 Elm St, Bethesda, MD 20814", "location"=>{"lat"=>38.982093, "lng"=>-77.097887}, "accuracy"=>0.46, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"7300", "street"=>"Arlington", "suffix"=>"Rd", "formatted_street"=>"Arlington Rd", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"7300 Arlington Rd, Bethesda, MD 20814", "location"=>{"lat"=>38.982676, "lng"=>-77.098509}, "accuracy"=>0.46, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"5000", "street"=>"Hampden", "suffix"=>"Ln", "formatted_street"=>"Hampden Ln", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"5000 Hampden Ln, Bethesda, MD 20814", "location"=>{"lat"=>38.982676, "lng"=>-77.098509}, "accuracy"=>0.46, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"7249", "street"=>"Arlington", "suffix"=>"Rd", "formatted_street"=>"Arlington Rd", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"7249 Arlington Rd, Bethesda, MD 20814", "location"=>{"lat"=>38.982036, "lng"=>-77.098479}, "accuracy"=>0.45, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"5000", "street"=>"Elm", "suffix"=>"St", "formatted_street"=>"Elm St", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"5000 Elm St, Bethesda, MD 20814", "location"=>{"lat"=>38.982036, "lng"=>-77.09848}, "accuracy"=>0.45, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"7400", "street"=>"Arlington", "suffix"=>"Rd", "formatted_street"=>"Arlington Rd", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"7400 Arlington Rd, Bethesda, MD 20814", "location"=>{"lat"=>38.98334, "lng"=>-77.098548}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"4919", "street"=>"Montgomery", "suffix"=>"Ln", "formatted_street"=>"Montgomery Ln", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4919 Montgomery Ln, Bethesda, MD 20814", "location"=>{"lat"=>38.983371, "lng"=>-77.097503}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"4956", "street"=>"Elm", "suffix"=>"St", "formatted_street"=>"Elm St", "city"=>"Bethesda", "county"=>"Montgomery County", "state"=>"MD", "zip"=>"20814", "country"=>"US"}, "formatted_address"=>"4956 Elm St, Bethesda, MD 20814", "location"=>{"lat"=>38.982138, "lng"=>-77.096655}, "accuracy"=>0.43, "accuracy_type"=>"nearest_street", "source"=>"TIGER/Line® dataset from the US Census Bureau"}]}}]}
|
|
59
|
+
```
|
|
60
|
+
### Appending Fields
|
|
61
|
+
|
|
62
|
+
If you would like to append data fields to your results, you can do so by passing in a second array after the array that contains your addresses or coordinates. Be sure to separate these arrays by a comma. Within the second array, provide a string of the parameter name of the field you would like to append. For example, if you require timezones added to your results, you would use "timezone".
|
|
63
|
+
|
|
64
|
+
For a complete list of data field parameters, reference the [Geocodio API documentation](https://www.geocod.io/docs/?shell#fields).
|
|
65
|
+
|
|
66
|
+
This will work for both the `Geocodio::Gem#geocode` and `Geocodio::Gem#reverse` methods.
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
results = geocodio.geocode(["1109 N Highland St, Arlington, VA 22201"], ["timezone"])
|
|
70
|
+
|
|
71
|
+
results # => {"input"=>{"address_components"=>{"number"=>"1109", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1109 N Highland St, Arlington, VA 22201"}, "results"=>[{"address_components"=>{"number"=>"1109", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1109 N Highland St, Arlington, VA 22201", "location"=>{"lat"=>38.886672, "lng"=>-77.094735}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Arlington", "fields"=>{"timezone"=>{"name"=>"America/New_York", "utc_offset"=>-5, "observes_dst"=>true, "abbreviation"=>"EST", "source"=>"© OpenStreetMap contributors"}}}]}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
If you would like to append multiple data fields, pass each parameter that you require into the array as a separate string, divided by commas.
|
|
75
|
+
|
|
76
|
+
```ruby
|
|
77
|
+
results = geocodio.geocode(["1109 N Highland St, Arlington, VA 22201"], ["timezone", "stateleg"])
|
|
78
|
+
|
|
79
|
+
results # => {"input"=>{"address_components"=>{"number"=>"1109", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1109 N Highland St, Arlington, VA 22201"}, "results"=>[{"address_components"=>{"number"=>"1109", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1109 N Highland St, Arlington, VA 22201", "location"=>{"lat"=>38.886672, "lng"=>-77.094735}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Arlington", "fields"=>{"state_legislative_districts"=>{"house"=>[{"name"=>"State House District 47", "district_number"=>"47", "ocd_id"=>nil, "is_upcoming_state_legislative_district"=>false, "proportion"=>1}], "senate"=>[{"name"=>"State Senate District 31", "district_number"=>"31", "ocd_id"=>nil, "is_upcoming_state_legislative_district"=>false, "proportion"=>1}]}, "timezone"=>{"name"=>"America/New_York", "utc_offset"=>-5, "observes_dst"=>true, "abbreviation"=>"EST", "source"=>"© OpenStreetMap contributors"}}}]}
|
|
80
|
+
```
|
|
81
|
+
### Limiting Results
|
|
82
|
+
|
|
83
|
+
Some results may return a collection of different possible matches to the address or coordinates you've provided. If you would like to limit the number of results you receive, you can add a `limit` parameter that will set a maximum amount of results to be returned.
|
|
84
|
+
|
|
85
|
+
Pass in the maximum amount of results you'd prefer after your fields array as a number.
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
results = geocodio.geocode(["1120 N Highland St, Arlington, VA 22201"], [], 1)
|
|
89
|
+
|
|
90
|
+
# => {"input"=>{"address_components"=>{"number"=>"1120", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1120 N Highland St, Arlington, VA 22201"}, "results"=>[{"address_components"=>{"number"=>"1120", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1120 N Highland St, Arlington, VA 22201", "location"=>{"lat"=>38.886743, "lng"=>-77.095041}, "accuracy"=>1, "accuracy_type"=>"range_interpolation", "source"=>"TIGER/Line® dataset from the US Census Bureau"}]}
|
|
91
|
+
|
|
92
|
+
results_two = geocodio.geocode(["1120 N Highland St, Arlington, VA 22201"], [], 3)
|
|
93
|
+
|
|
94
|
+
# => {{"input"=>{"address_components"=>{"number"=>"1120", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1120 N Highland St, Arlington, VA 22201"}, "results"=>[{"address_components"=>{"number"=>"1120", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1120 N Highland St, Arlington, VA 22201", "location"=>{"lat"=>38.886743, "lng"=>-77.095041}, "accuracy"=>1, "accuracy_type"=>"range_interpolation", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"1120", "predirectional"=>"N", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"N Highland St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22201", "country"=>"US"}, "formatted_address"=>"1120 N Highland St, Arlington, VA 22201", "location"=>{"lat"=>38.886743, "lng"=>-77.09474}, "accuracy"=>0.9, "accuracy_type"=>"range_interpolation", "source"=>"TIGER/Line® dataset from the US Census Bureau"}, {"address_components"=>{"number"=>"1120", "predirectional"=>"S", "street"=>"Highland", "suffix"=>"St", "formatted_street"=>"S Highland St", "city"=>"Arlington", "county"=>"Arlington County", "state"=>"VA", "zip"=>"22204", "country"=>"US"}, "formatted_address"=>"1120 S Highland St, Arlington, VA 22204", "location"=>{"lat"=>38.860865, "lng"=>-77.089447}, "accuracy"=>0.8, "accuracy_type"=>"rooftop", "source"=>"Arlington"}]}}
|
|
95
|
+
|
|
96
|
+
results["results"].length # => 1
|
|
97
|
+
results_two["results"].length # => 3
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
In this example, you can see that by limiting the `results` to 1, we only receive the first element of the returned array. When we limit the `results_two` to 3 in the second example, we receive the first three elements in the array.
|
|
101
|
+
|
|
102
|
+
If you would rather not limit your results at all, you can enter `nil` or leave the third parameter blank.
|
|
103
|
+
|
|
104
|
+
You can also limit `reverse` geocode requests.
|
|
105
|
+
|
|
106
|
+
```ruby
|
|
107
|
+
results = geocodio.reverse(["38.9002898,-76.9990361"], [], 1)
|
|
108
|
+
|
|
109
|
+
# => {"results"=>[{"address_components"=>{"number"=>"508", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"508 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900432, "lng"=>-76.999031}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide DC"}]}
|
|
110
|
+
|
|
111
|
+
results_two = geocodio.reverse(["38.9002898,-76.9990361"], [], 4)
|
|
112
|
+
|
|
113
|
+
# => {"results"=>[{"address_components"=>{"number"=>"508", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"508 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900432, "lng"=>-76.999031}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide DC"}, {"address_components"=>{"number"=>"510", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"510 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900429, "lng"=>-76.998965}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide DC"}, {"address_components"=>{"number"=>"506", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"506 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900437, "lng"=>-76.999099}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide DC"}, {"address_components"=>{"number"=>"504", "street"=>"H", "suffix"=>"St", "postdirectional"=>"NE", "formatted_street"=>"H St NE", "city"=>"Washington", "county"=>"District of Columbia", "state"=>"DC", "zip"=>"20002", "country"=>"US"}, "formatted_address"=>"504 H St NE, Washington, DC 20002", "location"=>{"lat"=>38.900422, "lng"=>-76.999169}, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide DC"}]}
|
|
114
|
+
|
|
115
|
+
results["results"].length # => 1
|
|
116
|
+
results_two["results"].length # => 4
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Simple Formatting
|
|
120
|
+
|
|
121
|
+
The `simple` format parameter returns an alternative JSON response that is simplified and only includes the formatted address, lat, long, accuracy and source fields.
|
|
122
|
+
|
|
123
|
+
To receive a `simple` response, include the string `"simple"` as the fourth argument after any limit you have set.
|
|
124
|
+
|
|
125
|
+
Currently, the `simple` format only works with single `geocode` and `reverse` input. It does not support batch requests.
|
|
126
|
+
|
|
127
|
+
```ruby
|
|
128
|
+
## EXAMPLE: Forward geocoding simple formatting without data appends or limit.
|
|
129
|
+
|
|
130
|
+
response = geocodio.geocode(["1109 N Highland St, Arlington, VA 22201"], [], nil, "simple")
|
|
131
|
+
|
|
132
|
+
response # => {"address"=>"1109 N Highland St, Arlington, VA 22201", "lat"=>38.886672, "lng"=>-77.094735, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Arlington"}
|
|
133
|
+
|
|
134
|
+
## EXAMPLE: Reverse geocoding simple formatting with school appends and limit of 1.
|
|
135
|
+
|
|
136
|
+
response = geocodio.reverse(["38.9002898,-76.9990361"], ["school"], 1, "simple"))
|
|
137
|
+
|
|
138
|
+
response # => {"address"=>"508 H St NE, Washington, DC 20002", "lat"=>38.900432, "lng"=>-76.999031, "accuracy"=>1, "accuracy_type"=>"rooftop", "source"=>"Statewide DC", "fields"=>{"school_districts"=>{"unified"=>{"name"=>"District of Columbia Public Schools", "lea_code"=>"1100030", "grade_low"=>"PK", "grade_high"=>"12"}}}}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Lists API
|
|
142
|
+
|
|
143
|
+
The Geocodio Lists API allows you to upload and process a spreadsheet with addresses or coordinates. This is very similar to our [Spreadsheet Uploader]("https://geocod.io/upload") tool. While your spreadsheet is being processed, you can also query the status of its current progress, download the final result or delete it from your records.
|
|
144
|
+
|
|
145
|
+
You will continue to use the `Geocodio##Gem` class you created in the Setup portion so that you can access the Lists API methods.
|
|
146
|
+
|
|
147
|
+
### Create A List
|
|
148
|
+
|
|
149
|
+
Create a new spreadsheet list job by utilizing the `createList()` method. To upload a spreadsheet file, pass following arguments into the method:
|
|
150
|
+
- file: The location of the file to be geocoded.
|
|
151
|
+
- filename: File extension is used to determine the file format. Valid formats include: CSV, TSV, XLS, XLSX.
|
|
152
|
+
- direction: Identify whether you will be `forward` geocoding or `reverse` geocoding.
|
|
153
|
+
- format: Provide a template for how addresses or coordinates should be read from the spreadsheet. For example:
|
|
154
|
+
- Full address in column A: {{A}}
|
|
155
|
+
- Street adresses in column A, Zip in column D: {{A}} {{D}}
|
|
156
|
+
- Street name in A, City in B, State in C, Zip in D: {{A}} {{B}} {{C}} {{D}}
|
|
157
|
+
- [More examples here.]("https://www.geocod.io/docs/?shell#create-a-new-list")
|
|
158
|
+
- callback: Optional parameter. A valid URL that a webhook should be sent to upon completion of the spreadsheet geocoding job.
|
|
159
|
+
|
|
160
|
+
```ruby
|
|
161
|
+
response = geocodio.createList(File.read("sample_list_test.csv"), "sample_list_test.csv", "forward", "{{A}} {{B}} {{C}} {{D}}")
|
|
162
|
+
|
|
163
|
+
response # => {"id"=>11599178, "file"=>{"headers"=>["address", "city", "state", "zip"], "estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}}
|
|
164
|
+
```
|
|
165
|
+
### Check List Status
|
|
166
|
+
|
|
167
|
+
To check the current status of your List API spreadsheet upload, use the `getList()` method. Pass in the ID generated when you created your List to identify which list you'd like to check.
|
|
168
|
+
|
|
169
|
+
```ruby
|
|
170
|
+
response = geocodio.getList(11599178)
|
|
171
|
+
|
|
172
|
+
response # => {"id"=>11599178, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-10T23:33:01.000000Z"}
|
|
173
|
+
```
|
|
174
|
+
### Check All Lists
|
|
175
|
+
|
|
176
|
+
If you'd like to see all of the list jobs that you have created, use the `getAllLists` method. You don't need to pass anything as an argument. The endpoint is paginated, showing 15 lists at a time, ordered by most recent.
|
|
177
|
+
|
|
178
|
+
```ruby
|
|
179
|
+
response = geocodio.getAllLists
|
|
180
|
+
|
|
181
|
+
response # => {"current_page"=>1, "data"=>[{"id"=>11603086, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>"https://api.geocod.io/v1.7/lists/11603086/download", "expires_at"=>"2022-12-22T22:54:23.000000Z"}, {"id"=>11603084, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>"https://api.geocod.io/v1.7/lists/11603084/download", "expires_at"=>"2022-12-22T22:49:49.000000Z"}, {"id"=>11602633, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-22T02:33:39.000000Z"}, {"id"=>11600845, "fields"=>[], "file"=>{"estimated_rows_count"=>19, "filename"=>"lat_long_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-16T17:17:40.000000Z"}, {"id"=>11600844, "fields"=>[], "file"=>{"estimated_rows_count"=>19, "filename"=>"lat_long_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-16T17:17:39.000000Z"}, {"id"=>11600843, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-16T17:17:38.000000Z"}, {"id"=>11599180, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-10T23:34:12.000000Z"}, {"id"=>11599179, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-10T23:33:47.000000Z"}, {"id"=>11599178, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-10T23:33:01.000000Z"}, {"id"=>11599053, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-10T20:03:41.000000Z"}, {"id"=>11599051, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-10T20:03:19.000000Z"}, {"id"=>11599050, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-10T20:03:18.000000Z"}, {"id"=>11598977, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-10T17:29:55.000000Z"}, {"id"=>11598976, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-10T17:29:52.000000Z"}, {"id"=>11598973, "fields"=>[], "file"=>{"estimated_rows_count"=>24, "filename"=>"sample_list_test.csv"}, "status"=>{"state"=>"COMPLETED", "progress"=>100, "message"=>"Completed", "time_left_description"=>nil, "time_left_seconds"=>nil}, "download_url"=>nil, "expires_at"=>"2022-12-10T17:29:14.000000Z"}], "first_page_url"=>"https://api.geocod.io/v1.7/lists?page=1", "from"=>1, "next_page_url"=>"https://api.geocod.io/v1.7/lists?page=2", "path"=>"https://api.geocod.io/v1.7/lists", "per_page"=>15, "prev_page_url"=>nil, "to"=>15}
|
|
182
|
+
```
|
|
183
|
+
### Download A List
|
|
184
|
+
|
|
185
|
+
Download a spreadsheet file by using the `downloadList()` method. Pass in the ID you received during list creation to identify the list you would like to download. If the spreadsheet is finished processing, you will be redirected to a link that will automatically download the file.
|
|
186
|
+
|
|
187
|
+
```ruby
|
|
188
|
+
response = geocodio.downloadList(id)
|
|
189
|
+
|
|
190
|
+
If the file is finished processing:
|
|
191
|
+
|
|
192
|
+
response # => [address,city,state,zip,Latitude,Longitude,"Accuracy Score","Accuracy Type",Number,Street,"Unit Type","Unit Number",City,State,County,Zip,Country,Source], ["660 Pennsylvania Ave SE",Washington,DC,20003,38.885172,-76.996565,1,rooftop,660,"Pennsylvania Ave SE",,,Washington,DC,"District of Columbia",20003,US,Statewide],["1718 14th St NW",Washington,DC,20009,38.913274,-77.032266,1,rooftop,1718,"14th St NW",,,Washington,DC,"District of Columbia",20009,US,Statewide], ["1309 5th St NE",,,20002,38.908724,-76.997653,0.9,rooftop,1309,"5th St NE",,,Washington,DC,"District of Columbia",20002,US,Statewide], ["2150 P St NW",,,20037,38.90948,-77.048527,1,rooftop,2150,"P St NW",,,Washington,DC,"District of Columbia",20037,US,Statewide],["201 F Street NE",,,20002,38.897139,-77.003286,0.9,rooftop,201,"F St NE",,,Washington,DC,"District of Columbia",20002,US,Statewide],["1001 2nd St SE",,,20003,38.877737,-77.003695,1,rooftop,1001,"2nd St SE",,,Washington,DC,"District of Columbia",20003,US,Statewide],["1645 Wisconsin Avenue NW",Washington,DC,20007,38.911626,-77.065281,1,rooftop,1645,"Wisconsin Ave NW",,,Washington,DC,"District of Columbia",20007,US,Statewide],["820 East Baltimore Street",Baltimore,MD,21202,39.290427,-76.60485,1,rooftop,820,"E Baltimore St",,,Baltimore,MD,"Baltimore City",21202,US,"City of Baltimore"],["800 F St NW",Washington,DC,20001,38.896987,-77.023286,1,rooftop,800,"F St NW",,,Washington,DC,"District of Columbia",20004,US,Statewide],["700 Constitution Avenue NW",Washington,DC,20565,38.892228,-77.0219,0.9,range_interpolation,700,"Constitution Ave NW",,,Washington,DC,"District of Columbia",20002,US,"TIGER/Line® dataset from the US Census Bureau"],["1123 Pennsylvania Ave SE",Washington,DC,20003,38.882097,-76.990714,1,rooftop,1123,"Pennsylvania Ave SE",,,Washington,DC,"District of Columbia",20003,US,Statewide],["621 Pennsylvania Ave SE",Washington,DC,20003,38.884906,-76.997682,1,rooftop,621,"Pennsylvania Ave SE",,,Washington,DC,"District of Columbia",20003,US,Statewide],["1702 G Street NW",Washington,DC,20006,38.89816,-77.039982,1,rooftop,1702,"G St NW",,,Washington,DC,"District of Columbia",20006,US,Statewide],["701 8th St SE",Washington,DC,20003,38.881115,-76.995245,1,rooftop,701,"8th St SE",,,Washington,DC,"District of Columbia",20003,US,Statewide],["12187 Darnestown Rd",Gaithersburg,MD,20878,39.118169,-77.251699,1,rooftop,12187,"Darnestown Rd",,,Gaithersburg,MD,"Montgomery County",20878,US,Montgomery],["4961 Elm Street",Bethesda,MD,,38.982196,-77.098161,1,rooftop,4961,"Elm St",,,Bethesda,MD,"Montgomery County",20814,US,Montgomery],["3064 Mount Pleasant St NW",Washington,DC,,38.92846,-77.037509,1,rooftop,3064,"Mt Pleasant St NW",,,Washington,DC,"District of Columbia",20009,US,Statewide],["1052 Thomas Jefferson Street NW",Washington,DC,,38.903887,-77.060437,1,rooftop,1052,"Thomas Jefferson St NW",,,Washington,DC,"District of Columbia",20007,US,Statewide],["475 H St NW",Washington,DC,,38.900078,-77.018645,1,rooftop,475,"H St NW",,,Washington,DC,"District of Columbia",20001,US,Statewide],["1301 U St NW",Washington,DC,,38.917294,-77.03052,1,rooftop,1301,"U St NW",,,Washington,DC,"District of Columbia",20009,US,Statewide],["1726 20th Street, NW",Washington,DC,,38.913694,-77.045095,1,rooftop,1726,"20th St NW",,,Washington,DC,"District of Columbia",20009,US,Statewide],["1916 I Street, NW",Washington,DC,,38.90115,-77.044172,1,rooftop,1916,"I St NW",,,Washington,DC,"District of Columbia",20006,US,Statewide],["107 Church St NE",Vienna,VA,,38.902565,-77.265693,1,rooftop,107,"Church St NE",,,Vienna,VA,"Fairfax County",22180,US,Fairfax],["4817 Bethesda Ave",Bethesda,MD,20814,38.981067,-77.096506,1,rooftop,4817,"Bethesda Ave",,,Bethesda,MD,"Montgomery County",20814,US,Montgomery]
|
|
193
|
+
|
|
194
|
+
If the file is not finished processing:
|
|
195
|
+
|
|
196
|
+
response # => {
|
|
197
|
+
"message": "List is still processing",
|
|
198
|
+
"success": false
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Delete A List
|
|
203
|
+
|
|
204
|
+
Delete an existing list by utilizing the `deleteList()` method. If the job is complete, this will delete both the list data and the spreadsheet data contained within. The spreadsheet data will be automatically deleted in 72 hours if it is not manually deleted using `deleteList()`.
|
|
205
|
+
|
|
206
|
+
You can also use this method to cancel a current list job while it is still processing. Geocodio Unlimited customers can cancel a spreadsheet at any time, while Pay-As-You-Go customers can only do so if the spreadsheet job was started recently.
|
|
207
|
+
|
|
208
|
+
To use `deleteList()`, pass in the ID of the list you would like to delete.
|
|
209
|
+
|
|
210
|
+
```ruby
|
|
211
|
+
response = geocodio.deleteList(11599181)
|
|
212
|
+
|
|
213
|
+
response # => {"success"=>true}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Testing
|
|
217
|
+
|
|
218
|
+
To run tests, be sure to create a `.env` file that export your Geocodio API Key within a variable of API_KEY.
|
|
219
|
+
|
|
220
|
+
```ruby
|
|
221
|
+
export API_KEY=<YOUR API KEY>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Then, run `rspec`.
|
|
225
|
+
|
|
226
|
+
```ruby
|
|
227
|
+
rspec
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Changelog
|
|
231
|
+
|
|
232
|
+
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
|
|
233
|
+
|
|
234
|
+
## License
|
|
235
|
+
|
|
236
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/lat_long_test.csv
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Latitude,Longitude,,,,,
|
|
2
|
+
38.8886262809655,-77.0165386458959,,,,,
|
|
3
|
+
38.8883882115863,-77.0198276082111,,,,,
|
|
4
|
+
38.8891899038527,-77.0199992695837,,,,,
|
|
5
|
+
38.886350536353,-77.0211109612279,,,,,
|
|
6
|
+
38.8844010178023,-77.0255355942621,,,,,
|
|
7
|
+
38.888332492042,-77.0254521107444,,,,,
|
|
8
|
+
38.8890797724534,-77.0259738835079,,,,,
|
|
9
|
+
38.8915489909506,-77.0257443034919,,,,,
|
|
10
|
+
38.8883812279607,-77.0273304926929,,,,,
|
|
11
|
+
38.888348737352,-77.0273304926929,,,,,
|
|
12
|
+
38.891681936895,-77.0326497048902,,,,,
|
|
13
|
+
39.3506842577113,-76.6211688308013,,,,,
|
|
14
|
+
39.328085935215,-76.6200000598111,,,,,
|
|
15
|
+
39.3140067165994,-76.5961237381548,,,,,
|
|
16
|
+
39.2818423681824,-76.6070446000219,,,,,
|
|
17
|
+
39.2868182724211,-76.6080089058459,,,,,
|
|
18
|
+
39.2753731641967,-76.6022230709016,,,,,
|
|
19
|
+
39.2949117273769,-76.6323515144706,,,,,
|
|
20
|
+
39.2976382021164,-76.6160833127033,,,,,
|
data/lib/geocodio/gem.rb
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require_relative "gem/version"
|
|
2
|
+
require "faraday"
|
|
3
|
+
require "faraday/follow_redirects"
|
|
4
|
+
require "csv"
|
|
5
|
+
|
|
6
|
+
module Geocodio
|
|
7
|
+
|
|
8
|
+
class Error < StandardError; end
|
|
9
|
+
|
|
10
|
+
class Gem
|
|
11
|
+
attr_reader :api_key
|
|
12
|
+
|
|
13
|
+
def initialize(api_key)
|
|
14
|
+
@api_key = api_key
|
|
15
|
+
|
|
16
|
+
@conn = Faraday.new(
|
|
17
|
+
url: 'https://api.geocod.io/v1.7/',
|
|
18
|
+
headers: {'Content-Type' => 'application/json' }
|
|
19
|
+
) do |f|
|
|
20
|
+
f.response :follow_redirects
|
|
21
|
+
f.adapter Faraday.default_adapter
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def geocode(query=[], fields=[], limit=nil, format=nil)
|
|
26
|
+
if query.size < 1
|
|
27
|
+
raise ArgumentError, 'Please provide at least one address to geocode.'
|
|
28
|
+
elsif query.size == 1
|
|
29
|
+
response = JSON.parse(@conn.get('geocode', { q: query.join(""), fields: fields.join(","), limit: limit, format: format, api_key: @api_key }).body)
|
|
30
|
+
return response
|
|
31
|
+
elsif query.size > 1
|
|
32
|
+
response = @conn.post('geocode') do |req|
|
|
33
|
+
req.params = { fields: fields.join(","), limit: limit, api_key: @api_key }
|
|
34
|
+
req.headers['Content-Type'] = 'application/json'
|
|
35
|
+
req.body = query.to_json
|
|
36
|
+
end
|
|
37
|
+
parsed = JSON.parse(response.body)
|
|
38
|
+
return parsed
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def reverse(query=[], fields=[], limit=nil, format=nil)
|
|
43
|
+
if query.size < 1
|
|
44
|
+
raise ArgumentError, 'Please provide at least one set of coordinates to geocode.'
|
|
45
|
+
elsif query.size == 1
|
|
46
|
+
response = JSON.parse(@conn.get('reverse', { q: query.join(""), fields: fields.join(","), limit: limit, format: format, api_key: @api_key}).body)
|
|
47
|
+
return response
|
|
48
|
+
elsif query.size > 1
|
|
49
|
+
response = @conn.post('reverse') do |req|
|
|
50
|
+
req.params = { fields: fields.join(","), limit: limit, api_key: @api_key }
|
|
51
|
+
req.headers['Content-Type'] = 'application/json'
|
|
52
|
+
req.body = query.to_json
|
|
53
|
+
end
|
|
54
|
+
parsed = JSON.parse(response.body)
|
|
55
|
+
return parsed
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def createList(file, filename, direction, format, callback = nil)
|
|
60
|
+
response = @conn.post('lists') do |req|
|
|
61
|
+
req.params = {
|
|
62
|
+
api_key: @api_key,
|
|
63
|
+
file: file,
|
|
64
|
+
filename: filename,
|
|
65
|
+
direction: direction,
|
|
66
|
+
format: format,
|
|
67
|
+
callback: callback
|
|
68
|
+
}
|
|
69
|
+
req.headers['Content-Type'] = 'application/json'
|
|
70
|
+
end
|
|
71
|
+
parsed = JSON.parse(response.body)
|
|
72
|
+
return parsed
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def getList(id)
|
|
76
|
+
response = JSON.parse(@conn.get("lists/#{id}", { api_key: @api_key }).body)
|
|
77
|
+
return response
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def getAllLists
|
|
81
|
+
response = JSON.parse(@conn.get("lists", { api_key: @api_key}).body)
|
|
82
|
+
return response
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def downloadList(id)
|
|
86
|
+
response = @conn.get("lists/#{id}/download", { api_key: @api_key})
|
|
87
|
+
|
|
88
|
+
if (response.headers["content-type"] == "application/json")
|
|
89
|
+
return JSON.parse(response.body)
|
|
90
|
+
else
|
|
91
|
+
return CSV.parse(response.body.force_encoding("UTF-8"))
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def deleteList(id)
|
|
96
|
+
response = JSON.parse(@conn.delete("lists/#{id}", { api_key: @api_key}).body)
|
|
97
|
+
return response
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
#TODO: Look into filter_sensitive_data
|
|
103
|
+
#Add sample_list_test.csv to repo
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
address,city,state,zip
|
|
2
|
+
660 Pennsylvania Ave SE,Washington,DC,20003
|
|
3
|
+
1718 14th St NW,Washington,DC,20009
|
|
4
|
+
1309 5th St NE,,,20002
|
|
5
|
+
2150 P St NW,,,20037
|
|
6
|
+
201 F Street NE,,,20002
|
|
7
|
+
1001 2nd St SE,,,20003
|
|
8
|
+
1645 Wisconsin Avenue NW,Washington,DC,20007
|
|
9
|
+
820 East Baltimore Street,Baltimore,MD,21202
|
|
10
|
+
800 F St NW,Washington,DC,20001
|
|
11
|
+
700 Constitution Avenue NW,Washington,DC,20565
|
|
12
|
+
1123 Pennsylvania Ave SE,Washington,DC,20003
|
|
13
|
+
621 Pennsylvania Ave SE,Washington,DC,20003
|
|
14
|
+
1702 G Street NW,Washington,DC,20006
|
|
15
|
+
701 8th St SE,Washington,DC,20003
|
|
16
|
+
12187 Darnestown Rd,Gaithersburg,MD,20878
|
|
17
|
+
4961 Elm Street,Bethesda,MD,
|
|
18
|
+
3064 Mount Pleasant St NW,Washington,DC,
|
|
19
|
+
1052 Thomas Jefferson Street NW,Washington,DC,
|
|
20
|
+
475 H St NW,Washington,DC,
|
|
21
|
+
1301 U St NW,Washington,DC,
|
|
22
|
+
"1726 20th Street, NW",Washington,DC,
|
|
23
|
+
"1916 I Street, NW",Washington,DC,
|
|
24
|
+
107 Church St NE,Vienna,VA,
|
|
25
|
+
4817 Bethesda Ave,Bethesda,MD,20814
|
metadata
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: geocodio-gem
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- GoldenPavilion
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A Ruby Gem to help you integrate your application with the Geocodio API.
|
|
14
|
+
email:
|
|
15
|
+
- cory@geocod.io
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- ".rspec"
|
|
21
|
+
- CHANGELOG.md
|
|
22
|
+
- CODE_OF_CONDUCT.md
|
|
23
|
+
- Gemfile
|
|
24
|
+
- Gemfile.lock
|
|
25
|
+
- LICENSE.txt
|
|
26
|
+
- README.md
|
|
27
|
+
- Rakefile
|
|
28
|
+
- lat_long_test.csv
|
|
29
|
+
- lib/geocodio/gem.rb
|
|
30
|
+
- lib/geocodio/gem/version.rb
|
|
31
|
+
- sample_list_test.csv
|
|
32
|
+
- sig/geocodio/gem.rbs
|
|
33
|
+
homepage: https://www.geocod.io/docs
|
|
34
|
+
licenses:
|
|
35
|
+
- MIT
|
|
36
|
+
metadata:
|
|
37
|
+
allowed_push_host: https://rubygems.org
|
|
38
|
+
homepage_uri: https://www.geocod.io/docs
|
|
39
|
+
source_code_uri: https://www.github.com/Geocodio/geocodio-gem/
|
|
40
|
+
changelog_uri: https://www.github.com/Geocodio/geocodio-gem/CHANGELOD.md
|
|
41
|
+
post_install_message:
|
|
42
|
+
rdoc_options: []
|
|
43
|
+
require_paths:
|
|
44
|
+
- lib
|
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: 2.6.0
|
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
requirements: []
|
|
56
|
+
rubygems_version: 3.3.17
|
|
57
|
+
signing_key:
|
|
58
|
+
specification_version: 4
|
|
59
|
+
summary: Geocodio Ruby Library.
|
|
60
|
+
test_files: []
|