geocoder 1.2.11 → 1.2.12
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/README.md +10 -5
- data/lib/generators/geocoder/config/templates/initializer.rb +15 -15
- data/lib/geocoder/calculations.rb +5 -2
- data/lib/geocoder/lookups/base.rb +2 -2
- data/lib/geocoder/results/mapquest.rb +4 -0
- data/lib/geocoder/results/pointpin.rb +0 -4
- data/lib/geocoder/version.rb +1 -1
- data/lib/maxmind_database.rb +1 -1
- 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: 0ac038477cf014a8e62f7fec0e684f851cb55bbb
|
4
|
+
data.tar.gz: 3abbf824220bd221ecd033e75c7c14a8ece6057a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42d47442e4839e84bcb0d98c28591ddeb1df2c63d19b1400736c1f90523f32e84b80990efb714551592a8614704a234c24533398c81c48052654aaf2f83d3d7f
|
7
|
+
data.tar.gz: b51c9a638a256db67d025e8ab67001fcb7a482dcae9206931b957952aa215e27c635044c829eecd20043dd901b5a683248155a403baa5f1057954c1711439c3d
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ Your model must have two attributes (database columns) for storing latitude and
|
|
47
47
|
rails generate migration AddLatitudeAndLongitudeToModel latitude:float longitude:float
|
48
48
|
rake db:migrate
|
49
49
|
|
50
|
-
For
|
50
|
+
For geocoding your model must provide a method that returns an address. This can be a single attribute, but it can also be a method that returns a string assembled from different attributes (eg: `city`, `state`, and `country`).
|
51
51
|
|
52
52
|
Next, your model must tell Geocoder which method returns your object's geocodable address:
|
53
53
|
|
@@ -294,7 +294,7 @@ Every `Geocoder::Result` object, `result`, provides the following data:
|
|
294
294
|
|
295
295
|
* `result.latitude` - float
|
296
296
|
* `result.longitude` - float
|
297
|
-
* `result.coordinates` - array of the above two
|
297
|
+
* `result.coordinates` - array of the above two in the form of `[lat,lon]`
|
298
298
|
* `result.address` - string
|
299
299
|
* `result.city` - string
|
300
300
|
* `result.state` - string
|
@@ -351,6 +351,10 @@ Please see the [source code for each lookup](https://github.com/alexreisner/geoc
|
|
351
351
|
# with Nominatim:
|
352
352
|
Geocoder.search("Paris", :params => {:countrycodes => "gb,de,fr,es,us"})
|
353
353
|
|
354
|
+
Or, to search within a particular region with Google:
|
355
|
+
|
356
|
+
Geocoder.search("...", :params => {:region => "..."})
|
357
|
+
|
354
358
|
You can also configure multiple geocoding services at once, like this:
|
355
359
|
|
356
360
|
Geocoder.configure(
|
@@ -464,9 +468,9 @@ The [Google Places Details API](https://developers.google.com/places/documentati
|
|
464
468
|
|
465
469
|
#### Yandex (`:yandex`)
|
466
470
|
|
467
|
-
* **API key**:
|
471
|
+
* **API key**: optional, but without it lookup is territorially limited
|
468
472
|
* **Quota**: 25000 requests / day
|
469
|
-
* **Region**: world
|
473
|
+
* **Region**: world with API key. Otherwise restricted to Russia, Ukraine, Belarus, Kazakhstan, Georgia, Abkhazia, South Ossetia, Armenia, Azerbaijan, Moldova, Turkmenistan, Tajikistan, Uzbekistan, Kyrgyzstan and Turkey
|
470
474
|
* **SSL support**: HTTPS only
|
471
475
|
* **Languages**: Russian, Belarusian, Ukrainian, English, Turkish (only for maps of Turkey)
|
472
476
|
* **Documentation**: http://api.yandex.com.tr/maps/doc/intro/concepts/intro.xml
|
@@ -499,7 +503,7 @@ The [Google Places Details API](https://developers.google.com/places/documentati
|
|
499
503
|
#### Mapquest (`:mapquest`)
|
500
504
|
|
501
505
|
* **API key**: required
|
502
|
-
* **Key signup**:
|
506
|
+
* **Key signup**: https://developer.mapquest.com/plans
|
503
507
|
* **Quota**: ?
|
504
508
|
* **HTTP Headers**: when using the licensed API you can specify a referer like so:
|
505
509
|
`Geocoder.configure(:http_headers => { "Referer" => "http://foo.com" })`
|
@@ -1075,6 +1079,7 @@ Contributions are welcome via pull requests on Github. Please respect the follow
|
|
1075
1079
|
* Remember: Geocoder needs to run outside of Rails. Don't assume things like ActiveSupport are available.
|
1076
1080
|
* Be willing to accept criticism and work on improving your code; Geocoder is used by thousands of developers and care must be taken not to introduce bugs.
|
1077
1081
|
* Be aware that the pull request review process is not immediate, and is generally proportional to the size of the pull request.
|
1082
|
+
* If your pull request is merged, please do not ask for an immediate release of the gem. There are many factors contributing to when releases occur (remember that they affect thousands of apps with Geocoder in their Gemfiles). If necessary, please install from the Github source until the next official release.
|
1078
1083
|
|
1079
1084
|
|
1080
1085
|
Copyright (c) 2009-15 Alex Reisner, released under the MIT license
|
@@ -1,21 +1,21 @@
|
|
1
1
|
Geocoder.configure(
|
2
|
-
#
|
3
|
-
# :
|
4
|
-
# :
|
5
|
-
# :
|
6
|
-
# :
|
7
|
-
# :
|
8
|
-
# :
|
9
|
-
# :
|
10
|
-
# :
|
11
|
-
# :
|
2
|
+
# Geocoding options
|
3
|
+
# timeout: 3, # geocoding service timeout (secs)
|
4
|
+
# lookup: :google, # name of geocoding service (symbol)
|
5
|
+
# language: :en, # ISO-639 language code
|
6
|
+
# use_https: false, # use HTTPS for lookup requests? (if supported)
|
7
|
+
# http_proxy: nil, # HTTP proxy server (user:pass@host:port)
|
8
|
+
# https_proxy: nil, # HTTPS proxy server (user:pass@host:port)
|
9
|
+
# api_key: nil, # API key for geocoding service
|
10
|
+
# cache: nil, # cache object (must respond to #[], #[]=, and #keys)
|
11
|
+
# cache_prefix: 'geocoder:', # prefix (string) to use for all cache keys
|
12
12
|
|
13
|
-
#
|
13
|
+
# Exceptions that should not be rescued by default
|
14
14
|
# (if you want to implement custom error handling);
|
15
15
|
# supports SocketError and TimeoutError
|
16
|
-
# :
|
16
|
+
# always_raise: [],
|
17
17
|
|
18
|
-
#
|
19
|
-
# :
|
20
|
-
# :
|
18
|
+
# Calculation options
|
19
|
+
# units: :mi, # :km for kilometers or :mi for miles
|
20
|
+
# distances: :linear # :spherical or :linear
|
21
21
|
)
|
@@ -237,11 +237,14 @@ module Geocoder
|
|
237
237
|
#
|
238
238
|
# * <tt>:units</tt> - <tt>:mi</tt> or <tt>:km</tt>
|
239
239
|
# Use Geocoder.configure(:units => ...) to configure default units.
|
240
|
+
# * <tt>:seed</tt> - The seed for the random number generator
|
240
241
|
def random_point_near(center, radius, options = {})
|
241
242
|
|
242
243
|
# set default options
|
243
244
|
options[:units] ||= Geocoder.config.units
|
244
245
|
|
246
|
+
random = Random.new(options[:seed] || Random.new_seed)
|
247
|
+
|
245
248
|
# convert to coordinate arrays
|
246
249
|
center = extract_coordinates(center)
|
247
250
|
|
@@ -249,11 +252,11 @@ module Geocoder
|
|
249
252
|
max_degree_delta = 360.0 * (radius / earth_circumference)
|
250
253
|
|
251
254
|
# random bearing in radians
|
252
|
-
theta = 2 * Math::PI * rand
|
255
|
+
theta = 2 * Math::PI * random.rand
|
253
256
|
|
254
257
|
# random radius, use the square root to ensure a uniform
|
255
258
|
# distribution of points over the circle
|
256
|
-
r = Math.sqrt(rand) * max_degree_delta
|
259
|
+
r = Math.sqrt(random.rand) * max_degree_delta
|
257
260
|
|
258
261
|
delta_lat, delta_long = [r * Math.cos(theta), r * Math.sin(theta)]
|
259
262
|
[center[0] + delta_lat, center[1] + delta_long]
|
@@ -190,7 +190,7 @@ module Geocoder
|
|
190
190
|
else
|
191
191
|
JSON.parse(data)
|
192
192
|
end
|
193
|
-
rescue
|
193
|
+
rescue
|
194
194
|
raise_error(ResponseParseError.new(data)) or Geocoder.log(:warn, "Geocoding API's response was not valid JSON: #{data}")
|
195
195
|
end
|
196
196
|
|
@@ -283,7 +283,7 @@ module Geocoder
|
|
283
283
|
end
|
284
284
|
client.request(req)
|
285
285
|
end
|
286
|
-
rescue
|
286
|
+
rescue Timeout::Error
|
287
287
|
raise Geocoder::LookupTimeout
|
288
288
|
end
|
289
289
|
|
data/lib/geocoder/version.rb
CHANGED
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"
|
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.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Reisner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-29 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,
|