graticule 0.2.10 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/CHANGELOG.txt +6 -0
- data/Manifest.txt +4 -0
- data/README.txt +14 -2
- data/Rakefile +74 -17
- data/VERSION +1 -0
- data/graticule.gemspec +147 -0
- data/lib/graticule.rb +1 -0
- data/lib/graticule/geocoder/base.rb +1 -1
- data/lib/graticule/geocoder/geocoder_us.rb +4 -3
- data/lib/graticule/geocoder/mapquest.rb +87 -0
- data/lib/graticule/location.rb +1 -1
- data/lib/graticule/version.rb +1 -1
- data/test/fixtures/responses/mapquest/multi_result.xml +1 -0
- data/test/fixtures/responses/mapquest/success.xml +1 -0
- data/test/unit/graticule/geocoder/mapquest_test.rb +47 -0
- metadata +21 -25
data/.gitignore
ADDED
data/CHANGELOG.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -20,6 +20,7 @@ lib/graticule/geocoder/geocoder_us.rb
|
|
20
20
|
lib/graticule/geocoder/google.rb
|
21
21
|
lib/graticule/geocoder/host_ip.rb
|
22
22
|
lib/graticule/geocoder/local_search_maps.rb
|
23
|
+
lib/graticule/geocoder/mapquest.rb
|
23
24
|
lib/graticule/geocoder/meta_carta.rb
|
24
25
|
lib/graticule/geocoder/multi.rb
|
25
26
|
lib/graticule/geocoder/multimap.rb
|
@@ -50,6 +51,8 @@ test/fixtures/responses/host_ip/unknown.txt
|
|
50
51
|
test/fixtures/responses/local_search_maps/empty.txt
|
51
52
|
test/fixtures/responses/local_search_maps/not_found.txt
|
52
53
|
test/fixtures/responses/local_search_maps/success.txt
|
54
|
+
test/fixtures/responses/mapquest/multi_result.xml
|
55
|
+
test/fixtures/responses/mapquest/success.xml
|
53
56
|
test/fixtures/responses/meta_carta/bad_address.xml
|
54
57
|
test/fixtures/responses/meta_carta/multiple.xml
|
55
58
|
test/fixtures/responses/meta_carta/success.xml
|
@@ -71,6 +74,7 @@ test/unit/graticule/geocoder/geocoders.rb
|
|
71
74
|
test/unit/graticule/geocoder/google_test.rb
|
72
75
|
test/unit/graticule/geocoder/host_ip_test.rb
|
73
76
|
test/unit/graticule/geocoder/local_search_maps_test.rb
|
77
|
+
test/unit/graticule/geocoder/mapquest_test.rb
|
74
78
|
test/unit/graticule/geocoder/meta_carta_test.rb
|
75
79
|
test/unit/graticule/geocoder/multi_test.rb
|
76
80
|
test/unit/graticule/geocoder/multimap_test.rb
|
data/README.txt
CHANGED
@@ -24,6 +24,18 @@ Graticule includes a command line interface (CLI).
|
|
24
24
|
Washington, DC US
|
25
25
|
latitude: 38.895222, longitude: -77.036758
|
26
26
|
|
27
|
-
=
|
27
|
+
= How to contribute
|
28
28
|
|
29
|
-
|
29
|
+
If you find what you might think is a bug:
|
30
|
+
|
31
|
+
1. Check the GitHub issue tracker to see if anyone else has had the same issue.
|
32
|
+
http://github.com/collectiveidea/graticule/issues/
|
33
|
+
2. If you don't see anything, create an issue with information on how to reproduce it.
|
34
|
+
|
35
|
+
If you want to contribute an enhancement or a fix:
|
36
|
+
|
37
|
+
1. Fork the project on github.
|
38
|
+
http://github.com/collectiveidea/graticule/
|
39
|
+
2. Make your changes with tests.
|
40
|
+
3. Commit the changes without making changes to the Rakefile, VERSION, or any other files that aren't related to your enhancement or fix
|
41
|
+
4. Send a pull request.
|
data/Rakefile
CHANGED
@@ -1,23 +1,79 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
rescue LoadError
|
4
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
5
|
+
exit 1
|
6
|
+
end
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
require 'rcov/rcovtask'
|
10
|
+
|
11
|
+
Jeweler::Tasks.new do |s|
|
12
|
+
s.name = "graticule"
|
13
|
+
s.rubyforge_project = "graticule"
|
14
|
+
s.author = 'Brandon Keepers'
|
15
|
+
s.email = 'brandon@opensoul.org'
|
16
|
+
s.summary = "API for using all the popular geocoding services."
|
17
|
+
s.description = 'Graticule is a geocoding API that provides a common interface to all the popular services, including Google, Yahoo, Geocoder.us, and MetaCarta.'
|
18
|
+
s.homepage = "http://github.com/collectiveidea/graticule"
|
19
|
+
s.add_dependency "activesupport"
|
20
|
+
s.has_rdoc = true
|
21
|
+
s.extra_rdoc_files = ["README.txt"]
|
22
|
+
s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"]
|
23
|
+
s.test_files = Dir['test/**/*.{yml,rb}']
|
18
24
|
end
|
19
25
|
|
26
|
+
desc 'Default: run unit tests.'
|
27
|
+
task :default => :test
|
28
|
+
|
29
|
+
desc 'Run the unit tests'
|
30
|
+
Rake::TestTask.new(:test) do |t|
|
31
|
+
t.libs << 'lib'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = true
|
34
|
+
end
|
20
35
|
|
36
|
+
desc 'Generate documentatio'
|
37
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
38
|
+
rdoc.rdoc_dir = 'rdoc'
|
39
|
+
rdoc.title = 'Graticule'
|
40
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
41
|
+
rdoc.rdoc_files.include('README.txt')
|
42
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
43
|
+
end
|
44
|
+
|
45
|
+
namespace :test do
|
46
|
+
desc "just rcov minus html output"
|
47
|
+
Rcov::RcovTask.new(:coverage) do |t|
|
48
|
+
# t.libs << 'test'
|
49
|
+
t.test_files = FileList['test/**/*_test.rb']
|
50
|
+
t.output_dir = 'coverage'
|
51
|
+
t.verbose = true
|
52
|
+
t.rcov_opts = %w(--exclude test,/usr/lib/ruby,/Library/Ruby,$HOME/.gem --sort coverage)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
require 'rake/contrib/sshpublisher'
|
57
|
+
namespace :rubyforge do
|
58
|
+
|
59
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
60
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
61
|
+
|
62
|
+
namespace :release do
|
63
|
+
desc "Publish RDoc to RubyForge."
|
64
|
+
task :docs => [:rdoc] do
|
65
|
+
config = YAML.load(
|
66
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
67
|
+
)
|
68
|
+
|
69
|
+
host = "#{config['username']}@rubyforge.org"
|
70
|
+
remote_dir = "/var/www/gforge-projects/the-perfect-gem/"
|
71
|
+
local_dir = 'rdoc'
|
72
|
+
|
73
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
21
77
|
|
22
78
|
namespace :test do
|
23
79
|
namespace :cache do
|
@@ -57,6 +113,7 @@ namespace :test do
|
|
57
113
|
end
|
58
114
|
end
|
59
115
|
|
116
|
+
require 'active_support'
|
60
117
|
require 'net/http'
|
61
118
|
require 'uri'
|
62
119
|
RESPONSES_PATH = File.dirname(__FILE__) + '/test/fixtures/responses'
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.12
|
data/graticule.gemspec
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{graticule}
|
8
|
+
s.version = "0.2.12"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Brandon Keepers"]
|
12
|
+
s.date = %q{2009-09-06}
|
13
|
+
s.default_executable = %q{geocode}
|
14
|
+
s.description = %q{Graticule is a geocoding API that provides a common interface to all the popular services, including Google, Yahoo, Geocoder.us, and MetaCarta.}
|
15
|
+
s.email = %q{brandon@opensoul.org}
|
16
|
+
s.executables = ["geocode"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"README.txt"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".gitignore",
|
22
|
+
"CHANGELOG.txt",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"Manifest.txt",
|
25
|
+
"README.txt",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/geocode",
|
29
|
+
"graticule.gemspec",
|
30
|
+
"init.rb",
|
31
|
+
"lib/graticule.rb",
|
32
|
+
"lib/graticule/cli.rb",
|
33
|
+
"lib/graticule/core_ext.rb",
|
34
|
+
"lib/graticule/distance.rb",
|
35
|
+
"lib/graticule/distance/haversine.rb",
|
36
|
+
"lib/graticule/distance/spherical.rb",
|
37
|
+
"lib/graticule/distance/vincenty.rb",
|
38
|
+
"lib/graticule/geocoder.rb",
|
39
|
+
"lib/graticule/geocoder/base.rb",
|
40
|
+
"lib/graticule/geocoder/bogus.rb",
|
41
|
+
"lib/graticule/geocoder/geocoder_ca.rb",
|
42
|
+
"lib/graticule/geocoder/geocoder_us.rb",
|
43
|
+
"lib/graticule/geocoder/google.rb",
|
44
|
+
"lib/graticule/geocoder/host_ip.rb",
|
45
|
+
"lib/graticule/geocoder/local_search_maps.rb",
|
46
|
+
"lib/graticule/geocoder/mapquest.rb",
|
47
|
+
"lib/graticule/geocoder/meta_carta.rb",
|
48
|
+
"lib/graticule/geocoder/multi.rb",
|
49
|
+
"lib/graticule/geocoder/multimap.rb",
|
50
|
+
"lib/graticule/geocoder/postcode_anywhere.rb",
|
51
|
+
"lib/graticule/geocoder/rest.rb",
|
52
|
+
"lib/graticule/geocoder/yahoo.rb",
|
53
|
+
"lib/graticule/location.rb",
|
54
|
+
"lib/graticule/version.rb",
|
55
|
+
"site/index.html",
|
56
|
+
"site/plugin.html",
|
57
|
+
"site/stylesheets/style.css",
|
58
|
+
"test/config.yml.default",
|
59
|
+
"test/fixtures/responses/geocoder_us/success.xml",
|
60
|
+
"test/fixtures/responses/geocoder_us/unknown.xml",
|
61
|
+
"test/fixtures/responses/google/badkey.xml",
|
62
|
+
"test/fixtures/responses/google/limit.xml",
|
63
|
+
"test/fixtures/responses/google/missing_address.xml",
|
64
|
+
"test/fixtures/responses/google/only_coordinates.xml",
|
65
|
+
"test/fixtures/responses/google/partial.xml",
|
66
|
+
"test/fixtures/responses/google/server_error.xml",
|
67
|
+
"test/fixtures/responses/google/success.xml",
|
68
|
+
"test/fixtures/responses/google/success_multiple_results.xml",
|
69
|
+
"test/fixtures/responses/google/unavailable.xml",
|
70
|
+
"test/fixtures/responses/google/unknown_address.xml",
|
71
|
+
"test/fixtures/responses/host_ip/private.txt",
|
72
|
+
"test/fixtures/responses/host_ip/success.txt",
|
73
|
+
"test/fixtures/responses/host_ip/unknown.txt",
|
74
|
+
"test/fixtures/responses/local_search_maps/empty.txt",
|
75
|
+
"test/fixtures/responses/local_search_maps/not_found.txt",
|
76
|
+
"test/fixtures/responses/local_search_maps/success.txt",
|
77
|
+
"test/fixtures/responses/mapquest/multi_result.xml",
|
78
|
+
"test/fixtures/responses/mapquest/success.xml",
|
79
|
+
"test/fixtures/responses/meta_carta/bad_address.xml",
|
80
|
+
"test/fixtures/responses/meta_carta/multiple.xml",
|
81
|
+
"test/fixtures/responses/meta_carta/success.xml",
|
82
|
+
"test/fixtures/responses/multimap/missing_params.xml",
|
83
|
+
"test/fixtures/responses/multimap/no_matches.xml",
|
84
|
+
"test/fixtures/responses/multimap/success.xml",
|
85
|
+
"test/fixtures/responses/postcode_anywhere/badkey.xml",
|
86
|
+
"test/fixtures/responses/postcode_anywhere/canada.xml",
|
87
|
+
"test/fixtures/responses/postcode_anywhere/empty.xml",
|
88
|
+
"test/fixtures/responses/postcode_anywhere/success.xml",
|
89
|
+
"test/fixtures/responses/postcode_anywhere/uk.xml",
|
90
|
+
"test/fixtures/responses/yahoo/success.xml",
|
91
|
+
"test/fixtures/responses/yahoo/unknown_address.xml",
|
92
|
+
"test/mocks/uri.rb",
|
93
|
+
"test/test_helper.rb",
|
94
|
+
"test/unit/graticule/distance_test.rb",
|
95
|
+
"test/unit/graticule/geocoder/geocoder_us_test.rb",
|
96
|
+
"test/unit/graticule/geocoder/geocoders.rb",
|
97
|
+
"test/unit/graticule/geocoder/google_test.rb",
|
98
|
+
"test/unit/graticule/geocoder/host_ip_test.rb",
|
99
|
+
"test/unit/graticule/geocoder/local_search_maps_test.rb",
|
100
|
+
"test/unit/graticule/geocoder/mapquest_test.rb",
|
101
|
+
"test/unit/graticule/geocoder/meta_carta_test.rb",
|
102
|
+
"test/unit/graticule/geocoder/multi_test.rb",
|
103
|
+
"test/unit/graticule/geocoder/multimap_test.rb",
|
104
|
+
"test/unit/graticule/geocoder/postcode_anywhere_test.rb",
|
105
|
+
"test/unit/graticule/geocoder/yahoo_test.rb",
|
106
|
+
"test/unit/graticule/geocoder_test.rb",
|
107
|
+
"test/unit/graticule/location_test.rb"
|
108
|
+
]
|
109
|
+
s.has_rdoc = true
|
110
|
+
s.homepage = %q{http://github.com/collectiveidea/graticule}
|
111
|
+
s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"]
|
112
|
+
s.require_paths = ["lib"]
|
113
|
+
s.rubyforge_project = %q{graticule}
|
114
|
+
s.rubygems_version = %q{1.3.1}
|
115
|
+
s.summary = %q{API for using all the popular geocoding services.}
|
116
|
+
s.test_files = [
|
117
|
+
"test/mocks/uri.rb",
|
118
|
+
"test/test_helper.rb",
|
119
|
+
"test/unit/graticule/distance_test.rb",
|
120
|
+
"test/unit/graticule/geocoder/geocoder_us_test.rb",
|
121
|
+
"test/unit/graticule/geocoder/geocoders.rb",
|
122
|
+
"test/unit/graticule/geocoder/google_test.rb",
|
123
|
+
"test/unit/graticule/geocoder/host_ip_test.rb",
|
124
|
+
"test/unit/graticule/geocoder/local_search_maps_test.rb",
|
125
|
+
"test/unit/graticule/geocoder/mapquest_test.rb",
|
126
|
+
"test/unit/graticule/geocoder/meta_carta_test.rb",
|
127
|
+
"test/unit/graticule/geocoder/multi_test.rb",
|
128
|
+
"test/unit/graticule/geocoder/multimap_test.rb",
|
129
|
+
"test/unit/graticule/geocoder/postcode_anywhere_test.rb",
|
130
|
+
"test/unit/graticule/geocoder/yahoo_test.rb",
|
131
|
+
"test/unit/graticule/geocoder_test.rb",
|
132
|
+
"test/unit/graticule/location_test.rb"
|
133
|
+
]
|
134
|
+
|
135
|
+
if s.respond_to? :specification_version then
|
136
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
137
|
+
s.specification_version = 2
|
138
|
+
|
139
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
140
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
141
|
+
else
|
142
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
143
|
+
end
|
144
|
+
else
|
145
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
146
|
+
end
|
147
|
+
end
|
data/lib/graticule.rb
CHANGED
@@ -19,6 +19,7 @@ require 'graticule/geocoder/local_search_maps'
|
|
19
19
|
require 'graticule/geocoder/meta_carta'
|
20
20
|
require 'graticule/geocoder/postcode_anywhere'
|
21
21
|
require 'graticule/geocoder/multimap'
|
22
|
+
require 'graticule/geocoder/mapquest'
|
22
23
|
require 'graticule/distance'
|
23
24
|
require 'graticule/distance/haversine'
|
24
25
|
require 'graticule/distance/spherical'
|
@@ -41,9 +41,10 @@ module Graticule #:nodoc:
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def check_error(xml) #:nodoc:
|
44
|
-
|
45
|
-
raise
|
46
|
-
raise Error,
|
44
|
+
text = xml.to_s
|
45
|
+
raise AddressError, text if text =~ /couldn't find this address! sorry/
|
46
|
+
raise Error, text if text =~ /Your browser sent a request that this server could not understand./
|
47
|
+
raise Error, text if !(text =~ /geo:Point/)
|
47
48
|
end
|
48
49
|
|
49
50
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Graticule #:nodoc:
|
2
|
+
module Geocoder #:nodoc:
|
3
|
+
|
4
|
+
# Mapquest requires both a client id and a password, which you can
|
5
|
+
# get by registering at:
|
6
|
+
# http://developer.mapquest.com/Home/Register?_devAPISignup_WAR_devAPISignup_action=signup&_devAPISignup_WAR_devAPISignup_clientType=Developer
|
7
|
+
#
|
8
|
+
# mq = Graticule.service(:mapquest).new(CLIENT_ID, PASSWORD)
|
9
|
+
# location = gg.locate('44 Allen Rd., Lovell, ME 04051')
|
10
|
+
# [42.78942, -86.104424]
|
11
|
+
#
|
12
|
+
class Mapquest < Rest
|
13
|
+
# I would link to the documentation here, but there is none that will do anything but confuse you.
|
14
|
+
|
15
|
+
PRECISION = {
|
16
|
+
'L1' => :address,
|
17
|
+
'I1' => :street,
|
18
|
+
'B1' => :street,
|
19
|
+
'B2' => :street,
|
20
|
+
'B3' => :street,
|
21
|
+
'Z3' => :zip,
|
22
|
+
'Z4' => :zip,
|
23
|
+
'Z2' => :zip,
|
24
|
+
'Z1' => :zip,
|
25
|
+
'A5' => :city,
|
26
|
+
'A4' => :county,
|
27
|
+
'A3' => :state,
|
28
|
+
'A1' => :country
|
29
|
+
}
|
30
|
+
|
31
|
+
def initialize(client_id, password)
|
32
|
+
@password = password
|
33
|
+
@client_id = client_id
|
34
|
+
@url = URI.parse('http://geocode.dev.mapquest.com/mq/mqserver.dll')
|
35
|
+
end
|
36
|
+
|
37
|
+
# Locates +address+ returning a Location
|
38
|
+
def locate(address)
|
39
|
+
get :q => address.is_a?(String) ? address : location_from_params(address).to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def make_url(params) #:nodoc
|
45
|
+
query = "e=5&<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><Geocode Version=\"1\"> \
|
46
|
+
#{address_string(params[:q])}#{authentication_string}</Geocode>"
|
47
|
+
url = @url.dup
|
48
|
+
url.query = URI.escape(query)
|
49
|
+
url
|
50
|
+
end
|
51
|
+
|
52
|
+
# Extracts a location from +xml+.
|
53
|
+
def parse_response(xml) #:nodoc:
|
54
|
+
longitude = xml.elements['/GeocodeResponse/LocationCollection/GeoAddress/LatLng/Lng'].text.to_f
|
55
|
+
latitude = xml.elements['/GeocodeResponse/LocationCollection/GeoAddress/LatLng/Lat'].text.to_f
|
56
|
+
returning Location.new(:latitude => latitude, :longitude => longitude) do |l|
|
57
|
+
address = REXML::XPath.first(xml, '/GeocodeResponse/LocationCollection/GeoAddress')
|
58
|
+
|
59
|
+
if address
|
60
|
+
l.street = value(address.elements['./Street/text()'])
|
61
|
+
l.locality = value(address.elements['./AdminArea5/text()'])
|
62
|
+
l.region = value(address.elements['./AdminArea3/text()'])
|
63
|
+
l.postal_code = value(address.elements['./PostalCode/text()'])
|
64
|
+
l.country = value(address.elements['./AdminArea1/text()'])
|
65
|
+
l.precision = PRECISION[value(address.elements['./ResultCode/text()'])[0,2]]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Extracts and raises any errors in +xml+
|
71
|
+
def check_error(xml) #:nodoc
|
72
|
+
end
|
73
|
+
|
74
|
+
def value(element)
|
75
|
+
element.value if element
|
76
|
+
end
|
77
|
+
|
78
|
+
def authentication_string
|
79
|
+
"<Authentication Version=\"2\"><Password>#{@password}</Password><ClientId>#{@client_id}</ClientId></Authentication>"
|
80
|
+
end
|
81
|
+
|
82
|
+
def address_string(query)
|
83
|
+
"<Address><Street>#{query}</Street></Address><GeocodeOptionsCollection Count=\"0\"/>"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/graticule/location.rb
CHANGED
data/lib/graticule/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="ISO-8859-1"?><GeocodeResponse><LocationCollection Count="10"><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Suffolk County</AdminArea4><AdminArea5>Stony Brook</AdminArea5><LatLng><Lat>40.925598</Lat><Lng>-73.141403</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Rockland County</AdminArea4><AdminArea5>Stony Point</AdminArea5><LatLng><Lat>41.229401</Lat><Lng>-73.987503</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Dutchess County</AdminArea4><AdminArea5>Staatsburg</AdminArea5><LatLng><Lat>41.849701</Lat><Lng>-73.930603</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Delaware County</AdminArea4><AdminArea5>Stamford</AdminArea5><LatLng><Lat>42.407200</Lat><Lng>-74.614700</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Clinton County</AdminArea4><AdminArea5>Standish</AdminArea5><LatLng><Lat>44.689201</Lat><Lng>-73.949402</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Albany County</AdminArea4><AdminArea5>Stanford Heights</AdminArea5><LatLng><Lat>42.765598</Lat><Lng>-73.889397</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Dutchess County</AdminArea4><AdminArea5>Stanfordville</AdminArea5><LatLng><Lat>41.867199</Lat><Lng>-73.714699</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Allegany County</AdminArea4><AdminArea5>Stannards</AdminArea5><LatLng><Lat>42.086399</Lat><Lng>-77.922501</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Saint Lawrence County</AdminArea4><AdminArea5>Star Lake</AdminArea5><LatLng><Lat>44.159698</Lat><Lng>-75.031898</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Rensselaer County</AdminArea4><AdminArea5>Stephentown</AdminArea5><LatLng><Lat>42.548599</Lat><Lng>-73.374397</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress></LocationCollection></GeocodeResponse>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="ISO-8859-1"?><GeocodeResponse><LocationCollection Count="1"><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>ME</AdminArea3><AdminArea4>Oxford County</AdminArea4><AdminArea5>Lovell</AdminArea5><PostalCode>04051-3919</PostalCode><Street>44 Allen Rd</Street><LatLng><Lat>44.152019</Lat><Lng>-70.892706</Lng></LatLng><ResultCode>L1AAA</ResultCode><SourceId>navt</SourceId></GeoAddress></LocationCollection></GeocodeResponse>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
2
|
+
|
3
|
+
module Graticule
|
4
|
+
module Geocoder
|
5
|
+
class MapquestTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@geocoder = Mapquest.new('client_id', 'password')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_success
|
11
|
+
prepare_response(:success)
|
12
|
+
location = Location.new(
|
13
|
+
:country => "US",
|
14
|
+
:latitude => 44.152019,
|
15
|
+
:locality => "Lovell",
|
16
|
+
:longitude => -70.892706,
|
17
|
+
:postal_code => "04051-3919",
|
18
|
+
:precision => :address,
|
19
|
+
:region => "ME",
|
20
|
+
:street => "44 Allen Rd"
|
21
|
+
)
|
22
|
+
assert_equal(location, @geocoder.locate('44 Allen Rd., Lovell, ME 04051'))
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_multi_result
|
26
|
+
prepare_response(:multi_result)
|
27
|
+
location = Location.new(
|
28
|
+
:country => "US",
|
29
|
+
:latitude => 40.925598,
|
30
|
+
:locality => "Stony Brook",
|
31
|
+
:longitude => -73.141403,
|
32
|
+
:postal_code => nil,
|
33
|
+
:precision => :city,
|
34
|
+
:region => "NY",
|
35
|
+
:street => nil
|
36
|
+
)
|
37
|
+
assert_equal(location, @geocoder.locate('217 Union St., NY'))
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
def prepare_response(id)
|
43
|
+
URI::HTTP.responses << response('mapquest', id)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graticule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Keepers
|
@@ -9,8 +9,8 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
13
|
-
default_executable:
|
12
|
+
date: 2009-09-06 00:00:00 -04:00
|
13
|
+
default_executable: geocode
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -22,16 +22,6 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: hoe
|
27
|
-
type: :development
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.8.2
|
34
|
-
version:
|
35
25
|
description: Graticule is a geocoding API that provides a common interface to all the popular services, including Google, Yahoo, Geocoder.us, and MetaCarta.
|
36
26
|
email: brandon@opensoul.org
|
37
27
|
executables:
|
@@ -39,23 +29,17 @@ executables:
|
|
39
29
|
extensions: []
|
40
30
|
|
41
31
|
extra_rdoc_files:
|
42
|
-
- CHANGELOG.txt
|
43
|
-
- LICENSE.txt
|
44
|
-
- Manifest.txt
|
45
32
|
- README.txt
|
46
|
-
- test/fixtures/responses/host_ip/private.txt
|
47
|
-
- test/fixtures/responses/host_ip/success.txt
|
48
|
-
- test/fixtures/responses/host_ip/unknown.txt
|
49
|
-
- test/fixtures/responses/local_search_maps/empty.txt
|
50
|
-
- test/fixtures/responses/local_search_maps/not_found.txt
|
51
|
-
- test/fixtures/responses/local_search_maps/success.txt
|
52
33
|
files:
|
34
|
+
- .gitignore
|
53
35
|
- CHANGELOG.txt
|
54
36
|
- LICENSE.txt
|
55
37
|
- Manifest.txt
|
56
38
|
- README.txt
|
57
39
|
- Rakefile
|
40
|
+
- VERSION
|
58
41
|
- bin/geocode
|
42
|
+
- graticule.gemspec
|
59
43
|
- init.rb
|
60
44
|
- lib/graticule.rb
|
61
45
|
- lib/graticule/cli.rb
|
@@ -72,6 +56,7 @@ files:
|
|
72
56
|
- lib/graticule/geocoder/google.rb
|
73
57
|
- lib/graticule/geocoder/host_ip.rb
|
74
58
|
- lib/graticule/geocoder/local_search_maps.rb
|
59
|
+
- lib/graticule/geocoder/mapquest.rb
|
75
60
|
- lib/graticule/geocoder/meta_carta.rb
|
76
61
|
- lib/graticule/geocoder/multi.rb
|
77
62
|
- lib/graticule/geocoder/multimap.rb
|
@@ -102,6 +87,8 @@ files:
|
|
102
87
|
- test/fixtures/responses/local_search_maps/empty.txt
|
103
88
|
- test/fixtures/responses/local_search_maps/not_found.txt
|
104
89
|
- test/fixtures/responses/local_search_maps/success.txt
|
90
|
+
- test/fixtures/responses/mapquest/multi_result.xml
|
91
|
+
- test/fixtures/responses/mapquest/success.xml
|
105
92
|
- test/fixtures/responses/meta_carta/bad_address.xml
|
106
93
|
- test/fixtures/responses/meta_carta/multiple.xml
|
107
94
|
- test/fixtures/responses/meta_carta/success.xml
|
@@ -123,6 +110,7 @@ files:
|
|
123
110
|
- test/unit/graticule/geocoder/google_test.rb
|
124
111
|
- test/unit/graticule/geocoder/host_ip_test.rb
|
125
112
|
- test/unit/graticule/geocoder/local_search_maps_test.rb
|
113
|
+
- test/unit/graticule/geocoder/mapquest_test.rb
|
126
114
|
- test/unit/graticule/geocoder/meta_carta_test.rb
|
127
115
|
- test/unit/graticule/geocoder/multi_test.rb
|
128
116
|
- test/unit/graticule/geocoder/multimap_test.rb
|
@@ -131,11 +119,15 @@ files:
|
|
131
119
|
- test/unit/graticule/geocoder_test.rb
|
132
120
|
- test/unit/graticule/location_test.rb
|
133
121
|
has_rdoc: true
|
134
|
-
homepage: http://graticule
|
122
|
+
homepage: http://github.com/collectiveidea/graticule
|
123
|
+
licenses: []
|
124
|
+
|
135
125
|
post_install_message:
|
136
126
|
rdoc_options:
|
137
127
|
- --main
|
138
|
-
- README.
|
128
|
+
- README.rdoc
|
129
|
+
- --inline-source
|
130
|
+
- --line-numbers
|
139
131
|
require_paths:
|
140
132
|
- lib
|
141
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -153,16 +145,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
145
|
requirements: []
|
154
146
|
|
155
147
|
rubyforge_project: graticule
|
156
|
-
rubygems_version: 1.3.
|
148
|
+
rubygems_version: 1.3.3
|
157
149
|
signing_key:
|
158
150
|
specification_version: 2
|
159
151
|
summary: API for using all the popular geocoding services.
|
160
152
|
test_files:
|
153
|
+
- test/mocks/uri.rb
|
154
|
+
- test/test_helper.rb
|
161
155
|
- test/unit/graticule/distance_test.rb
|
162
156
|
- test/unit/graticule/geocoder/geocoder_us_test.rb
|
157
|
+
- test/unit/graticule/geocoder/geocoders.rb
|
163
158
|
- test/unit/graticule/geocoder/google_test.rb
|
164
159
|
- test/unit/graticule/geocoder/host_ip_test.rb
|
165
160
|
- test/unit/graticule/geocoder/local_search_maps_test.rb
|
161
|
+
- test/unit/graticule/geocoder/mapquest_test.rb
|
166
162
|
- test/unit/graticule/geocoder/meta_carta_test.rb
|
167
163
|
- test/unit/graticule/geocoder/multi_test.rb
|
168
164
|
- test/unit/graticule/geocoder/multimap_test.rb
|