rails-geocoder 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +5 -0
- data/README.rdoc +2 -0
- data/lib/geocoder.rb +2 -2
- metadata +19 -27
- data/.document +0 -5
- data/.gitignore +0 -5
- data/VERSION +0 -1
- data/init.rb +0 -1
- data/lib/tasks/geocoder_tasks.rake +0 -15
- data/rails-geocoder.gemspec +0 -55
- data/test/fixtures/madison_square_garden.json +0 -57
data/CHANGELOG.rdoc
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
Per-release changes to Geocoder.
|
4
4
|
|
5
|
+
== 0.9.6 (2011 Jan 19)
|
6
|
+
|
7
|
+
* Fix incompatibility with will_paginate gem.
|
8
|
+
* Include table names in GROUP BY clause of nearby scope to avoid ambiguity in joins.
|
9
|
+
|
5
10
|
== 0.9.5 (2010 Oct 15)
|
6
11
|
|
7
12
|
* Fix broken PostgreSQL compatibility (now 100% compatible).
|
data/README.rdoc
CHANGED
@@ -105,6 +105,8 @@ Please see the code for more methods and detailed information about arguments (e
|
|
105
105
|
|
106
106
|
SQLite's lack of trigonometric functions requires an alternate implementation of the +near+ method (scope). When using SQLite, Geocoder will automatically use a less accurate algorithm for finding objects near a given point. Results of this algorithm should not be trusted too much as it will return objects that are outside the given radius.
|
107
107
|
|
108
|
+
It is also not possible to calculate distances between points without the trig functions so you cannot sort results by "nearness."
|
109
|
+
|
108
110
|
|
109
111
|
=== Discussion
|
110
112
|
|
data/lib/geocoder.rb
CHANGED
@@ -74,7 +74,6 @@ module Geocoder
|
|
74
74
|
# http://www.scribd.com/doc/2569355/Geo-Distance-Search-with-MySQL
|
75
75
|
#
|
76
76
|
def full_near_scope_options(latitude, longitude, radius, options)
|
77
|
-
options[:order] ||= 'distance ASC'
|
78
77
|
lat_attr = geocoder_options[:latitude]
|
79
78
|
lon_attr = geocoder_options[:longitude]
|
80
79
|
distance = "3956 * 2 * ASIN(SQRT(" +
|
@@ -83,6 +82,7 @@ module Geocoder
|
|
83
82
|
"COS(#{lat_attr} * PI() / 180) * " +
|
84
83
|
"POWER(SIN((#{longitude} - #{lon_attr}) * " +
|
85
84
|
"PI() / 180 / 2), 2) ))"
|
85
|
+
options[:order] ||= "#{distance} ASC"
|
86
86
|
default_near_scope_options(latitude, longitude, radius, options).merge(
|
87
87
|
:select => "#{options[:select] || '*'}, #{distance} AS distance",
|
88
88
|
:having => "#{distance} <= #{radius}"
|
@@ -115,7 +115,7 @@ module Geocoder
|
|
115
115
|
conditions << obj.id
|
116
116
|
end
|
117
117
|
{
|
118
|
-
:group => columns.map{ |c| c.name}.join(','),
|
118
|
+
:group => columns.map{ |c| "#{table_name}.#{c.name}" }.join(','),
|
119
119
|
:order => options[:order],
|
120
120
|
:limit => options[:limit],
|
121
121
|
:offset => options[:offset],
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-geocoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 6
|
10
|
+
version: 0.9.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Reisner
|
@@ -15,41 +15,34 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-18 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description: Geocoder adds object geocoding and
|
23
|
-
email:
|
22
|
+
description: Geocoder adds object geocoding and distance calculations to ActiveRecord models. It does not rely on proprietary database functions so finding geocoded objects in a given area is easily done using out-of-the-box MySQL, PostgreSQL, or SQLite.
|
23
|
+
email:
|
24
|
+
- alex@alexreisner.com
|
24
25
|
executables: []
|
25
26
|
|
26
27
|
extensions: []
|
27
28
|
|
28
|
-
extra_rdoc_files:
|
29
|
-
|
30
|
-
- README.rdoc
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
31
|
files:
|
32
|
-
- .document
|
33
|
-
- .gitignore
|
34
|
-
- CHANGELOG.rdoc
|
35
|
-
- LICENSE
|
36
|
-
- README.rdoc
|
37
|
-
- Rakefile
|
38
|
-
- VERSION
|
39
|
-
- init.rb
|
40
32
|
- lib/geocoder.rb
|
41
|
-
- lib/tasks/geocoder_tasks.rake
|
42
|
-
- rails-geocoder.gemspec
|
43
|
-
- test/fixtures/madison_square_garden.json
|
44
|
-
- test/geocoder_test.rb
|
45
33
|
- test/test_helper.rb
|
34
|
+
- test/geocoder_test.rb
|
35
|
+
- CHANGELOG.rdoc
|
36
|
+
- Rakefile
|
37
|
+
- README.rdoc
|
38
|
+
- LICENSE
|
46
39
|
has_rdoc: true
|
47
40
|
homepage: http://github.com/alexreisner/geocoder
|
48
41
|
licenses: []
|
49
42
|
|
50
43
|
post_install_message:
|
51
|
-
rdoc_options:
|
52
|
-
|
44
|
+
rdoc_options: []
|
45
|
+
|
53
46
|
require_paths:
|
54
47
|
- lib
|
55
48
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -76,7 +69,6 @@ rubyforge_project:
|
|
76
69
|
rubygems_version: 1.3.7
|
77
70
|
signing_key:
|
78
71
|
specification_version: 3
|
79
|
-
summary:
|
80
|
-
test_files:
|
81
|
-
|
82
|
-
- test/geocoder_test.rb
|
72
|
+
summary: Simple, database-agnostic geocoding and distance calculations for Rails.
|
73
|
+
test_files: []
|
74
|
+
|
data/.document
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.9.5
|
data/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'geocoder'
|
@@ -1,15 +0,0 @@
|
|
1
|
-
def klass
|
2
|
-
class_name = ENV['CLASS'] || ENV['class']
|
3
|
-
raise "Please specify a CLASS (model)" unless class_name
|
4
|
-
Object.const_get(class_name)
|
5
|
-
end
|
6
|
-
|
7
|
-
namespace :geocode do
|
8
|
-
|
9
|
-
desc "Geocode all objects without coordinates."
|
10
|
-
task :all => :environment do
|
11
|
-
klass.not_geocoded.each do |obj|
|
12
|
-
obj.fetch_coordinates!
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/rails-geocoder.gemspec
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{rails-geocoder}
|
8
|
-
s.version = "0.9.5"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Alex Reisner"]
|
12
|
-
s.date = %q{2010-10-15}
|
13
|
-
s.description = %q{Geocoder adds object geocoding and database-agnostic distance calculations to Ruby on Rails. It does not rely on proprietary database functions so finding geocoded objects in a given area is easily done using out-of-the-box MySQL or even SQLite.}
|
14
|
-
s.email = %q{alex@alexreisner.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"CHANGELOG.rdoc",
|
23
|
-
"LICENSE",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"init.rb",
|
28
|
-
"lib/geocoder.rb",
|
29
|
-
"lib/tasks/geocoder_tasks.rake",
|
30
|
-
"rails-geocoder.gemspec",
|
31
|
-
"test/fixtures/madison_square_garden.json",
|
32
|
-
"test/geocoder_test.rb",
|
33
|
-
"test/test_helper.rb"
|
34
|
-
]
|
35
|
-
s.homepage = %q{http://github.com/alexreisner/geocoder}
|
36
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
37
|
-
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = %q{1.3.7}
|
39
|
-
s.summary = %q{Add geocoding functionality to Rails models.}
|
40
|
-
s.test_files = [
|
41
|
-
"test/test_helper.rb",
|
42
|
-
"test/geocoder_test.rb"
|
43
|
-
]
|
44
|
-
|
45
|
-
if s.respond_to? :specification_version then
|
46
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
-
s.specification_version = 3
|
48
|
-
|
49
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
-
else
|
51
|
-
end
|
52
|
-
else
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
@@ -1,57 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"status": "OK",
|
3
|
-
"results": [ {
|
4
|
-
"types": [ "street_address" ],
|
5
|
-
"formatted_address": "4 Penn Plaza, New York, NY 10001, USA",
|
6
|
-
"address_components": [ {
|
7
|
-
"long_name": "4",
|
8
|
-
"short_name": "4",
|
9
|
-
"types": [ "street_number" ]
|
10
|
-
}, {
|
11
|
-
"long_name": "Penn Plaza",
|
12
|
-
"short_name": "Penn Plaza",
|
13
|
-
"types": [ "route" ]
|
14
|
-
}, {
|
15
|
-
"long_name": "Manhattan",
|
16
|
-
"short_name": "Manhattan",
|
17
|
-
"types": [ "sublocality", "political" ]
|
18
|
-
}, {
|
19
|
-
"long_name": "New York",
|
20
|
-
"short_name": "New York",
|
21
|
-
"types": [ "locality", "political" ]
|
22
|
-
}, {
|
23
|
-
"long_name": "New York",
|
24
|
-
"short_name": "New York",
|
25
|
-
"types": [ "administrative_area_level_2", "political" ]
|
26
|
-
}, {
|
27
|
-
"long_name": "New York",
|
28
|
-
"short_name": "NY",
|
29
|
-
"types": [ "administrative_area_level_1", "political" ]
|
30
|
-
}, {
|
31
|
-
"long_name": "United States",
|
32
|
-
"short_name": "US",
|
33
|
-
"types": [ "country", "political" ]
|
34
|
-
}, {
|
35
|
-
"long_name": "10001",
|
36
|
-
"short_name": "10001",
|
37
|
-
"types": [ "postal_code" ]
|
38
|
-
} ],
|
39
|
-
"geometry": {
|
40
|
-
"location": {
|
41
|
-
"lat": 40.7503540,
|
42
|
-
"lng": -73.9933710
|
43
|
-
},
|
44
|
-
"location_type": "ROOFTOP",
|
45
|
-
"viewport": {
|
46
|
-
"southwest": {
|
47
|
-
"lat": 40.7473324,
|
48
|
-
"lng": -73.9965316
|
49
|
-
},
|
50
|
-
"northeast": {
|
51
|
-
"lat": 40.7536276,
|
52
|
-
"lng": -73.9902364
|
53
|
-
}
|
54
|
-
}
|
55
|
-
}
|
56
|
-
} ]
|
57
|
-
}
|