geocoder 1.2.4 → 1.2.5
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 +6 -0
- data/README.md +1 -1
- data/lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb +2 -0
- data/lib/geocoder/lookups/maxmind_local.rb +2 -2
- data/lib/geocoder/lookups/opencagedata.rb +3 -3
- data/lib/geocoder/models/active_record.rb +4 -2
- data/lib/geocoder/models/mongo_base.rb +4 -2
- data/lib/geocoder/results/opencagedata.rb +1 -1
- data/lib/geocoder/stores/base.rb +1 -1
- data/lib/geocoder/version.rb +1 -1
- data/test/unit/lookups/opencagedata_test.rb +1 -1
- data/test/unit/result_test.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47da8a4b65f982fc2063b17aa979e48bd0747ff8
|
4
|
+
data.tar.gz: e248d9065a8228d98597639be3fb03cf012dc93b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5db5819f29c54c1923c31e80717ede54948f987fe086600f166a748b2b5b8c8d3cb021638f261792c95dfbeb13d7e243047e13351dc7edc205535b871b383361
|
7
|
+
data.tar.gz: 3bbf41ec2823259eeffe13e6d90a0aac72710a4dd4e728caca64ed9d7dc550a9306cae0bcf9cd19d9ba6b6797a7b51f1e2c9720ef0bb9f88e9878b547c951c0c
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@ 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.2.5 (2014 Sep 12)
|
7
|
+
-------------------
|
8
|
+
* Fix bugs in :opencagedata lookup (thanks github.com/duboff and kayakyakr).
|
9
|
+
* Allow language to be set in model configuration (thanks github.com/viniciusnz).
|
10
|
+
* Optimize lookup queries when using MaxMind Local (thanks github.com/gersmann).
|
11
|
+
|
6
12
|
1.2.4 (2014 Aug 12)
|
7
13
|
-------------------
|
8
14
|
* Add ability to specify lat/lon column names with .near scope (thanks github.com/switzersc).
|
data/README.md
CHANGED
@@ -566,7 +566,7 @@ Data Science Toolkit provides an API whose reponse format is like Google's but w
|
|
566
566
|
#### SmartyStreets (`:smarty_streets`)
|
567
567
|
|
568
568
|
* **API key**: required
|
569
|
-
* **Quota**: 10,000 free, 250/month then purchase at sliding scale.
|
569
|
+
* **Quota**: 10,000 free, 250/month then purchase at sliding scale.
|
570
570
|
* **Region**: US
|
571
571
|
* **SSL support**: yes
|
572
572
|
* **Languages**: en
|
@@ -5,7 +5,9 @@ class GeocoderMaxmindGeoliteCity < ActiveRecord::Migration
|
|
5
5
|
t.column :end_ip_num, :bigint, null: false
|
6
6
|
t.column :loc_id, :bigint, null: false
|
7
7
|
end
|
8
|
+
add_index :maxmind_geolite_city_blocks, :loc_id
|
8
9
|
add_index :maxmind_geolite_city_blocks, :start_ip_num, unique: true
|
10
|
+
add_index :maxmind_geolite_city_blocks, [:end_ip_num, :start_ip_num], unique: true, name: 'index_maxmind_geolite_city_blocks_on_end_ip_num_range'
|
9
11
|
|
10
12
|
create_table :maxmind_geolite_city_location, id: false do |t|
|
11
13
|
t.column :loc_id, :bigint, null: false
|
@@ -35,8 +35,8 @@ module Geocoder::Lookup
|
|
35
35
|
elsif configuration[:package] == :city
|
36
36
|
addr = IPAddr.new(query.text).to_i
|
37
37
|
q = "SELECT l.country, l.region, l.city, l.latitude, l.longitude
|
38
|
-
FROM maxmind_geolite_city_location l
|
39
|
-
WHERE b.start_ip_num <= #{addr} AND #{addr} <= b.end_ip_num"
|
38
|
+
FROM maxmind_geolite_city_location l WHERE l.loc_id = (SELECT b.loc_id FROM maxmind_geolite_city_blocks b
|
39
|
+
WHERE b.start_ip_num <= #{addr} AND #{addr} <= b.end_ip_num)"
|
40
40
|
format_result(q, [:country_name, :region_name, :city_name, :latitude, :longitude])
|
41
41
|
elsif configuration[:package] == :country
|
42
42
|
addr = IPAddr.new(query.text).to_i
|
@@ -9,7 +9,7 @@ module Geocoder::Lookup
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def query_url(query)
|
12
|
-
"#{protocol}://api.opencagedata.com/geocode/v1/json?key=#{configuration.api_key}
|
12
|
+
"#{protocol}://api.opencagedata.com/geocode/v1/json?key=#{configuration.api_key}&#{url_query_string(query)}"
|
13
13
|
end
|
14
14
|
|
15
15
|
def required_api_key_parts
|
@@ -21,7 +21,7 @@ module Geocoder::Lookup
|
|
21
21
|
def results(query)
|
22
22
|
return [] unless doc = fetch_data(query)
|
23
23
|
# return doc["results"]
|
24
|
-
|
24
|
+
|
25
25
|
messages = doc['status']['message']
|
26
26
|
case doc['status']['code']
|
27
27
|
when 400 # Error with input
|
@@ -43,7 +43,7 @@ module Geocoder::Lookup
|
|
43
43
|
|
44
44
|
def query_url_params(query)
|
45
45
|
params = {
|
46
|
-
:
|
46
|
+
:q => query.sanitized_text,
|
47
47
|
:language => (query.language || configuration.language)
|
48
48
|
}.merge(super)
|
49
49
|
|
@@ -17,7 +17,8 @@ module Geocoder
|
|
17
17
|
:geocode_block => block,
|
18
18
|
:units => options[:units],
|
19
19
|
:method => options[:method],
|
20
|
-
:lookup => options[:lookup]
|
20
|
+
:lookup => options[:lookup],
|
21
|
+
:language => options[:language]
|
21
22
|
)
|
22
23
|
end
|
23
24
|
|
@@ -33,7 +34,8 @@ module Geocoder
|
|
33
34
|
:reverse_block => block,
|
34
35
|
:units => options[:units],
|
35
36
|
:method => options[:method],
|
36
|
-
:lookup => options[:lookup]
|
37
|
+
:lookup => options[:lookup],
|
38
|
+
:language => options[:language]
|
37
39
|
)
|
38
40
|
end
|
39
41
|
|
@@ -20,7 +20,8 @@ module Geocoder
|
|
20
20
|
:units => options[:units],
|
21
21
|
:method => options[:method],
|
22
22
|
:skip_index => options[:skip_index] || false,
|
23
|
-
:lookup => options[:lookup]
|
23
|
+
:lookup => options[:lookup],
|
24
|
+
:language => options[:language]
|
24
25
|
)
|
25
26
|
end
|
26
27
|
|
@@ -36,7 +37,8 @@ module Geocoder
|
|
36
37
|
:units => options[:units],
|
37
38
|
:method => options[:method],
|
38
39
|
:skip_index => options[:skip_index] || false,
|
39
|
-
:lookup => options[:lookup]
|
40
|
+
:lookup => options[:lookup],
|
41
|
+
:language => options[:language]
|
40
42
|
)
|
41
43
|
end
|
42
44
|
|
data/lib/geocoder/stores/base.rb
CHANGED
@@ -101,7 +101,7 @@ module Geocoder
|
|
101
101
|
return
|
102
102
|
end
|
103
103
|
|
104
|
-
query_options = [:lookup, :ip_lookup].inject({}) do |hash, key|
|
104
|
+
query_options = [:lookup, :ip_lookup, :language].inject({}) do |hash, key|
|
105
105
|
if options.has_key?(key)
|
106
106
|
val = options[key]
|
107
107
|
hash[key] = val.respond_to?(:call) ? val.call(self) : val
|
data/lib/geocoder/version.rb
CHANGED
@@ -34,7 +34,7 @@ class OpencagedataTest < GeocoderTestCase
|
|
34
34
|
|
35
35
|
def test_opencagedata_reverse_url
|
36
36
|
query = Geocoder::Query.new([45.423733, -75.676333])
|
37
|
-
assert_match /\
|
37
|
+
assert_match /\bq=45.423733%2C-75.676333\b/, query.url
|
38
38
|
end
|
39
39
|
|
40
40
|
|
data/test/unit/result_test.rb
CHANGED
@@ -56,7 +56,9 @@ class ResultTest < GeocoderTestCase
|
|
56
56
|
m = "Lookup #{Geocoder.config.lookup} does not support %s attribute."
|
57
57
|
assert result.coordinates.is_a?(Array), m % "coordinates"
|
58
58
|
assert result.latitude.is_a?(Float), m % "latitude"
|
59
|
+
assert result.latitude != 0.0, m % "latitude"
|
59
60
|
assert result.longitude.is_a?(Float), m % "longitude"
|
61
|
+
assert result.longitude != 0.0, m % "longitude"
|
60
62
|
assert result.city.is_a?(String), m % "city"
|
61
63
|
assert result.state.is_a?(String), m % "state"
|
62
64
|
assert result.state_code.is_a?(String), m % "state_code"
|
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.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Reisner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-12 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,
|