geocoder 1.2.6 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +189 -1
- data/LICENSE +1 -1
- data/README.md +387 -755
- data/examples/autoexpire_cache_redis.rb +5 -3
- data/examples/reverse_geocode_job.rb +40 -0
- data/lib/generators/geocoder/config/templates/initializer.rb +17 -16
- data/lib/generators/geocoder/maxmind/geolite_city_generator.rb +2 -0
- data/lib/generators/geocoder/maxmind/geolite_country_generator.rb +2 -0
- data/lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb +1 -1
- data/lib/generators/geocoder/maxmind/templates/migration/geolite_country.rb +1 -1
- data/lib/generators/geocoder/migration_version.rb +15 -0
- data/lib/geocoder/cache.rb +6 -2
- data/lib/geocoder/calculations.rb +30 -38
- data/lib/geocoder/cli.rb +2 -2
- data/lib/geocoder/configuration.rb +18 -5
- data/lib/geocoder/esri_token.rb +38 -0
- data/lib/geocoder/exceptions.rb +19 -0
- data/lib/geocoder/ip_address.rb +16 -11
- data/lib/geocoder/kernel_logger.rb +25 -0
- data/lib/geocoder/logger.rb +47 -0
- data/lib/geocoder/lookup.rb +31 -12
- data/lib/geocoder/lookups/amap.rb +63 -0
- data/lib/geocoder/lookups/baidu.rb +17 -9
- data/lib/geocoder/lookups/baidu_ip.rb +7 -31
- data/lib/geocoder/lookups/ban_data_gouv_fr.rb +143 -0
- data/lib/geocoder/lookups/base.rb +73 -25
- data/lib/geocoder/lookups/bing.rb +38 -15
- data/lib/geocoder/lookups/db_ip_com.rb +52 -0
- data/lib/geocoder/lookups/dstk.rb +4 -2
- data/lib/geocoder/lookups/esri.rb +55 -8
- data/lib/geocoder/lookups/freegeoip.rb +18 -5
- data/lib/geocoder/lookups/geocoder_ca.rb +5 -6
- data/lib/geocoder/lookups/geocodio.rb +8 -8
- data/lib/geocoder/lookups/geoip2.rb +10 -5
- data/lib/geocoder/lookups/geoportail_lu.rb +65 -0
- data/lib/geocoder/lookups/google.rb +37 -9
- data/lib/geocoder/lookups/google_places_details.rb +9 -9
- data/lib/geocoder/lookups/google_places_search.rb +33 -0
- data/lib/geocoder/lookups/google_premier.rb +11 -1
- data/lib/geocoder/lookups/here.rb +29 -23
- data/lib/geocoder/lookups/ip2location.rb +67 -0
- data/lib/geocoder/lookups/ipapi_com.rb +82 -0
- data/lib/geocoder/lookups/ipdata_co.rb +62 -0
- data/lib/geocoder/lookups/ipgeolocation.rb +51 -0
- data/lib/geocoder/lookups/ipinfo_io.rb +44 -0
- data/lib/geocoder/lookups/ipregistry.rb +68 -0
- data/lib/geocoder/lookups/ipstack.rb +63 -0
- data/lib/geocoder/lookups/latlon.rb +59 -0
- data/lib/geocoder/lookups/location_iq.rb +50 -0
- data/lib/geocoder/lookups/mapbox.rb +59 -0
- data/lib/geocoder/lookups/mapquest.rb +7 -9
- data/lib/geocoder/lookups/maxmind.rb +7 -7
- data/lib/geocoder/lookups/maxmind_geoip2.rb +70 -0
- data/lib/geocoder/lookups/maxmind_local.rb +9 -2
- data/lib/geocoder/lookups/nominatim.rb +18 -6
- data/lib/geocoder/lookups/opencagedata.rb +16 -9
- data/lib/geocoder/lookups/osmnames.rb +57 -0
- data/lib/geocoder/lookups/pelias.rb +63 -0
- data/lib/geocoder/lookups/pickpoint.rb +41 -0
- data/lib/geocoder/lookups/pointpin.rb +14 -13
- data/lib/geocoder/lookups/postcode_anywhere_uk.rb +7 -8
- data/lib/geocoder/lookups/postcodes_io.rb +31 -0
- data/lib/geocoder/lookups/smarty_streets.rb +23 -5
- data/lib/geocoder/lookups/telize.rb +42 -7
- data/lib/geocoder/lookups/tencent.rb +59 -0
- data/lib/geocoder/lookups/yandex.rb +17 -9
- data/lib/geocoder/models/active_record.rb +4 -3
- data/lib/geocoder/models/mongo_base.rb +0 -2
- data/lib/geocoder/query.rb +15 -1
- data/lib/geocoder/railtie.rb +1 -1
- data/lib/geocoder/request.rb +103 -14
- data/lib/geocoder/results/amap.rb +87 -0
- data/lib/geocoder/results/baidu.rb +10 -14
- data/lib/geocoder/results/ban_data_gouv_fr.rb +257 -0
- data/lib/geocoder/results/base.rb +13 -1
- data/lib/geocoder/results/bing.rb +5 -1
- data/lib/geocoder/results/db_ip_com.rb +58 -0
- data/lib/geocoder/results/esri.rb +30 -6
- data/lib/geocoder/results/freegeoip.rb +2 -7
- data/lib/geocoder/results/geocoder_ca.rb +3 -3
- data/lib/geocoder/results/geocodio.rb +15 -3
- data/lib/geocoder/results/geoip2.rb +37 -25
- data/lib/geocoder/results/geoportail_lu.rb +71 -0
- data/lib/geocoder/results/google.rb +26 -0
- data/lib/geocoder/results/google_places_details.rb +4 -0
- data/lib/geocoder/results/google_places_search.rb +52 -0
- data/lib/geocoder/results/here.rb +21 -1
- data/lib/geocoder/results/ip2location.rb +22 -0
- data/lib/geocoder/results/ipapi_com.rb +45 -0
- data/lib/geocoder/results/ipdata_co.rb +40 -0
- data/lib/geocoder/results/ipgeolocation.rb +59 -0
- data/lib/geocoder/results/ipinfo_io.rb +48 -0
- data/lib/geocoder/results/ipregistry.rb +308 -0
- data/lib/geocoder/results/ipstack.rb +60 -0
- data/lib/geocoder/results/latlon.rb +71 -0
- data/lib/geocoder/results/location_iq.rb +6 -0
- data/lib/geocoder/results/mapbox.rb +57 -0
- data/lib/geocoder/results/mapquest.rb +5 -8
- data/lib/geocoder/results/maxmind.rb +0 -5
- data/lib/geocoder/results/maxmind_geoip2.rb +9 -0
- data/lib/geocoder/results/maxmind_local.rb +0 -5
- data/lib/geocoder/results/nominatim.rb +18 -3
- data/lib/geocoder/results/opencagedata.rb +20 -2
- data/lib/geocoder/results/osmnames.rb +56 -0
- data/lib/geocoder/results/pelias.rb +58 -0
- data/lib/geocoder/results/pickpoint.rb +6 -0
- data/lib/geocoder/results/pointpin.rb +0 -4
- data/lib/geocoder/results/postcodes_io.rb +40 -0
- data/lib/geocoder/results/smarty_streets.rb +55 -19
- data/lib/geocoder/results/telize.rb +0 -5
- data/lib/geocoder/results/tencent.rb +72 -0
- data/lib/geocoder/results/test.rb +1 -1
- data/lib/geocoder/results/yandex.rb +57 -7
- data/lib/geocoder/sql.rb +9 -6
- data/lib/geocoder/stores/active_record.rb +49 -10
- data/lib/geocoder/stores/base.rb +2 -14
- data/lib/geocoder/stores/mongo_base.rb +0 -31
- data/lib/geocoder/version.rb +1 -1
- data/lib/geocoder.rb +2 -1
- data/lib/hash_recursive_merge.rb +1 -2
- data/lib/maxmind_database.rb +4 -4
- data/lib/tasks/geocoder.rake +29 -4
- metadata +56 -159
- data/.gitignore +0 -6
- data/.travis.yml +0 -31
- data/Rakefile +0 -25
- data/gemfiles/Gemfile.mongoid-2.4.x +0 -16
- data/lib/geocoder/lookups/geocoder_us.rb +0 -39
- data/lib/geocoder/lookups/okf.rb +0 -43
- data/lib/geocoder/lookups/ovi.rb +0 -62
- data/lib/geocoder/lookups/yahoo.rb +0 -88
- data/lib/geocoder/results/geocoder_us.rb +0 -39
- data/lib/geocoder/results/okf.rb +0 -106
- data/lib/geocoder/results/ovi.rb +0 -62
- data/lib/geocoder/results/yahoo.rb +0 -55
- data/lib/oauth_util.rb +0 -112
- data/test/fixtures/baidu_invalid_key +0 -1
- data/test/fixtures/baidu_ip_202_198_16_3 +0 -19
- data/test/fixtures/baidu_ip_invalid_key +0 -1
- data/test/fixtures/baidu_ip_no_results +0 -1
- data/test/fixtures/baidu_no_results +0 -1
- data/test/fixtures/baidu_reverse +0 -1
- data/test/fixtures/baidu_shanghai_pearl_tower +0 -12
- data/test/fixtures/bing_invalid_key +0 -1
- data/test/fixtures/bing_madison_square_garden +0 -40
- data/test/fixtures/bing_no_results +0 -16
- data/test/fixtures/bing_reverse +0 -42
- data/test/fixtures/cloudmade_invalid_key +0 -1
- data/test/fixtures/cloudmade_madison_square_garden +0 -1
- data/test/fixtures/cloudmade_no_results +0 -1
- data/test/fixtures/esri_madison_square_garden +0 -59
- data/test/fixtures/esri_no_results +0 -8
- data/test/fixtures/esri_reverse +0 -21
- data/test/fixtures/freegeoip_74_200_247_59 +0 -12
- data/test/fixtures/freegeoip_no_results +0 -1
- data/test/fixtures/geocoder_ca_madison_square_garden +0 -1
- data/test/fixtures/geocoder_ca_no_results +0 -1
- data/test/fixtures/geocoder_ca_reverse +0 -34
- data/test/fixtures/geocoder_us_madison_square_garden +0 -1
- data/test/fixtures/geocoder_us_no_results +0 -1
- data/test/fixtures/geocodio_1101_pennsylvania_ave +0 -1
- data/test/fixtures/geocodio_bad_api_key +0 -3
- data/test/fixtures/geocodio_invalid +0 -4
- data/test/fixtures/geocodio_no_results +0 -1
- data/test/fixtures/geocodio_over_query_limit +0 -4
- data/test/fixtures/google_garbage +0 -456
- data/test/fixtures/google_madison_square_garden +0 -57
- data/test/fixtures/google_no_city_data +0 -44
- data/test/fixtures/google_no_locality +0 -51
- data/test/fixtures/google_no_results +0 -4
- data/test/fixtures/google_over_limit +0 -4
- data/test/fixtures/google_places_details_invalid_request +0 -4
- data/test/fixtures/google_places_details_madison_square_garden +0 -120
- data/test/fixtures/google_places_details_no_results +0 -4
- data/test/fixtures/google_places_details_no_reviews +0 -60
- data/test/fixtures/google_places_details_no_types +0 -66
- data/test/fixtures/here_madison_square_garden +0 -72
- data/test/fixtures/here_no_results +0 -8
- data/test/fixtures/mapquest_error +0 -16
- data/test/fixtures/mapquest_invalid_api_key +0 -16
- data/test/fixtures/mapquest_invalid_request +0 -16
- data/test/fixtures/mapquest_madison_square_garden +0 -52
- data/test/fixtures/mapquest_no_results +0 -16
- data/test/fixtures/maxmind_24_24_24_21 +0 -1
- data/test/fixtures/maxmind_24_24_24_22 +0 -1
- data/test/fixtures/maxmind_24_24_24_23 +0 -1
- data/test/fixtures/maxmind_24_24_24_24 +0 -1
- data/test/fixtures/maxmind_74_200_247_59 +0 -1
- data/test/fixtures/maxmind_invalid_key +0 -1
- data/test/fixtures/maxmind_no_results +0 -1
- data/test/fixtures/nominatim_madison_square_garden +0 -150
- data/test/fixtures/nominatim_no_results +0 -1
- data/test/fixtures/nominatim_over_limit +0 -1
- data/test/fixtures/okf_kirstinmaki +0 -67
- data/test/fixtures/okf_no_results +0 -4
- data/test/fixtures/opencagedata_invalid_api_key +0 -25
- data/test/fixtures/opencagedata_invalid_request +0 -26
- data/test/fixtures/opencagedata_madison_square_garden +0 -73
- data/test/fixtures/opencagedata_no_results +0 -29
- data/test/fixtures/opencagedata_over_limit +0 -31
- data/test/fixtures/ovi_madison_square_garden +0 -72
- data/test/fixtures/ovi_no_results +0 -8
- data/test/fixtures/pointpin_10_10_10_10 +0 -1
- data/test/fixtures/pointpin_555_555_555_555 +0 -1
- data/test/fixtures/pointpin_80_111_555_555 +0 -1
- data/test/fixtures/pointpin_no_results +0 -1
- data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_WR26NJ +0 -1
- data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_generic_error +0 -1
- data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_hampshire +0 -1
- data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_key_limit_exceeded +0 -1
- data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_no_results +0 -1
- data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_romsey +0 -1
- data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_unknown_key +0 -1
- data/test/fixtures/smarty_streets_11211 +0 -1
- data/test/fixtures/smarty_streets_madison_square_garden +0 -47
- data/test/fixtures/smarty_streets_no_results +0 -1
- data/test/fixtures/telize_10_10_10_10 +0 -1
- data/test/fixtures/telize_555_555_555_555 +0 -4
- data/test/fixtures/telize_74_200_247_59 +0 -1
- data/test/fixtures/telize_no_results +0 -1
- data/test/fixtures/yahoo_error +0 -1
- data/test/fixtures/yahoo_invalid_key +0 -2
- data/test/fixtures/yahoo_madison_square_garden +0 -52
- data/test/fixtures/yahoo_no_results +0 -10
- data/test/fixtures/yahoo_over_limit +0 -2
- data/test/fixtures/yandex_canada_rue_dupuis_14 +0 -446
- data/test/fixtures/yandex_invalid_key +0 -1
- data/test/fixtures/yandex_kremlin +0 -48
- data/test/fixtures/yandex_new_york +0 -1
- data/test/fixtures/yandex_no_city_and_town +0 -112
- data/test/fixtures/yandex_no_results +0 -16
- data/test/integration/http_client_test.rb +0 -31
- data/test/mongoid_test_helper.rb +0 -43
- data/test/test_helper.rb +0 -416
- data/test/unit/active_record_test.rb +0 -16
- data/test/unit/cache_test.rb +0 -37
- data/test/unit/calculations_test.rb +0 -220
- data/test/unit/configuration_test.rb +0 -55
- data/test/unit/error_handling_test.rb +0 -56
- data/test/unit/geocoder_test.rb +0 -78
- data/test/unit/https_test.rb +0 -17
- data/test/unit/ip_address_test.rb +0 -27
- data/test/unit/lookup_test.rb +0 -153
- data/test/unit/lookups/bing_test.rb +0 -68
- data/test/unit/lookups/dstk_test.rb +0 -26
- data/test/unit/lookups/esri_test.rb +0 -48
- data/test/unit/lookups/freegeoip_test.rb +0 -27
- data/test/unit/lookups/geocoder_ca_test.rb +0 -17
- data/test/unit/lookups/geocodio_test.rb +0 -55
- data/test/unit/lookups/geoip2_test.rb +0 -27
- data/test/unit/lookups/google_places_details_test.rb +0 -122
- data/test/unit/lookups/google_premier_test.rb +0 -22
- data/test/unit/lookups/google_test.rb +0 -84
- data/test/unit/lookups/mapquest_test.rb +0 -60
- data/test/unit/lookups/maxmind_local_test.rb +0 -28
- data/test/unit/lookups/maxmind_test.rb +0 -63
- data/test/unit/lookups/nominatim_test.rb +0 -31
- data/test/unit/lookups/okf_test.rb +0 -38
- data/test/unit/lookups/opencagedata_test.rb +0 -64
- data/test/unit/lookups/pointpin_test.rb +0 -30
- data/test/unit/lookups/postcode_anywhere_uk_test.rb +0 -70
- data/test/unit/lookups/smarty_streets_test.rb +0 -71
- data/test/unit/lookups/telize_test.rb +0 -36
- data/test/unit/lookups/yahoo_test.rb +0 -35
- data/test/unit/method_aliases_test.rb +0 -26
- data/test/unit/model_test.rb +0 -38
- data/test/unit/mongoid_test.rb +0 -47
- data/test/unit/near_test.rb +0 -87
- data/test/unit/oauth_util_test.rb +0 -31
- data/test/unit/proxy_test.rb +0 -37
- data/test/unit/query_test.rb +0 -52
- data/test/unit/rake_task_test.rb +0 -21
- data/test/unit/request_test.rb +0 -35
- data/test/unit/result_test.rb +0 -72
- data/test/unit/test_mode_test.rb +0 -70
data/lib/geocoder/stores/base.rb
CHANGED
@@ -6,7 +6,7 @@ module Geocoder
|
|
6
6
|
# Is this object geocoded? (Does it have latitude and longitude?)
|
7
7
|
#
|
8
8
|
def geocoded?
|
9
|
-
to_coordinates.compact.size
|
9
|
+
to_coordinates.compact.size == 2
|
10
10
|
end
|
11
11
|
|
12
12
|
##
|
@@ -55,17 +55,6 @@ module Geocoder
|
|
55
55
|
point, to_coordinates, options)
|
56
56
|
end
|
57
57
|
|
58
|
-
##
|
59
|
-
# Get nearby geocoded objects.
|
60
|
-
# Takes the same options hash as the near class method (scope).
|
61
|
-
# Returns nil if the object is not geocoded.
|
62
|
-
#
|
63
|
-
def nearbys(radius = 20, options = {})
|
64
|
-
return nil unless geocoded?
|
65
|
-
options.merge!(:exclude => self) unless send(self.class.primary_key).nil?
|
66
|
-
self.class.near(self, radius, options)
|
67
|
-
end
|
68
|
-
|
69
58
|
##
|
70
59
|
# Look up coordinates and assign to +latitude+ and +longitude+ attributes
|
71
60
|
# (or other as specified in +geocoded_by+). Returns coordinates (array).
|
@@ -101,7 +90,7 @@ module Geocoder
|
|
101
90
|
return
|
102
91
|
end
|
103
92
|
|
104
|
-
query_options = [:lookup, :ip_lookup, :language].inject({}) do |hash, key|
|
93
|
+
query_options = [:lookup, :ip_lookup, :language, :params].inject({}) do |hash, key|
|
105
94
|
if options.has_key?(key)
|
106
95
|
val = options[key]
|
107
96
|
hash[key] = val.respond_to?(:call) ? val.call(self) : val
|
@@ -124,4 +113,3 @@ module Geocoder
|
|
124
113
|
end
|
125
114
|
end
|
126
115
|
end
|
127
|
-
|
@@ -11,37 +11,6 @@ module Geocoder::Store
|
|
11
11
|
scope :not_geocoded, lambda {
|
12
12
|
where(geocoder_options[:coordinates] => nil)
|
13
13
|
}
|
14
|
-
|
15
|
-
scope :near, lambda{ |location, *args|
|
16
|
-
coords = Geocoder::Calculations.extract_coordinates(location)
|
17
|
-
|
18
|
-
# no results if no lat/lon given
|
19
|
-
return where(:id => false) unless coords.is_a?(Array)
|
20
|
-
|
21
|
-
radius = args.size > 0 ? args.shift : 20
|
22
|
-
options = args.size > 0 ? args.shift : {}
|
23
|
-
options[:units] ||= geocoder_options[:units]
|
24
|
-
|
25
|
-
# Use BSON::OrderedHash if Ruby's hashes are unordered.
|
26
|
-
# Conditions must be in order required by indexes (see mongo gem).
|
27
|
-
version = RUBY_VERSION.split('.').map { |i| i.to_i }
|
28
|
-
empty = version[0] < 2 && version[1] < 9 ? BSON::OrderedHash.new : {}
|
29
|
-
|
30
|
-
conds = empty.clone
|
31
|
-
field = geocoder_options[:coordinates]
|
32
|
-
conds[field] = empty.clone
|
33
|
-
conds[field]["$nearSphere"] = coords.reverse
|
34
|
-
|
35
|
-
if radius
|
36
|
-
conds[field]["$maxDistance"] = \
|
37
|
-
Geocoder::Calculations.distance_to_radians(radius, options[:units])
|
38
|
-
end
|
39
|
-
|
40
|
-
if obj = options[:exclude]
|
41
|
-
conds[:_id.ne] = obj.id
|
42
|
-
end
|
43
|
-
where(conds)
|
44
|
-
}
|
45
14
|
end
|
46
15
|
end
|
47
16
|
|
data/lib/geocoder/version.rb
CHANGED
data/lib/geocoder.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require "geocoder/configuration"
|
2
|
+
require "geocoder/logger"
|
3
|
+
require "geocoder/kernel_logger"
|
2
4
|
require "geocoder/query"
|
3
5
|
require "geocoder/calculations"
|
4
6
|
require "geocoder/exceptions"
|
@@ -43,5 +45,4 @@ end
|
|
43
45
|
# load Railtie if Rails exists
|
44
46
|
if defined?(Rails)
|
45
47
|
require "geocoder/railtie"
|
46
|
-
Geocoder::Railtie.insert
|
47
48
|
end
|
data/lib/hash_recursive_merge.rb
CHANGED
@@ -60,9 +60,8 @@ module HashRecursiveMerge
|
|
60
60
|
# h1.merge(h2) #=> {"a" => 100, "b" = >254, "c" => {"c1" => 16, "c3" => 94}}
|
61
61
|
#
|
62
62
|
def rmerge(other_hash)
|
63
|
-
r = {}
|
64
63
|
merge(other_hash) do |key, oldval, newval|
|
65
|
-
|
64
|
+
oldval.class == self.class ? oldval.rmerge(newval) : newval
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
data/lib/maxmind_database.rb
CHANGED
@@ -21,7 +21,7 @@ module Geocoder
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def insert(package, dir = "tmp")
|
24
|
-
data_files(package).each do |filepath,table|
|
24
|
+
data_files(package, dir).each do |filepath,table|
|
25
25
|
print "Resetting table #{table}..."
|
26
26
|
ActiveRecord::Base.connection.execute("DELETE FROM #{table}")
|
27
27
|
puts "done"
|
@@ -96,9 +96,9 @@ module Geocoder
|
|
96
96
|
|
97
97
|
def archive_url_path(package)
|
98
98
|
{
|
99
|
-
geolite_country_csv: "
|
100
|
-
geolite_city_csv: "
|
101
|
-
geolite_asn_csv: "
|
99
|
+
geolite_country_csv: "GeoLite2-Country-CSV.zip",
|
100
|
+
geolite_city_csv: "GeoLite2-City-CSV.zip",
|
101
|
+
geolite_asn_csv: "GeoLite2-ASN-CSV.zip"
|
102
102
|
}[package]
|
103
103
|
end
|
104
104
|
|
data/lib/tasks/geocoder.rake
CHANGED
@@ -1,20 +1,45 @@
|
|
1
|
+
require "geocoder/models/mongoid"
|
2
|
+
|
1
3
|
namespace :geocode do
|
2
4
|
desc "Geocode all objects without coordinates."
|
3
5
|
task :all => :environment do
|
4
6
|
class_name = ENV['CLASS'] || ENV['class']
|
5
7
|
sleep_timer = ENV['SLEEP'] || ENV['sleep']
|
6
8
|
batch = ENV['BATCH'] || ENV['batch']
|
9
|
+
reverse = ENV['REVERSE'] || ENV['reverse']
|
10
|
+
limit = ENV['LIMIT'] || ENV['limit']
|
7
11
|
raise "Please specify a CLASS (model)" unless class_name
|
8
12
|
klass = class_from_string(class_name)
|
9
|
-
batch = batch.to_i unless batch.nil?
|
13
|
+
batch = (batch.to_i unless batch.nil?) || 1000
|
14
|
+
orm = (klass < Geocoder::Model::Mongoid) ? 'mongoid' : 'active_record'
|
15
|
+
reverse = false unless reverse.to_s.downcase == 'true'
|
10
16
|
|
11
|
-
|
12
|
-
obj.
|
17
|
+
geocode_record = lambda { |obj|
|
18
|
+
reverse ? obj.reverse_geocode : obj.geocode
|
19
|
+
obj.save
|
13
20
|
sleep(sleep_timer.to_f) unless sleep_timer.nil?
|
21
|
+
}
|
22
|
+
|
23
|
+
scope = reverse ? klass.not_reverse_geocoded : klass.not_geocoded
|
24
|
+
scope = scope.limit(limit) if limit
|
25
|
+
if orm == 'mongoid'
|
26
|
+
scope.each do |obj|
|
27
|
+
geocode_record.call(obj)
|
28
|
+
end
|
29
|
+
elsif orm == 'active_record'
|
30
|
+
if limit
|
31
|
+
scope.each do |obj|
|
32
|
+
geocode_record.call(obj)
|
33
|
+
end
|
34
|
+
else
|
35
|
+
scope.find_each(batch_size: batch) do |obj|
|
36
|
+
geocode_record.call(obj)
|
37
|
+
end
|
38
|
+
end
|
14
39
|
end
|
40
|
+
|
15
41
|
end
|
16
42
|
end
|
17
|
-
|
18
43
|
##
|
19
44
|
# Get a class object from the string given in the shell environment.
|
20
45
|
# Similar to ActiveSupport's +constantize+ method.
|
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
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Reisner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-23 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,
|
@@ -21,60 +21,78 @@ executables:
|
|
21
21
|
extensions: []
|
22
22
|
extra_rdoc_files: []
|
23
23
|
files:
|
24
|
-
- ".gitignore"
|
25
|
-
- ".travis.yml"
|
26
24
|
- CHANGELOG.md
|
27
25
|
- LICENSE
|
28
26
|
- README.md
|
29
|
-
- Rakefile
|
30
27
|
- bin/geocode
|
31
28
|
- examples/autoexpire_cache_dalli.rb
|
32
29
|
- examples/autoexpire_cache_redis.rb
|
33
30
|
- examples/cache_bypass.rb
|
34
|
-
-
|
31
|
+
- examples/reverse_geocode_job.rb
|
35
32
|
- lib/generators/geocoder/config/config_generator.rb
|
36
33
|
- lib/generators/geocoder/config/templates/initializer.rb
|
37
34
|
- lib/generators/geocoder/maxmind/geolite_city_generator.rb
|
38
35
|
- lib/generators/geocoder/maxmind/geolite_country_generator.rb
|
39
36
|
- lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb
|
40
37
|
- lib/generators/geocoder/maxmind/templates/migration/geolite_country.rb
|
38
|
+
- lib/generators/geocoder/migration_version.rb
|
41
39
|
- lib/geocoder.rb
|
42
40
|
- lib/geocoder/cache.rb
|
43
41
|
- lib/geocoder/calculations.rb
|
44
42
|
- lib/geocoder/cli.rb
|
45
43
|
- lib/geocoder/configuration.rb
|
46
44
|
- lib/geocoder/configuration_hash.rb
|
45
|
+
- lib/geocoder/esri_token.rb
|
47
46
|
- lib/geocoder/exceptions.rb
|
48
47
|
- lib/geocoder/ip_address.rb
|
48
|
+
- lib/geocoder/kernel_logger.rb
|
49
|
+
- lib/geocoder/logger.rb
|
49
50
|
- lib/geocoder/lookup.rb
|
51
|
+
- lib/geocoder/lookups/amap.rb
|
50
52
|
- lib/geocoder/lookups/baidu.rb
|
51
53
|
- lib/geocoder/lookups/baidu_ip.rb
|
54
|
+
- lib/geocoder/lookups/ban_data_gouv_fr.rb
|
52
55
|
- lib/geocoder/lookups/base.rb
|
53
56
|
- lib/geocoder/lookups/bing.rb
|
57
|
+
- lib/geocoder/lookups/db_ip_com.rb
|
54
58
|
- lib/geocoder/lookups/dstk.rb
|
55
59
|
- lib/geocoder/lookups/esri.rb
|
56
60
|
- lib/geocoder/lookups/freegeoip.rb
|
57
61
|
- lib/geocoder/lookups/geocoder_ca.rb
|
58
|
-
- lib/geocoder/lookups/geocoder_us.rb
|
59
62
|
- lib/geocoder/lookups/geocodio.rb
|
60
63
|
- lib/geocoder/lookups/geoip2.rb
|
64
|
+
- lib/geocoder/lookups/geoportail_lu.rb
|
61
65
|
- lib/geocoder/lookups/google.rb
|
62
66
|
- lib/geocoder/lookups/google_places_details.rb
|
67
|
+
- lib/geocoder/lookups/google_places_search.rb
|
63
68
|
- lib/geocoder/lookups/google_premier.rb
|
64
69
|
- lib/geocoder/lookups/here.rb
|
70
|
+
- lib/geocoder/lookups/ip2location.rb
|
71
|
+
- lib/geocoder/lookups/ipapi_com.rb
|
72
|
+
- lib/geocoder/lookups/ipdata_co.rb
|
73
|
+
- lib/geocoder/lookups/ipgeolocation.rb
|
74
|
+
- lib/geocoder/lookups/ipinfo_io.rb
|
75
|
+
- lib/geocoder/lookups/ipregistry.rb
|
76
|
+
- lib/geocoder/lookups/ipstack.rb
|
77
|
+
- lib/geocoder/lookups/latlon.rb
|
78
|
+
- lib/geocoder/lookups/location_iq.rb
|
79
|
+
- lib/geocoder/lookups/mapbox.rb
|
65
80
|
- lib/geocoder/lookups/mapquest.rb
|
66
81
|
- lib/geocoder/lookups/maxmind.rb
|
82
|
+
- lib/geocoder/lookups/maxmind_geoip2.rb
|
67
83
|
- lib/geocoder/lookups/maxmind_local.rb
|
68
84
|
- lib/geocoder/lookups/nominatim.rb
|
69
|
-
- lib/geocoder/lookups/okf.rb
|
70
85
|
- lib/geocoder/lookups/opencagedata.rb
|
71
|
-
- lib/geocoder/lookups/
|
86
|
+
- lib/geocoder/lookups/osmnames.rb
|
87
|
+
- lib/geocoder/lookups/pelias.rb
|
88
|
+
- lib/geocoder/lookups/pickpoint.rb
|
72
89
|
- lib/geocoder/lookups/pointpin.rb
|
73
90
|
- lib/geocoder/lookups/postcode_anywhere_uk.rb
|
91
|
+
- lib/geocoder/lookups/postcodes_io.rb
|
74
92
|
- lib/geocoder/lookups/smarty_streets.rb
|
75
93
|
- lib/geocoder/lookups/telize.rb
|
94
|
+
- lib/geocoder/lookups/tencent.rb
|
76
95
|
- lib/geocoder/lookups/test.rb
|
77
|
-
- lib/geocoder/lookups/yahoo.rb
|
78
96
|
- lib/geocoder/lookups/yandex.rb
|
79
97
|
- lib/geocoder/models/active_record.rb
|
80
98
|
- lib/geocoder/models/base.rb
|
@@ -84,34 +102,51 @@ files:
|
|
84
102
|
- lib/geocoder/query.rb
|
85
103
|
- lib/geocoder/railtie.rb
|
86
104
|
- lib/geocoder/request.rb
|
105
|
+
- lib/geocoder/results/amap.rb
|
87
106
|
- lib/geocoder/results/baidu.rb
|
88
107
|
- lib/geocoder/results/baidu_ip.rb
|
108
|
+
- lib/geocoder/results/ban_data_gouv_fr.rb
|
89
109
|
- lib/geocoder/results/base.rb
|
90
110
|
- lib/geocoder/results/bing.rb
|
111
|
+
- lib/geocoder/results/db_ip_com.rb
|
91
112
|
- lib/geocoder/results/dstk.rb
|
92
113
|
- lib/geocoder/results/esri.rb
|
93
114
|
- lib/geocoder/results/freegeoip.rb
|
94
115
|
- lib/geocoder/results/geocoder_ca.rb
|
95
|
-
- lib/geocoder/results/geocoder_us.rb
|
96
116
|
- lib/geocoder/results/geocodio.rb
|
97
117
|
- lib/geocoder/results/geoip2.rb
|
118
|
+
- lib/geocoder/results/geoportail_lu.rb
|
98
119
|
- lib/geocoder/results/google.rb
|
99
120
|
- lib/geocoder/results/google_places_details.rb
|
121
|
+
- lib/geocoder/results/google_places_search.rb
|
100
122
|
- lib/geocoder/results/google_premier.rb
|
101
123
|
- lib/geocoder/results/here.rb
|
124
|
+
- lib/geocoder/results/ip2location.rb
|
125
|
+
- lib/geocoder/results/ipapi_com.rb
|
126
|
+
- lib/geocoder/results/ipdata_co.rb
|
127
|
+
- lib/geocoder/results/ipgeolocation.rb
|
128
|
+
- lib/geocoder/results/ipinfo_io.rb
|
129
|
+
- lib/geocoder/results/ipregistry.rb
|
130
|
+
- lib/geocoder/results/ipstack.rb
|
131
|
+
- lib/geocoder/results/latlon.rb
|
132
|
+
- lib/geocoder/results/location_iq.rb
|
133
|
+
- lib/geocoder/results/mapbox.rb
|
102
134
|
- lib/geocoder/results/mapquest.rb
|
103
135
|
- lib/geocoder/results/maxmind.rb
|
136
|
+
- lib/geocoder/results/maxmind_geoip2.rb
|
104
137
|
- lib/geocoder/results/maxmind_local.rb
|
105
138
|
- lib/geocoder/results/nominatim.rb
|
106
|
-
- lib/geocoder/results/okf.rb
|
107
139
|
- lib/geocoder/results/opencagedata.rb
|
108
|
-
- lib/geocoder/results/
|
140
|
+
- lib/geocoder/results/osmnames.rb
|
141
|
+
- lib/geocoder/results/pelias.rb
|
142
|
+
- lib/geocoder/results/pickpoint.rb
|
109
143
|
- lib/geocoder/results/pointpin.rb
|
110
144
|
- lib/geocoder/results/postcode_anywhere_uk.rb
|
145
|
+
- lib/geocoder/results/postcodes_io.rb
|
111
146
|
- lib/geocoder/results/smarty_streets.rb
|
112
147
|
- lib/geocoder/results/telize.rb
|
148
|
+
- lib/geocoder/results/tencent.rb
|
113
149
|
- lib/geocoder/results/test.rb
|
114
|
-
- lib/geocoder/results/yahoo.rb
|
115
150
|
- lib/geocoder/results/yandex.rb
|
116
151
|
- lib/geocoder/sql.rb
|
117
152
|
- lib/geocoder/stores/active_record.rb
|
@@ -122,151 +157,14 @@ files:
|
|
122
157
|
- lib/geocoder/version.rb
|
123
158
|
- lib/hash_recursive_merge.rb
|
124
159
|
- lib/maxmind_database.rb
|
125
|
-
- lib/oauth_util.rb
|
126
160
|
- lib/tasks/geocoder.rake
|
127
161
|
- lib/tasks/maxmind.rake
|
128
|
-
- test/fixtures/baidu_invalid_key
|
129
|
-
- test/fixtures/baidu_ip_202_198_16_3
|
130
|
-
- test/fixtures/baidu_ip_invalid_key
|
131
|
-
- test/fixtures/baidu_ip_no_results
|
132
|
-
- test/fixtures/baidu_no_results
|
133
|
-
- test/fixtures/baidu_reverse
|
134
|
-
- test/fixtures/baidu_shanghai_pearl_tower
|
135
|
-
- test/fixtures/bing_invalid_key
|
136
|
-
- test/fixtures/bing_madison_square_garden
|
137
|
-
- test/fixtures/bing_no_results
|
138
|
-
- test/fixtures/bing_reverse
|
139
|
-
- test/fixtures/cloudmade_invalid_key
|
140
|
-
- test/fixtures/cloudmade_madison_square_garden
|
141
|
-
- test/fixtures/cloudmade_no_results
|
142
|
-
- test/fixtures/esri_madison_square_garden
|
143
|
-
- test/fixtures/esri_no_results
|
144
|
-
- test/fixtures/esri_reverse
|
145
|
-
- test/fixtures/freegeoip_74_200_247_59
|
146
|
-
- test/fixtures/freegeoip_no_results
|
147
|
-
- test/fixtures/geocoder_ca_madison_square_garden
|
148
|
-
- test/fixtures/geocoder_ca_no_results
|
149
|
-
- test/fixtures/geocoder_ca_reverse
|
150
|
-
- test/fixtures/geocoder_us_madison_square_garden
|
151
|
-
- test/fixtures/geocoder_us_no_results
|
152
|
-
- test/fixtures/geocodio_1101_pennsylvania_ave
|
153
|
-
- test/fixtures/geocodio_bad_api_key
|
154
|
-
- test/fixtures/geocodio_invalid
|
155
|
-
- test/fixtures/geocodio_no_results
|
156
|
-
- test/fixtures/geocodio_over_query_limit
|
157
|
-
- test/fixtures/google_garbage
|
158
|
-
- test/fixtures/google_madison_square_garden
|
159
|
-
- test/fixtures/google_no_city_data
|
160
|
-
- test/fixtures/google_no_locality
|
161
|
-
- test/fixtures/google_no_results
|
162
|
-
- test/fixtures/google_over_limit
|
163
|
-
- test/fixtures/google_places_details_invalid_request
|
164
|
-
- test/fixtures/google_places_details_madison_square_garden
|
165
|
-
- test/fixtures/google_places_details_no_results
|
166
|
-
- test/fixtures/google_places_details_no_reviews
|
167
|
-
- test/fixtures/google_places_details_no_types
|
168
|
-
- test/fixtures/here_madison_square_garden
|
169
|
-
- test/fixtures/here_no_results
|
170
|
-
- test/fixtures/mapquest_error
|
171
|
-
- test/fixtures/mapquest_invalid_api_key
|
172
|
-
- test/fixtures/mapquest_invalid_request
|
173
|
-
- test/fixtures/mapquest_madison_square_garden
|
174
|
-
- test/fixtures/mapquest_no_results
|
175
|
-
- test/fixtures/maxmind_24_24_24_21
|
176
|
-
- test/fixtures/maxmind_24_24_24_22
|
177
|
-
- test/fixtures/maxmind_24_24_24_23
|
178
|
-
- test/fixtures/maxmind_24_24_24_24
|
179
|
-
- test/fixtures/maxmind_74_200_247_59
|
180
|
-
- test/fixtures/maxmind_invalid_key
|
181
|
-
- test/fixtures/maxmind_no_results
|
182
|
-
- test/fixtures/nominatim_madison_square_garden
|
183
|
-
- test/fixtures/nominatim_no_results
|
184
|
-
- test/fixtures/nominatim_over_limit
|
185
|
-
- test/fixtures/okf_kirstinmaki
|
186
|
-
- test/fixtures/okf_no_results
|
187
|
-
- test/fixtures/opencagedata_invalid_api_key
|
188
|
-
- test/fixtures/opencagedata_invalid_request
|
189
|
-
- test/fixtures/opencagedata_madison_square_garden
|
190
|
-
- test/fixtures/opencagedata_no_results
|
191
|
-
- test/fixtures/opencagedata_over_limit
|
192
|
-
- test/fixtures/ovi_madison_square_garden
|
193
|
-
- test/fixtures/ovi_no_results
|
194
|
-
- test/fixtures/pointpin_10_10_10_10
|
195
|
-
- test/fixtures/pointpin_555_555_555_555
|
196
|
-
- test/fixtures/pointpin_80_111_555_555
|
197
|
-
- test/fixtures/pointpin_no_results
|
198
|
-
- test/fixtures/postcode_anywhere_uk_geocode_v2_00_WR26NJ
|
199
|
-
- test/fixtures/postcode_anywhere_uk_geocode_v2_00_generic_error
|
200
|
-
- test/fixtures/postcode_anywhere_uk_geocode_v2_00_hampshire
|
201
|
-
- test/fixtures/postcode_anywhere_uk_geocode_v2_00_key_limit_exceeded
|
202
|
-
- test/fixtures/postcode_anywhere_uk_geocode_v2_00_no_results
|
203
|
-
- test/fixtures/postcode_anywhere_uk_geocode_v2_00_romsey
|
204
|
-
- test/fixtures/postcode_anywhere_uk_geocode_v2_00_unknown_key
|
205
|
-
- test/fixtures/smarty_streets_11211
|
206
|
-
- test/fixtures/smarty_streets_madison_square_garden
|
207
|
-
- test/fixtures/smarty_streets_no_results
|
208
|
-
- test/fixtures/telize_10_10_10_10
|
209
|
-
- test/fixtures/telize_555_555_555_555
|
210
|
-
- test/fixtures/telize_74_200_247_59
|
211
|
-
- test/fixtures/telize_no_results
|
212
|
-
- test/fixtures/yahoo_error
|
213
|
-
- test/fixtures/yahoo_invalid_key
|
214
|
-
- test/fixtures/yahoo_madison_square_garden
|
215
|
-
- test/fixtures/yahoo_no_results
|
216
|
-
- test/fixtures/yahoo_over_limit
|
217
|
-
- test/fixtures/yandex_canada_rue_dupuis_14
|
218
|
-
- test/fixtures/yandex_invalid_key
|
219
|
-
- test/fixtures/yandex_kremlin
|
220
|
-
- test/fixtures/yandex_new_york
|
221
|
-
- test/fixtures/yandex_no_city_and_town
|
222
|
-
- test/fixtures/yandex_no_results
|
223
|
-
- test/integration/http_client_test.rb
|
224
|
-
- test/mongoid_test_helper.rb
|
225
|
-
- test/test_helper.rb
|
226
|
-
- test/unit/active_record_test.rb
|
227
|
-
- test/unit/cache_test.rb
|
228
|
-
- test/unit/calculations_test.rb
|
229
|
-
- test/unit/configuration_test.rb
|
230
|
-
- test/unit/error_handling_test.rb
|
231
|
-
- test/unit/geocoder_test.rb
|
232
|
-
- test/unit/https_test.rb
|
233
|
-
- test/unit/ip_address_test.rb
|
234
|
-
- test/unit/lookup_test.rb
|
235
|
-
- test/unit/lookups/bing_test.rb
|
236
|
-
- test/unit/lookups/dstk_test.rb
|
237
|
-
- test/unit/lookups/esri_test.rb
|
238
|
-
- test/unit/lookups/freegeoip_test.rb
|
239
|
-
- test/unit/lookups/geocoder_ca_test.rb
|
240
|
-
- test/unit/lookups/geocodio_test.rb
|
241
|
-
- test/unit/lookups/geoip2_test.rb
|
242
|
-
- test/unit/lookups/google_places_details_test.rb
|
243
|
-
- test/unit/lookups/google_premier_test.rb
|
244
|
-
- test/unit/lookups/google_test.rb
|
245
|
-
- test/unit/lookups/mapquest_test.rb
|
246
|
-
- test/unit/lookups/maxmind_local_test.rb
|
247
|
-
- test/unit/lookups/maxmind_test.rb
|
248
|
-
- test/unit/lookups/nominatim_test.rb
|
249
|
-
- test/unit/lookups/okf_test.rb
|
250
|
-
- test/unit/lookups/opencagedata_test.rb
|
251
|
-
- test/unit/lookups/pointpin_test.rb
|
252
|
-
- test/unit/lookups/postcode_anywhere_uk_test.rb
|
253
|
-
- test/unit/lookups/smarty_streets_test.rb
|
254
|
-
- test/unit/lookups/telize_test.rb
|
255
|
-
- test/unit/lookups/yahoo_test.rb
|
256
|
-
- test/unit/method_aliases_test.rb
|
257
|
-
- test/unit/model_test.rb
|
258
|
-
- test/unit/mongoid_test.rb
|
259
|
-
- test/unit/near_test.rb
|
260
|
-
- test/unit/oauth_util_test.rb
|
261
|
-
- test/unit/proxy_test.rb
|
262
|
-
- test/unit/query_test.rb
|
263
|
-
- test/unit/rake_task_test.rb
|
264
|
-
- test/unit/request_test.rb
|
265
|
-
- test/unit/result_test.rb
|
266
|
-
- test/unit/test_mode_test.rb
|
267
162
|
homepage: http://www.rubygeocoder.com
|
268
|
-
licenses:
|
269
|
-
|
163
|
+
licenses:
|
164
|
+
- MIT
|
165
|
+
metadata:
|
166
|
+
source_code_uri: https://github.com/alexreisner/geocoder
|
167
|
+
changelog_uri: https://github.com/alexreisner/geocoder/blob/master/CHANGELOG.md
|
270
168
|
post_install_message:
|
271
169
|
rdoc_options: []
|
272
170
|
require_paths:
|
@@ -275,15 +173,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
275
173
|
requirements:
|
276
174
|
- - ">="
|
277
175
|
- !ruby/object:Gem::Version
|
278
|
-
version:
|
176
|
+
version: 2.0.0
|
279
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
280
178
|
requirements:
|
281
179
|
- - ">="
|
282
180
|
- !ruby/object:Gem::Version
|
283
181
|
version: '0'
|
284
182
|
requirements: []
|
285
|
-
|
286
|
-
rubygems_version: 2.2.2
|
183
|
+
rubygems_version: 3.0.1
|
287
184
|
signing_key:
|
288
185
|
specification_version: 4
|
289
186
|
summary: Complete geocoding solution for Ruby.
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
rvm:
|
2
|
-
- 1.9.2
|
3
|
-
- 1.9.3
|
4
|
-
- 2.0.0
|
5
|
-
- 2.1.2
|
6
|
-
- jruby-19mode
|
7
|
-
- rbx-2
|
8
|
-
gemfile:
|
9
|
-
- Gemfile
|
10
|
-
- gemfiles/Gemfile.mongoid-2.4.x
|
11
|
-
env: SSL_CERT_DIR=/etc/ssl/certs
|
12
|
-
matrix:
|
13
|
-
exclude:
|
14
|
-
- rvm: 1.9.2
|
15
|
-
gemfile: Gemfile
|
16
|
-
env: SSL_CERT_DIR=/etc/ssl/certs
|
17
|
-
- rvm: 1.9.3
|
18
|
-
gemfile: gemfiles/Gemfile.mongoid-2.4.x
|
19
|
-
env: SSL_CERT_DIR=/etc/ssl/certs
|
20
|
-
- rvm: 2.0.0
|
21
|
-
gemfile: gemfiles/Gemfile.mongoid-2.4.x
|
22
|
-
env: SSL_CERT_DIR=/etc/ssl/certs
|
23
|
-
- rvm: 2.1.2
|
24
|
-
gemfile: gemfiles/Gemfile.mongoid-2.4.x
|
25
|
-
env: SSL_CERT_DIR=/etc/ssl/certs
|
26
|
-
- rvm: jruby-19mode
|
27
|
-
gemfile: gemfiles/Gemfile.mongoid-2.4.x
|
28
|
-
env: SSL_CERT_DIR=/etc/ssl/certs
|
29
|
-
- rvm: rbx-2
|
30
|
-
gemfile: gemfiles/Gemfile.mongoid-2.4.x
|
31
|
-
env: SSL_CERT_DIR=/etc/ssl/certs
|
data/Rakefile
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
Bundler::GemHelper.install_tasks
|
3
|
-
|
4
|
-
require 'rake/testtask'
|
5
|
-
Rake::TestTask.new(:test) do |test|
|
6
|
-
test.libs << 'lib' << 'test'
|
7
|
-
test.pattern = 'test/unit/**/*_test.rb'
|
8
|
-
test.verbose = true
|
9
|
-
end
|
10
|
-
|
11
|
-
Rake::TestTask.new(:integration) do |test|
|
12
|
-
test.libs << 'lib' << 'test'
|
13
|
-
test.pattern = 'test/integration/*_test.rb'
|
14
|
-
test.verbose = true
|
15
|
-
end
|
16
|
-
|
17
|
-
task :default => [:test]
|
18
|
-
|
19
|
-
require 'rdoc/task'
|
20
|
-
Rake::RDocTask.new do |rdoc|
|
21
|
-
rdoc.rdoc_dir = 'rdoc'
|
22
|
-
rdoc.title = "Geocoder #{Geocoder::VERSION}"
|
23
|
-
rdoc.rdoc_files.include('*.rdoc')
|
24
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
gemspec :path => '..'
|
4
|
-
|
5
|
-
group :development, :test do
|
6
|
-
gem 'rake'
|
7
|
-
gem 'mongoid', '2.4.11'
|
8
|
-
gem 'bson_ext', :platforms => :ruby
|
9
|
-
gem 'geoip'
|
10
|
-
|
11
|
-
gem 'rails'
|
12
|
-
|
13
|
-
platforms :jruby do
|
14
|
-
gem 'jruby-openssl'
|
15
|
-
end
|
16
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'geocoder/lookups/base'
|
2
|
-
require "geocoder/results/geocoder_us"
|
3
|
-
|
4
|
-
module Geocoder::Lookup
|
5
|
-
class GeocoderUs < Base
|
6
|
-
|
7
|
-
def name
|
8
|
-
"Geocoder.us"
|
9
|
-
end
|
10
|
-
|
11
|
-
def query_url(query)
|
12
|
-
if configuration.api_key
|
13
|
-
"http://#{configuration.api_key}@geocoder.us/member/service/csv/geocode?" + url_query_string(query)
|
14
|
-
else
|
15
|
-
"http://geocoder.us/service/csv/geocode?" + url_query_string(query)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def results(query)
|
22
|
-
return [] unless doc = fetch_data(query)
|
23
|
-
if doc[0].to_s =~ /^(\d+)\:/
|
24
|
-
return []
|
25
|
-
else
|
26
|
-
return [doc.size == 5 ? ((doc[0..1] << nil) + doc[2..4]) : doc]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def query_url_params(query)
|
31
|
-
(query.text =~ /^\d{5}(?:-\d{4})?$/ ? {:zip => query} : {:address => query.sanitized_text}).merge(super)
|
32
|
-
end
|
33
|
-
|
34
|
-
def parse_raw_data(raw_data)
|
35
|
-
raw_data.chomp.split(',')
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
data/lib/geocoder/lookups/okf.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'geocoder/lookups/base'
|
2
|
-
require "geocoder/results/okf"
|
3
|
-
|
4
|
-
module Geocoder::Lookup
|
5
|
-
class Okf < Base
|
6
|
-
|
7
|
-
def name
|
8
|
-
"Okf"
|
9
|
-
end
|
10
|
-
|
11
|
-
def query_url(query)
|
12
|
-
"#{protocol}://data.okf.fi/gis/1/geocode/json?" + url_query_string(query)
|
13
|
-
end
|
14
|
-
|
15
|
-
private # ---------------------------------------------------------------
|
16
|
-
|
17
|
-
def valid_response?(response)
|
18
|
-
status = parse_json(response.body)["status"]
|
19
|
-
super(response) and ['OK', 'ZERO_RESULTS'].include?(status)
|
20
|
-
end
|
21
|
-
|
22
|
-
def results(query)
|
23
|
-
return [] unless doc = fetch_data(query)
|
24
|
-
case doc['status']; when "OK" # OK status implies >0 results
|
25
|
-
return doc['results']
|
26
|
-
end
|
27
|
-
return []
|
28
|
-
end
|
29
|
-
|
30
|
-
def query_url_okf_params(query)
|
31
|
-
params = {
|
32
|
-
(query.reverse_geocode? ? :latlng : :address) => query.sanitized_text,
|
33
|
-
:sensor => "false",
|
34
|
-
:language => (query.language || configuration.language)
|
35
|
-
}
|
36
|
-
params
|
37
|
-
end
|
38
|
-
|
39
|
-
def query_url_params(query)
|
40
|
-
query_url_okf_params(query).merge(super)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|