geocoder 1.4.6 → 1.4.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 581d1e425470b88287f22a34b3290577ae9b2f3c
4
- data.tar.gz: bec7133e542e5da09e6f66828fce5b793c599db3
3
+ metadata.gz: dab954ab0ccd1f5c7829f019e78b754a950939c1
4
+ data.tar.gz: 8dd3db6e80446b91d9c35f9b2ad0f73a5bc28f0b
5
5
  SHA512:
6
- metadata.gz: b81c979316bfafed7ccc6806ac7eb0441a4a94103769132f01a4614c5629ac2c0ae555cc2cfa6311bca85c4f9791636db2d62eeafd1a031722ca1b2cb6fec28a
7
- data.tar.gz: 68e7fd710e2b3558dc25f5714cf8d69b9ed3fbcfc1ab7811a1c692e4a1533bdc0192efd121ae4812c91294d269f123fdd96793cf1ecac1930e8101236b6a1eef
6
+ metadata.gz: f796a95c55636b84fd46a58dd7c5e8c96ffea757270d6b8aba584abcc2634e3c30d6cce30fa6d1abf7d8ed683fecf43db6e0f1ec9512ed4b1f607786ba0289cc
7
+ data.tar.gz: f87b1b4860241b21a2ecebfeb8345660acf6c51d92483957eb9ec84999752588c75b4e3248366ecf591919859b8c1880c6d7d0fd29dbd67253443945cfce99a2
@@ -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.7 (2018 Mar 13)
7
+ -------------------
8
+ * Allow HTTP protocol for Nominatim.
9
+
6
10
  1.4.6 (2018 Feb 28)
7
11
  -------------------
8
12
  * Add support for :ipdata_co lookup (thanks github.com/roschaefer).
data/README.md CHANGED
@@ -156,10 +156,10 @@ Please use MongoDB's [geospatial query language](https://docs.mongodb.org/manual
156
156
 
157
157
  To find objects by location, use the following scopes:
158
158
 
159
- Venue.near('Omaha, NE, US', 20) # venues within 20 miles of Omaha
160
- Venue.near([40.71, -100.23], 20) # venues within 20 miles of a point
161
- Venue.near([40.71, -100.23], 20, :units => :km)
162
- # venues within 20 kilometres of a point
159
+ Venue.near('Omaha, NE, US') # venues within 20 (default) miles of Omaha
160
+ Venue.near([40.71, -100.23], 50) # venues within 50 miles of a point
161
+ Venue.near([40.71, -100.23], 50, :units => :km)
162
+ # venues within 50 kilometres of a point
163
163
  Venue.geocoded # venues with coordinates
164
164
  Venue.not_geocoded # venues without coordinates
165
165
 
@@ -13,15 +13,15 @@ module Geocoder::Lookup
13
13
 
14
14
  def query_url(query)
15
15
  method = query.reverse_geocode? ? "reverse" : "search"
16
- "#{protocol}://locationiq.org/v1/#{method}.php?key=#{configuration.api_key}&" + url_query_string(query)
17
- end
18
-
19
- def supported_protocols
20
- [:http, :https]
16
+ "#{protocol}://#{configured_host}/v1/#{method}.php?key=#{configuration.api_key}&" + url_query_string(query)
21
17
  end
22
18
 
23
19
  private
24
20
 
21
+ def configured_host
22
+ configuration[:host] || "locationiq.org"
23
+ end
24
+
25
25
  def results(query)
26
26
  return [] unless doc = fetch_data(query)
27
27
 
@@ -14,15 +14,23 @@ module Geocoder::Lookup
14
14
 
15
15
  def query_url(query)
16
16
  method = query.reverse_geocode? ? "reverse" : "search"
17
- host = configuration[:host] || "nominatim.openstreetmap.org"
18
- "#{protocol}://#{host}/#{method}?" + url_query_string(query)
17
+ "#{protocol}://#{configured_host}/#{method}?" + url_query_string(query)
19
18
  end
20
19
 
21
- def supported_protocols
22
- [:https]
20
+ private # ---------------------------------------------------------------
21
+
22
+ def configured_host
23
+ configuration[:host] || "nominatim.openstreetmap.org"
23
24
  end
24
25
 
25
- private # ---------------------------------------------------------------
26
+ def use_ssl?
27
+ # nominatim.openstreetmap.org redirects HTTP requests to HTTPS
28
+ if configured_host == "nominatim.openstreetmap.org"
29
+ true
30
+ else
31
+ super
32
+ end
33
+ end
26
34
 
27
35
  def results(query)
28
36
  return [] unless doc = fetch_data(query)
@@ -120,19 +120,30 @@ module Geocoder::Result
120
120
  def precision
121
121
  geometry['location_type'] if geometry
122
122
  end
123
-
123
+
124
124
  def partial_match
125
125
  @data['partial_match']
126
126
  end
127
-
127
+
128
128
  def place_id
129
129
  @data['place_id']
130
- end
130
+ end
131
131
 
132
132
  def viewport
133
133
  viewport = geometry['viewport'] || fail
134
- south, west = %w(lat lng).map { |c| viewport['southwest'][c] }
135
- north, east = %w(lat lng).map { |c| viewport['northeast'][c] }
134
+ bounding_box_from viewport
135
+ end
136
+
137
+ def bounds
138
+ bounding_box_from geometry['bounds']
139
+ end
140
+
141
+ private
142
+
143
+ def bounding_box_from(box)
144
+ return nil unless box
145
+ south, west = %w(lat lng).map { |c| box['southwest'][c] }
146
+ north, east = %w(lat lng).map { |c| box['northeast'][c] }
136
147
  [south, west, north, east]
137
148
  end
138
149
  end
@@ -1,3 +1,3 @@
1
1
  module Geocoder
2
- VERSION = "1.4.6"
2
+ VERSION = "1.4.7"
3
3
  end
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.6
4
+ version: 1.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Reisner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-28 00:00:00.000000000 Z
11
+ date: 2018-03-13 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,