geocoder 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of geocoder might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +8 -2
- data/lib/geocoder/lookup.rb +1 -0
- data/lib/geocoder/lookups/google.rb +3 -3
- data/lib/geocoder/lookups/google_places_search.rb +33 -0
- data/lib/geocoder/results/google_places_search.rb +52 -0
- data/lib/geocoder/results/yandex.rb +34 -0
- data/lib/geocoder/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f394e733415900303ed8be35b91692886c134ffb
|
4
|
+
data.tar.gz: 21211fb7e4b78a3f957923fabe959af3e9073c4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 628aa577898b95b9a5674f2b8f97452c04744eebbe80af4a90372f5461bde24a217408dc5c06b2e99213907ee91e4beead63e51cf69e0631a1b6b42a7085e7f7
|
7
|
+
data.tar.gz: fad11275dbbcc8a897b9d5b9231ceb543d0b81341745aaadd5033f93950af21cf04ea2bb93f0c8242d7c81a317b1eccf4be984d2b3bae9c3cb879b1fac02510a
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@ Changelog
|
|
3
3
|
|
4
4
|
Major changes to Geocoder for each release. Please see the Git log for complete list of changes.
|
5
5
|
|
6
|
+
1.4.3 (2017 Feb 7)
|
7
|
+
-------------------
|
8
|
+
* Add :google_places_search lookup (thanks github.com/waruboy).
|
9
|
+
|
6
10
|
1.4.2 (2017 Jan 31)
|
7
11
|
-------------------
|
8
12
|
* Fix bug that caused Model.near to return an incorrect query in some cases.
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ _Please note that this README is for the current `HEAD` and may document feature
|
|
9
9
|
Compatibility
|
10
10
|
-------------
|
11
11
|
|
12
|
-
* Supports multiple Ruby versions: Ruby 1.9.3, 2.x,
|
12
|
+
* Supports multiple Ruby versions: Ruby 1.9.3, 2.x, and JRuby.
|
13
13
|
* Supports multiple databases: MySQL, PostgreSQL, SQLite, and MongoDB (1.7.0 and higher).
|
14
14
|
* Supports Rails 3, 4, and 5. If you need to use it with Rails 2 please see the `rails2` branch (no longer maintained, limited feature set).
|
15
15
|
* Works very well outside of Rails, you just need to install either the `json` (for MRI) or `json_pure` (for JRuby) gem.
|
@@ -422,7 +422,7 @@ Similar to `:google`, with the following differences:
|
|
422
422
|
|
423
423
|
#### Google Places Details (`:google_places_details`)
|
424
424
|
|
425
|
-
The [Google Places Details API](https://developers.google.com/places/documentation/details) is not, strictly speaking, a geocoding service. It accepts a Google `place_id` and returns address information, ratings and reviews. A `place_id` can be obtained from the Google Places
|
425
|
+
The [Google Places Details API](https://developers.google.com/places/documentation/details) is not, strictly speaking, a geocoding service. It accepts a Google `place_id` and returns address information, ratings and reviews. A `place_id` can be obtained from the Google Places Search lookup (`:google_places_search`) and should be passed to Geocoder as the first search argument: `Geocoder.search("ChIJhRwB-yFawokR5Phil-QQ3zM", lookup: :google_places_details)`.
|
426
426
|
|
427
427
|
* **API key**: required
|
428
428
|
* **Key signup**: https://code.google.com/apis/console/
|
@@ -434,6 +434,12 @@ The [Google Places Details API](https://developers.google.com/places/documentati
|
|
434
434
|
* **Terms of Service**: https://developers.google.com/places/policies
|
435
435
|
* **Limitations**: "If your application displays Places API data on a page or view that does not also display a Google Map, you must show a "Powered by Google" logo with that data."
|
436
436
|
|
437
|
+
#### Google Places Search (`:google_places_search`)
|
438
|
+
|
439
|
+
The [Google Places Search API](https://developers.google.com/places/web-service/search) is the geocoding service of Google Places API. It returns very limited location data, but it also returns a `place_id` which can be used with Google Place Details to get more detailed information. For a comparison between this and the regular Google Geocoding API, see https://maps-apis.googleblog.com/2016/11/address-geocoding-in-google-maps-apis.html
|
440
|
+
|
441
|
+
* Same specifications as Google Places Details (see above).
|
442
|
+
|
437
443
|
#### Bing (`:bing`)
|
438
444
|
|
439
445
|
* **API key**: required (set `Geocoder.configure(:lookup => :bing, :api_key => key)`)
|
data/lib/geocoder/lookup.rb
CHANGED
@@ -50,13 +50,13 @@ module Geocoder::Lookup
|
|
50
50
|
return doc['results']
|
51
51
|
when "OVER_QUERY_LIMIT"
|
52
52
|
raise_error(Geocoder::OverQueryLimitError) ||
|
53
|
-
Geocoder.log(:warn, "
|
53
|
+
Geocoder.log(:warn, "#{name} API error: over query limit.")
|
54
54
|
when "REQUEST_DENIED"
|
55
55
|
raise_error(Geocoder::RequestDenied) ||
|
56
|
-
Geocoder.log(:warn, "
|
56
|
+
Geocoder.log(:warn, "#{name} API error: request denied.")
|
57
57
|
when "INVALID_REQUEST"
|
58
58
|
raise_error(Geocoder::InvalidRequest) ||
|
59
|
-
Geocoder.log(:warn, "
|
59
|
+
Geocoder.log(:warn, "#{name} API error: invalid request.")
|
60
60
|
end
|
61
61
|
return []
|
62
62
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "geocoder/lookups/google"
|
2
|
+
require "geocoder/results/google_places_search"
|
3
|
+
|
4
|
+
module Geocoder
|
5
|
+
module Lookup
|
6
|
+
class GooglePlacesSearch < Google
|
7
|
+
def name
|
8
|
+
"Google Places Search"
|
9
|
+
end
|
10
|
+
|
11
|
+
def required_api_key_parts
|
12
|
+
["key"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def supported_protocols
|
16
|
+
[:https]
|
17
|
+
end
|
18
|
+
|
19
|
+
def query_url(query)
|
20
|
+
"#{protocol}://maps.googleapis.com/maps/api/place/textsearch/json?#{url_query_string(query)}"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def query_url_google_params(query)
|
26
|
+
{
|
27
|
+
query: query.text,
|
28
|
+
language: query.language || configuration.language
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "geocoder/results/google"
|
2
|
+
|
3
|
+
module Geocoder
|
4
|
+
module Result
|
5
|
+
class GooglePlacesSearch < Google
|
6
|
+
|
7
|
+
def types
|
8
|
+
@data["types"] || []
|
9
|
+
end
|
10
|
+
|
11
|
+
def rating
|
12
|
+
@data["rating"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def photos
|
16
|
+
@data["photos"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def city
|
20
|
+
""
|
21
|
+
end
|
22
|
+
|
23
|
+
def state
|
24
|
+
""
|
25
|
+
end
|
26
|
+
|
27
|
+
def state_code
|
28
|
+
""
|
29
|
+
end
|
30
|
+
|
31
|
+
def province
|
32
|
+
""
|
33
|
+
end
|
34
|
+
|
35
|
+
def province_code
|
36
|
+
""
|
37
|
+
end
|
38
|
+
|
39
|
+
def postal_code
|
40
|
+
""
|
41
|
+
end
|
42
|
+
|
43
|
+
def country
|
44
|
+
""
|
45
|
+
end
|
46
|
+
|
47
|
+
def country_code
|
48
|
+
""
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -68,6 +68,14 @@ module Geocoder::Result
|
|
68
68
|
address_details['Locality']['Premise']['PremiseName']
|
69
69
|
end
|
70
70
|
|
71
|
+
def street
|
72
|
+
thoroughfare_data && thoroughfare_data['ThoroughfareName']
|
73
|
+
end
|
74
|
+
|
75
|
+
def street_number
|
76
|
+
thoroughfare_data && thoroughfare_data['Premise'] && thoroughfare_data['Premise']['PremiseNumber']
|
77
|
+
end
|
78
|
+
|
71
79
|
def kind
|
72
80
|
@data['GeoObject']['metaDataProperty']['GeocoderMetaData']['kind']
|
73
81
|
end
|
@@ -85,6 +93,32 @@ module Geocoder::Result
|
|
85
93
|
|
86
94
|
private # ----------------------------------------------------------------
|
87
95
|
|
96
|
+
def thoroughfare_data
|
97
|
+
locality_data && locality_data['Thoroughfare']
|
98
|
+
end
|
99
|
+
|
100
|
+
def locality_data
|
101
|
+
dependent_locality && subadmin_locality && admin_locality
|
102
|
+
end
|
103
|
+
|
104
|
+
def admin_locality
|
105
|
+
address_details && address_details['AdministrativeArea'] &&
|
106
|
+
address_details['AdministrativeArea']['Locality']
|
107
|
+
end
|
108
|
+
|
109
|
+
def subadmin_locality
|
110
|
+
address_details && address_details['AdministrativeArea'] &&
|
111
|
+
address_details['AdministrativeArea']['SubAdministrativeArea'] &&
|
112
|
+
address_details['AdministrativeArea']['SubAdministrativeArea']['Locality']
|
113
|
+
end
|
114
|
+
|
115
|
+
def dependent_locality
|
116
|
+
address_details && address_details['AdministrativeArea'] &&
|
117
|
+
address_details['AdministrativeArea']['SubAdministrativeArea'] &&
|
118
|
+
address_details['AdministrativeArea']['SubAdministrativeArea']['Locality'] &&
|
119
|
+
address_details['AdministrativeArea']['SubAdministrativeArea']['Locality']['DependentLocality']
|
120
|
+
end
|
121
|
+
|
88
122
|
def address_details
|
89
123
|
@data['GeoObject']['metaDataProperty']['GeocoderMetaData']['AddressDetails']['Country']
|
90
124
|
end
|
data/lib/geocoder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geocoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Reisner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Provides object geocoding (by street or IP address), reverse geocoding
|
14
14
|
(coordinates to street address), distance queries for ActiveRecord and Mongoid,
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/geocoder/lookups/geoportail_lu.rb
|
63
63
|
- lib/geocoder/lookups/google.rb
|
64
64
|
- lib/geocoder/lookups/google_places_details.rb
|
65
|
+
- lib/geocoder/lookups/google_places_search.rb
|
65
66
|
- lib/geocoder/lookups/google_premier.rb
|
66
67
|
- lib/geocoder/lookups/here.rb
|
67
68
|
- lib/geocoder/lookups/ipapi_com.rb
|
@@ -108,6 +109,7 @@ files:
|
|
108
109
|
- lib/geocoder/results/geoportail_lu.rb
|
109
110
|
- lib/geocoder/results/google.rb
|
110
111
|
- lib/geocoder/results/google_places_details.rb
|
112
|
+
- lib/geocoder/results/google_places_search.rb
|
111
113
|
- lib/geocoder/results/google_premier.rb
|
112
114
|
- lib/geocoder/results/here.rb
|
113
115
|
- lib/geocoder/results/ipapi_com.rb
|
@@ -162,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
164
|
version: '0'
|
163
165
|
requirements: []
|
164
166
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.5.1
|
166
168
|
signing_key:
|
167
169
|
specification_version: 4
|
168
170
|
summary: Complete geocoding solution for Ruby.
|