graticule 0.2.12 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +13 -0
- data/.gitignore +2 -1
- data/CHANGELOG.txt +2 -0
- data/README.txt +5 -1
- data/Rakefile +31 -51
- data/VERSION +1 -1
- data/graticule.gemspec +102 -53
- data/lib/graticule/geocoder/base.rb +1 -1
- data/lib/graticule/geocoder/bogus.rb +8 -6
- data/lib/graticule/geocoder/freethepostcode.rb +38 -0
- data/lib/graticule/geocoder/geocoder_ca.rb +45 -20
- data/lib/graticule/geocoder/geocoder_us.rb +26 -14
- data/lib/graticule/geocoder/geonames.rb +51 -0
- data/lib/graticule/geocoder/google.rb +71 -44
- data/lib/graticule/geocoder/local_search_maps.rb +8 -7
- data/lib/graticule/geocoder/mapquest.rb +47 -27
- data/lib/graticule/geocoder/multi.rb +68 -8
- data/lib/graticule/geocoder/multimap.rb +49 -24
- data/lib/graticule/geocoder/yahoo.rb +57 -28
- data/lib/graticule/geocoder.rb +1 -0
- data/lib/graticule/location.rb +4 -0
- data/lib/graticule.rb +2 -4
- data/test/config.yml +32 -0
- data/test/config.yml.default +9 -12
- data/test/fixtures/responses/freethepostcode/not_found.txt +3 -0
- data/test/fixtures/responses/freethepostcode/success.txt +2 -0
- data/test/fixtures/responses/geocoder_ca/success.xml +12 -0
- data/test/fixtures/responses/geocoder_us/success.xml +3 -13
- data/test/fixtures/responses/geonames/missing.xml +4 -0
- data/test/fixtures/responses/geonames/success.xml +14 -0
- data/test/fixtures/responses/geonames/unknown.xml +4 -0
- data/test/fixtures/responses/google/partial.xml +16 -1
- data/test/fixtures/responses/google/success.xml +16 -1
- data/test/fixtures/responses/google/unknown_address.xml +8 -1
- data/test/fixtures/responses/yahoo/success.xml +2 -2
- data/test/fixtures/responses/yahoo/unknown_address.xml +1 -1
- data/test/{unit/graticule → graticule}/distance_test.rb +1 -1
- data/test/graticule/geocoder/freethepostcode_test.rb +36 -0
- data/test/graticule/geocoder/geocoder_ca_test.rb +41 -0
- data/test/{unit/graticule → graticule}/geocoder/geocoder_us_test.rb +1 -1
- data/test/{unit/graticule → graticule}/geocoder/geocoders.rb +1 -2
- data/test/graticule/geocoder/geonames_test.rb +48 -0
- data/test/{unit/graticule → graticule}/geocoder/google_test.rb +21 -26
- data/test/{unit/graticule → graticule}/geocoder/host_ip_test.rb +1 -1
- data/test/{unit/graticule → graticule}/geocoder/local_search_maps_test.rb +1 -1
- data/test/{unit/graticule → graticule}/geocoder/mapquest_test.rb +4 -2
- data/test/{unit/graticule → graticule}/geocoder/multi_test.rb +10 -2
- data/test/{unit/graticule → graticule}/geocoder/multimap_test.rb +2 -2
- data/test/{unit/graticule → graticule}/geocoder/yahoo_test.rb +6 -5
- data/test/{unit/graticule → graticule}/geocoder_test.rb +1 -5
- data/test/{unit/graticule → graticule}/location_test.rb +9 -1
- data/test/test_helper.rb +1 -2
- metadata +88 -47
- data/Manifest.txt +0 -84
- data/lib/graticule/geocoder/meta_carta.rb +0 -33
- data/lib/graticule/geocoder/postcode_anywhere.rb +0 -63
- data/lib/graticule/geocoder/rest.rb +0 -18
- data/lib/graticule/version.rb +0 -9
- data/test/fixtures/responses/meta_carta/bad_address.xml +0 -17
- data/test/fixtures/responses/meta_carta/multiple.xml +0 -33
- data/test/fixtures/responses/meta_carta/success.xml +0 -31
- data/test/fixtures/responses/postcode_anywhere/badkey.xml +0 -9
- data/test/fixtures/responses/postcode_anywhere/canada.xml +0 -16
- data/test/fixtures/responses/postcode_anywhere/empty.xml +0 -16
- data/test/fixtures/responses/postcode_anywhere/success.xml +0 -16
- data/test/fixtures/responses/postcode_anywhere/uk.xml +0 -18
- data/test/unit/graticule/geocoder/meta_carta_test.rb +0 -44
- data/test/unit/graticule/geocoder/postcode_anywhere_test.rb +0 -50
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.
|
4
|
+
version: 1.0.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Keepers
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-05 00:00:00 -05:00
|
13
13
|
default_executable: geocode
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: happymapper
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.3.0
|
34
|
+
version:
|
25
35
|
description: Graticule is a geocoding API that provides a common interface to all the popular services, including Google, Yahoo, Geocoder.us, and MetaCarta.
|
26
36
|
email: brandon@opensoul.org
|
27
37
|
executables:
|
@@ -31,10 +41,10 @@ extensions: []
|
|
31
41
|
extra_rdoc_files:
|
32
42
|
- README.txt
|
33
43
|
files:
|
44
|
+
- .autotest
|
34
45
|
- .gitignore
|
35
46
|
- CHANGELOG.txt
|
36
47
|
- LICENSE.txt
|
37
|
-
- Manifest.txt
|
38
48
|
- README.txt
|
39
49
|
- Rakefile
|
40
50
|
- VERSION
|
@@ -51,26 +61,30 @@ files:
|
|
51
61
|
- lib/graticule/geocoder.rb
|
52
62
|
- lib/graticule/geocoder/base.rb
|
53
63
|
- lib/graticule/geocoder/bogus.rb
|
64
|
+
- lib/graticule/geocoder/freethepostcode.rb
|
54
65
|
- lib/graticule/geocoder/geocoder_ca.rb
|
55
66
|
- lib/graticule/geocoder/geocoder_us.rb
|
67
|
+
- lib/graticule/geocoder/geonames.rb
|
56
68
|
- lib/graticule/geocoder/google.rb
|
57
69
|
- lib/graticule/geocoder/host_ip.rb
|
58
70
|
- lib/graticule/geocoder/local_search_maps.rb
|
59
71
|
- lib/graticule/geocoder/mapquest.rb
|
60
|
-
- lib/graticule/geocoder/meta_carta.rb
|
61
72
|
- lib/graticule/geocoder/multi.rb
|
62
73
|
- lib/graticule/geocoder/multimap.rb
|
63
|
-
- lib/graticule/geocoder/postcode_anywhere.rb
|
64
|
-
- lib/graticule/geocoder/rest.rb
|
65
74
|
- lib/graticule/geocoder/yahoo.rb
|
66
75
|
- lib/graticule/location.rb
|
67
|
-
- lib/graticule/version.rb
|
68
76
|
- site/index.html
|
69
77
|
- site/plugin.html
|
70
78
|
- site/stylesheets/style.css
|
71
79
|
- test/config.yml.default
|
80
|
+
- test/fixtures/responses/freethepostcode/not_found.txt
|
81
|
+
- test/fixtures/responses/freethepostcode/success.txt
|
82
|
+
- test/fixtures/responses/geocoder_ca/success.xml
|
72
83
|
- test/fixtures/responses/geocoder_us/success.xml
|
73
84
|
- test/fixtures/responses/geocoder_us/unknown.xml
|
85
|
+
- test/fixtures/responses/geonames/missing.xml
|
86
|
+
- test/fixtures/responses/geonames/success.xml
|
87
|
+
- test/fixtures/responses/geonames/unknown.xml
|
74
88
|
- test/fixtures/responses/google/badkey.xml
|
75
89
|
- test/fixtures/responses/google/limit.xml
|
76
90
|
- test/fixtures/responses/google/missing_address.xml
|
@@ -89,35 +103,28 @@ files:
|
|
89
103
|
- test/fixtures/responses/local_search_maps/success.txt
|
90
104
|
- test/fixtures/responses/mapquest/multi_result.xml
|
91
105
|
- test/fixtures/responses/mapquest/success.xml
|
92
|
-
- test/fixtures/responses/meta_carta/bad_address.xml
|
93
|
-
- test/fixtures/responses/meta_carta/multiple.xml
|
94
|
-
- test/fixtures/responses/meta_carta/success.xml
|
95
106
|
- test/fixtures/responses/multimap/missing_params.xml
|
96
107
|
- test/fixtures/responses/multimap/no_matches.xml
|
97
108
|
- test/fixtures/responses/multimap/success.xml
|
98
|
-
- test/fixtures/responses/postcode_anywhere/badkey.xml
|
99
|
-
- test/fixtures/responses/postcode_anywhere/canada.xml
|
100
|
-
- test/fixtures/responses/postcode_anywhere/empty.xml
|
101
|
-
- test/fixtures/responses/postcode_anywhere/success.xml
|
102
|
-
- test/fixtures/responses/postcode_anywhere/uk.xml
|
103
109
|
- test/fixtures/responses/yahoo/success.xml
|
104
110
|
- test/fixtures/responses/yahoo/unknown_address.xml
|
111
|
+
- test/graticule/distance_test.rb
|
112
|
+
- test/graticule/geocoder/freethepostcode_test.rb
|
113
|
+
- test/graticule/geocoder/geocoder_ca_test.rb
|
114
|
+
- test/graticule/geocoder/geocoder_us_test.rb
|
115
|
+
- test/graticule/geocoder/geocoders.rb
|
116
|
+
- test/graticule/geocoder/geonames_test.rb
|
117
|
+
- test/graticule/geocoder/google_test.rb
|
118
|
+
- test/graticule/geocoder/host_ip_test.rb
|
119
|
+
- test/graticule/geocoder/local_search_maps_test.rb
|
120
|
+
- test/graticule/geocoder/mapquest_test.rb
|
121
|
+
- test/graticule/geocoder/multi_test.rb
|
122
|
+
- test/graticule/geocoder/multimap_test.rb
|
123
|
+
- test/graticule/geocoder/yahoo_test.rb
|
124
|
+
- test/graticule/geocoder_test.rb
|
125
|
+
- test/graticule/location_test.rb
|
105
126
|
- test/mocks/uri.rb
|
106
127
|
- test/test_helper.rb
|
107
|
-
- test/unit/graticule/distance_test.rb
|
108
|
-
- test/unit/graticule/geocoder/geocoder_us_test.rb
|
109
|
-
- test/unit/graticule/geocoder/geocoders.rb
|
110
|
-
- test/unit/graticule/geocoder/google_test.rb
|
111
|
-
- test/unit/graticule/geocoder/host_ip_test.rb
|
112
|
-
- test/unit/graticule/geocoder/local_search_maps_test.rb
|
113
|
-
- test/unit/graticule/geocoder/mapquest_test.rb
|
114
|
-
- test/unit/graticule/geocoder/meta_carta_test.rb
|
115
|
-
- test/unit/graticule/geocoder/multi_test.rb
|
116
|
-
- test/unit/graticule/geocoder/multimap_test.rb
|
117
|
-
- test/unit/graticule/geocoder/postcode_anywhere_test.rb
|
118
|
-
- test/unit/graticule/geocoder/yahoo_test.rb
|
119
|
-
- test/unit/graticule/geocoder_test.rb
|
120
|
-
- test/unit/graticule/location_test.rb
|
121
128
|
has_rdoc: true
|
122
129
|
homepage: http://github.com/collectiveidea/graticule
|
123
130
|
licenses: []
|
@@ -138,31 +145,65 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
145
|
version:
|
139
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
147
|
requirements:
|
141
|
-
- - "
|
148
|
+
- - ">"
|
142
149
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
150
|
+
version: 1.3.1
|
144
151
|
version:
|
145
152
|
requirements: []
|
146
153
|
|
147
154
|
rubyforge_project: graticule
|
148
|
-
rubygems_version: 1.3.
|
155
|
+
rubygems_version: 1.3.5
|
149
156
|
signing_key:
|
150
|
-
specification_version:
|
157
|
+
specification_version: 3
|
151
158
|
summary: API for using all the popular geocoding services.
|
152
159
|
test_files:
|
160
|
+
- test/config.yml
|
161
|
+
- test/config.yml.default
|
162
|
+
- test/fixtures/responses/freethepostcode/not_found.txt
|
163
|
+
- test/fixtures/responses/freethepostcode/success.txt
|
164
|
+
- test/fixtures/responses/geocoder_ca/success.xml
|
165
|
+
- test/fixtures/responses/geocoder_us/success.xml
|
166
|
+
- test/fixtures/responses/geocoder_us/unknown.xml
|
167
|
+
- test/fixtures/responses/geonames/missing.xml
|
168
|
+
- test/fixtures/responses/geonames/success.xml
|
169
|
+
- test/fixtures/responses/geonames/unknown.xml
|
170
|
+
- test/fixtures/responses/google/badkey.xml
|
171
|
+
- test/fixtures/responses/google/limit.xml
|
172
|
+
- test/fixtures/responses/google/missing_address.xml
|
173
|
+
- test/fixtures/responses/google/only_coordinates.xml
|
174
|
+
- test/fixtures/responses/google/partial.xml
|
175
|
+
- test/fixtures/responses/google/server_error.xml
|
176
|
+
- test/fixtures/responses/google/success.xml
|
177
|
+
- test/fixtures/responses/google/success_multiple_results.xml
|
178
|
+
- test/fixtures/responses/google/unavailable.xml
|
179
|
+
- test/fixtures/responses/google/unknown_address.xml
|
180
|
+
- test/fixtures/responses/host_ip/private.txt
|
181
|
+
- test/fixtures/responses/host_ip/success.txt
|
182
|
+
- test/fixtures/responses/host_ip/unknown.txt
|
183
|
+
- test/fixtures/responses/local_search_maps/empty.txt
|
184
|
+
- test/fixtures/responses/local_search_maps/not_found.txt
|
185
|
+
- test/fixtures/responses/local_search_maps/success.txt
|
186
|
+
- test/fixtures/responses/mapquest/multi_result.xml
|
187
|
+
- test/fixtures/responses/mapquest/success.xml
|
188
|
+
- test/fixtures/responses/multimap/missing_params.xml
|
189
|
+
- test/fixtures/responses/multimap/no_matches.xml
|
190
|
+
- test/fixtures/responses/multimap/success.xml
|
191
|
+
- test/fixtures/responses/yahoo/success.xml
|
192
|
+
- test/fixtures/responses/yahoo/unknown_address.xml
|
193
|
+
- test/graticule/distance_test.rb
|
194
|
+
- test/graticule/geocoder/freethepostcode_test.rb
|
195
|
+
- test/graticule/geocoder/geocoder_ca_test.rb
|
196
|
+
- test/graticule/geocoder/geocoder_us_test.rb
|
197
|
+
- test/graticule/geocoder/geocoders.rb
|
198
|
+
- test/graticule/geocoder/geonames_test.rb
|
199
|
+
- test/graticule/geocoder/google_test.rb
|
200
|
+
- test/graticule/geocoder/host_ip_test.rb
|
201
|
+
- test/graticule/geocoder/local_search_maps_test.rb
|
202
|
+
- test/graticule/geocoder/mapquest_test.rb
|
203
|
+
- test/graticule/geocoder/multi_test.rb
|
204
|
+
- test/graticule/geocoder/multimap_test.rb
|
205
|
+
- test/graticule/geocoder/yahoo_test.rb
|
206
|
+
- test/graticule/geocoder_test.rb
|
207
|
+
- test/graticule/location_test.rb
|
153
208
|
- test/mocks/uri.rb
|
154
209
|
- test/test_helper.rb
|
155
|
-
- test/unit/graticule/distance_test.rb
|
156
|
-
- test/unit/graticule/geocoder/geocoder_us_test.rb
|
157
|
-
- test/unit/graticule/geocoder/geocoders.rb
|
158
|
-
- test/unit/graticule/geocoder/google_test.rb
|
159
|
-
- test/unit/graticule/geocoder/host_ip_test.rb
|
160
|
-
- test/unit/graticule/geocoder/local_search_maps_test.rb
|
161
|
-
- test/unit/graticule/geocoder/mapquest_test.rb
|
162
|
-
- test/unit/graticule/geocoder/meta_carta_test.rb
|
163
|
-
- test/unit/graticule/geocoder/multi_test.rb
|
164
|
-
- test/unit/graticule/geocoder/multimap_test.rb
|
165
|
-
- test/unit/graticule/geocoder/postcode_anywhere_test.rb
|
166
|
-
- test/unit/graticule/geocoder/yahoo_test.rb
|
167
|
-
- test/unit/graticule/geocoder_test.rb
|
168
|
-
- test/unit/graticule/location_test.rb
|
data/Manifest.txt
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
CHANGELOG.txt
|
2
|
-
LICENSE.txt
|
3
|
-
Manifest.txt
|
4
|
-
README.txt
|
5
|
-
Rakefile
|
6
|
-
bin/geocode
|
7
|
-
init.rb
|
8
|
-
lib/graticule.rb
|
9
|
-
lib/graticule/cli.rb
|
10
|
-
lib/graticule/core_ext.rb
|
11
|
-
lib/graticule/distance.rb
|
12
|
-
lib/graticule/distance/haversine.rb
|
13
|
-
lib/graticule/distance/spherical.rb
|
14
|
-
lib/graticule/distance/vincenty.rb
|
15
|
-
lib/graticule/geocoder.rb
|
16
|
-
lib/graticule/geocoder/base.rb
|
17
|
-
lib/graticule/geocoder/bogus.rb
|
18
|
-
lib/graticule/geocoder/geocoder_ca.rb
|
19
|
-
lib/graticule/geocoder/geocoder_us.rb
|
20
|
-
lib/graticule/geocoder/google.rb
|
21
|
-
lib/graticule/geocoder/host_ip.rb
|
22
|
-
lib/graticule/geocoder/local_search_maps.rb
|
23
|
-
lib/graticule/geocoder/mapquest.rb
|
24
|
-
lib/graticule/geocoder/meta_carta.rb
|
25
|
-
lib/graticule/geocoder/multi.rb
|
26
|
-
lib/graticule/geocoder/multimap.rb
|
27
|
-
lib/graticule/geocoder/postcode_anywhere.rb
|
28
|
-
lib/graticule/geocoder/rest.rb
|
29
|
-
lib/graticule/geocoder/yahoo.rb
|
30
|
-
lib/graticule/location.rb
|
31
|
-
lib/graticule/version.rb
|
32
|
-
site/index.html
|
33
|
-
site/plugin.html
|
34
|
-
site/stylesheets/style.css
|
35
|
-
test/config.yml.default
|
36
|
-
test/fixtures/responses/geocoder_us/success.xml
|
37
|
-
test/fixtures/responses/geocoder_us/unknown.xml
|
38
|
-
test/fixtures/responses/google/badkey.xml
|
39
|
-
test/fixtures/responses/google/limit.xml
|
40
|
-
test/fixtures/responses/google/missing_address.xml
|
41
|
-
test/fixtures/responses/google/only_coordinates.xml
|
42
|
-
test/fixtures/responses/google/partial.xml
|
43
|
-
test/fixtures/responses/google/server_error.xml
|
44
|
-
test/fixtures/responses/google/success.xml
|
45
|
-
test/fixtures/responses/google/success_multiple_results.xml
|
46
|
-
test/fixtures/responses/google/unavailable.xml
|
47
|
-
test/fixtures/responses/google/unknown_address.xml
|
48
|
-
test/fixtures/responses/host_ip/private.txt
|
49
|
-
test/fixtures/responses/host_ip/success.txt
|
50
|
-
test/fixtures/responses/host_ip/unknown.txt
|
51
|
-
test/fixtures/responses/local_search_maps/empty.txt
|
52
|
-
test/fixtures/responses/local_search_maps/not_found.txt
|
53
|
-
test/fixtures/responses/local_search_maps/success.txt
|
54
|
-
test/fixtures/responses/mapquest/multi_result.xml
|
55
|
-
test/fixtures/responses/mapquest/success.xml
|
56
|
-
test/fixtures/responses/meta_carta/bad_address.xml
|
57
|
-
test/fixtures/responses/meta_carta/multiple.xml
|
58
|
-
test/fixtures/responses/meta_carta/success.xml
|
59
|
-
test/fixtures/responses/multimap/missing_params.xml
|
60
|
-
test/fixtures/responses/multimap/no_matches.xml
|
61
|
-
test/fixtures/responses/multimap/success.xml
|
62
|
-
test/fixtures/responses/postcode_anywhere/badkey.xml
|
63
|
-
test/fixtures/responses/postcode_anywhere/canada.xml
|
64
|
-
test/fixtures/responses/postcode_anywhere/empty.xml
|
65
|
-
test/fixtures/responses/postcode_anywhere/success.xml
|
66
|
-
test/fixtures/responses/postcode_anywhere/uk.xml
|
67
|
-
test/fixtures/responses/yahoo/success.xml
|
68
|
-
test/fixtures/responses/yahoo/unknown_address.xml
|
69
|
-
test/mocks/uri.rb
|
70
|
-
test/test_helper.rb
|
71
|
-
test/unit/graticule/distance_test.rb
|
72
|
-
test/unit/graticule/geocoder/geocoder_us_test.rb
|
73
|
-
test/unit/graticule/geocoder/geocoders.rb
|
74
|
-
test/unit/graticule/geocoder/google_test.rb
|
75
|
-
test/unit/graticule/geocoder/host_ip_test.rb
|
76
|
-
test/unit/graticule/geocoder/local_search_maps_test.rb
|
77
|
-
test/unit/graticule/geocoder/mapquest_test.rb
|
78
|
-
test/unit/graticule/geocoder/meta_carta_test.rb
|
79
|
-
test/unit/graticule/geocoder/multi_test.rb
|
80
|
-
test/unit/graticule/geocoder/multimap_test.rb
|
81
|
-
test/unit/graticule/geocoder/postcode_anywhere_test.rb
|
82
|
-
test/unit/graticule/geocoder/yahoo_test.rb
|
83
|
-
test/unit/graticule/geocoder_test.rb
|
84
|
-
test/unit/graticule/location_test.rb
|
@@ -1,33 +0,0 @@
|
|
1
|
-
|
2
|
-
module Graticule
|
3
|
-
module Geocoder
|
4
|
-
|
5
|
-
# Library for looking up coordinates with MetaCarta's GeoParser API.
|
6
|
-
#
|
7
|
-
# http://labs.metacarta.com/GeoParser/documentation.html
|
8
|
-
class MetaCarta < Rest
|
9
|
-
|
10
|
-
def initialize # :nodoc:
|
11
|
-
@url = URI.parse 'http://labs.metacarta.com/GeoParser/'
|
12
|
-
end
|
13
|
-
|
14
|
-
# Finds +location+ and returns a Location object.
|
15
|
-
def locate(location)
|
16
|
-
get :q => location.is_a?(String) ? location : location_from_params(location).to_s, :output => 'locations'
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def check_error(xml) # :nodoc:
|
22
|
-
raise AddressError, 'bad location' unless xml.elements['Locations/Location']
|
23
|
-
end
|
24
|
-
|
25
|
-
def parse_response(xml) # :nodoc:
|
26
|
-
result = xml.elements['/Locations/Location[1]']
|
27
|
-
coords = result.elements['Centroid/gml:Point/gml:coordinates'].text.split ','
|
28
|
-
Location.new :latitude => coords.first.to_f, :longitude => coords.last.to_f
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module Graticule #:nodoc:
|
2
|
-
module Geocoder #:nodoc:
|
3
|
-
|
4
|
-
class PostcodeAnywhere < Rest
|
5
|
-
|
6
|
-
# http://www.postcodeanywhere.com/register/
|
7
|
-
def initialize(account_code, license_code)
|
8
|
-
@url = URI.parse 'http://services.postcodeanywhere.co.uk/xml.aspx'
|
9
|
-
@account_code = account_code
|
10
|
-
@license_code = license_code
|
11
|
-
end
|
12
|
-
|
13
|
-
def locate(params)
|
14
|
-
location = location_from_params(params)
|
15
|
-
get :address => location.to_s(:country => false), :country => location.country
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def make_url(params) #:nodoc:
|
21
|
-
params[:account_code] = @account_code
|
22
|
-
params[:license_code] = @license_code
|
23
|
-
params[:action] = 'geocode'
|
24
|
-
super params
|
25
|
-
end
|
26
|
-
|
27
|
-
def parse_response(xml) #:nodoc:
|
28
|
-
result = xml.elements['/PostcodeAnywhere/Data/Item[1]']
|
29
|
-
returning Location.new do |location|
|
30
|
-
location.latitude = result.attribute('latitude').value.to_f
|
31
|
-
location.longitude = result.attribute('longitude').value.to_f
|
32
|
-
location.street = value(result.attribute('line1'))
|
33
|
-
location.locality = value(result.attribute('city'))
|
34
|
-
location.region = value(result.attribute('state'))
|
35
|
-
location.postal_code = value(result.attribute('postal_code'))
|
36
|
-
location.country = value(result.attribute('country'))
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def value(attribute)
|
41
|
-
attribute.value if attribute
|
42
|
-
end
|
43
|
-
|
44
|
-
# http://www.postcodeanywhere.co.uk/developers/documentation/errors.aspx
|
45
|
-
def check_error(xml) #:nodoc:
|
46
|
-
#raise AddressError, xml.text if xml.text == 'couldn\'t find this address! sorry'
|
47
|
-
if error = xml.elements['/PostcodeAnywhere/Data/Item[@error_number][1]']
|
48
|
-
error_number = error.attribute('error_number').value.to_i
|
49
|
-
message = error.attribute('message').value
|
50
|
-
if (1..11).include?(error_number) || (34..38).include?(error_number)
|
51
|
-
raise CredentialsError, message
|
52
|
-
else
|
53
|
-
raise Error, message
|
54
|
-
end
|
55
|
-
elsif xml.elements['/PostcodeAnywhere/Data'].elements.empty?
|
56
|
-
raise AddressError, 'No results returned'
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rexml/document'
|
2
|
-
|
3
|
-
module Graticule #:nodoc:
|
4
|
-
module Geocoder #:nodoc:
|
5
|
-
|
6
|
-
# Abstract class for implementing REST geocoders. Passes on a REXML::Document
|
7
|
-
# to +check_errors+ and +parse_response+.
|
8
|
-
class Rest < Base
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def prepare_response(response)
|
13
|
-
REXML::Document.new(response)
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/graticule/version.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
-
|
3
|
-
<!DOCTYPE Locations SYSTEM "Locations.dtd">
|
4
|
-
|
5
|
-
<Locations
|
6
|
-
xmlns:gml="http://www.opengis.net/gml"
|
7
|
-
CreatedBy="MetaCarta GeoParser v3.7.0-labs"
|
8
|
-
CreatedOn="Wed Apr 25 22:12:33 2007"
|
9
|
-
ConvertedFromBinaryFormat="0"
|
10
|
-
InputByteLength="0">
|
11
|
-
<ViewBox>
|
12
|
-
|
13
|
-
<gml:Box srsName="epsg:4326">
|
14
|
-
<gml:coordinates>-180.000000,-90.000000 180.000000,90.000000</gml:coordinates>
|
15
|
-
</gml:Box>
|
16
|
-
</ViewBox>
|
17
|
-
</Locations>
|
@@ -1,33 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE Locations SYSTEM "Locations.dtd">
|
3
|
-
<Locations xmlns:gml="http://www.opengis.net/gml" CreatedBy="MetaCarta GeoParser v3.5.0-labs-alpha" CreatedOn="Sat Jun 17 02:14:05 2006" ConvertedFromBinaryFormat="False" InputByteLength="1">
|
4
|
-
<ViewBox>
|
5
|
-
<gml:Box srsName="epsg:4326">
|
6
|
-
<gml:coordinates>43.800000,-126.133333 51.406390,-118.530830</gml:coordinates>
|
7
|
-
</gml:Box>
|
8
|
-
</ViewBox>
|
9
|
-
<Location Name="Seattle" Type="PPL" Population="563374" Hierarchy="United States/Washington/King/Seattle">
|
10
|
-
<ViewBox>
|
11
|
-
<gml:Box srsName="epsg:4326">
|
12
|
-
<gml:coordinates>43.806390,-126.130830 51.406390,-118.530830</gml:coordinates>
|
13
|
-
</gml:Box>
|
14
|
-
</ViewBox>
|
15
|
-
<Centroid>
|
16
|
-
<gml:Point>
|
17
|
-
<gml:coordinates>-122.330830000000006,47.606389999999998</gml:coordinates>
|
18
|
-
</gml:Point>
|
19
|
-
</Centroid>
|
20
|
-
</Location>
|
21
|
-
<Location Name="Seattle" Type="PRT" Population="-1" Hierarchy="United States/Seattle">
|
22
|
-
<ViewBox>
|
23
|
-
<gml:Box srsName="epsg:4326">
|
24
|
-
<gml:coordinates>43.800000,-126.133333 51.400000,-118.533333</gml:coordinates>
|
25
|
-
</gml:Box>
|
26
|
-
</ViewBox>
|
27
|
-
<Centroid>
|
28
|
-
<gml:Point>
|
29
|
-
<gml:coordinates>-122.333332999999996,47.6</gml:coordinates>
|
30
|
-
</gml:Point>
|
31
|
-
</Centroid>
|
32
|
-
</Location>
|
33
|
-
</Locations>
|
@@ -1,31 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
-
|
3
|
-
<!DOCTYPE Locations SYSTEM "Locations.dtd">
|
4
|
-
|
5
|
-
<Locations
|
6
|
-
xmlns:gml="http://www.opengis.net/gml"
|
7
|
-
CreatedBy="MetaCarta GeoParser v3.7.0-labs"
|
8
|
-
CreatedOn="Wed Apr 25 22:12:33 2007"
|
9
|
-
ConvertedFromBinaryFormat="0"
|
10
|
-
InputByteLength="0">
|
11
|
-
<ViewBox>
|
12
|
-
|
13
|
-
<gml:Box srsName="epsg:4326">
|
14
|
-
<gml:coordinates>43.593900,32.538600 45.193900,34.138600</gml:coordinates>
|
15
|
-
</gml:Box>
|
16
|
-
</ViewBox>
|
17
|
-
<Location
|
18
|
-
|
19
|
-
Name="Baghdad"
|
20
|
-
Type=""
|
21
|
-
Population="-1"
|
22
|
-
Hierarchy="">
|
23
|
-
<ViewBox>
|
24
|
-
<gml:Box srsName="epsg:4326">
|
25
|
-
<gml:coordinates>43.593900,32.538600 45.193900,34.138600</gml:coordinates>
|
26
|
-
</gml:Box>
|
27
|
-
</ViewBox>
|
28
|
-
<RemainingQuery></RemainingQuery>
|
29
|
-
<Confidence>0.566875</Confidence> <Centroid><gml:Point><gml:coordinates>44.393900000000002,33.3386</gml:coordinates></gml:Point></Centroid>
|
30
|
-
</Location>
|
31
|
-
</Locations>
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<PostcodeAnywhere Server="WS12" Version="3.0" Date="12/03/2007 15:43:33" Duration="0.016s">
|
2
|
-
<Schema Items="2">
|
3
|
-
<Field Name="error_number"/>
|
4
|
-
<Field Name="message"/>
|
5
|
-
</Schema>
|
6
|
-
<Data Items="1">
|
7
|
-
<Item error_number="6" message="License key was not recognised"/>
|
8
|
-
</Data>
|
9
|
-
</PostcodeAnywhere>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<PostcodeAnywhere Server="WS12" Version="3.0" Date="17/03/2007 19:01:05" Duration="1.109s">
|
3
|
-
<Schema Items="8">
|
4
|
-
<Field Name="line1"/>
|
5
|
-
<Field Name="line2"/>
|
6
|
-
<Field Name="city"/>
|
7
|
-
<Field Name="state"/>
|
8
|
-
<Field Name="postal_code"/>
|
9
|
-
<Field Name="country"/>
|
10
|
-
<Field Name="longitude"/>
|
11
|
-
<Field Name="latitude"/>
|
12
|
-
</Schema>
|
13
|
-
<Data Items="1">
|
14
|
-
<Item line1="204 Campbell Ave" city="Revelstoke" state="BC" postal_code="V0E" country="Canada" longitude="-118.196970002204" latitude="50.9997350418267"/>
|
15
|
-
</Data>
|
16
|
-
</PostcodeAnywhere>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<PostcodeAnywhere Version="3.0" Server="WS03" Date="17/03/2007 19:26:33" Duration="0.016s">
|
3
|
-
<Schema Items="10">
|
4
|
-
<Field Name="id"/>
|
5
|
-
<Field Name="seq"/>
|
6
|
-
<Field Name="location"/>
|
7
|
-
<Field Name="grid_east_m"/>
|
8
|
-
<Field Name="grid_north_m"/>
|
9
|
-
<Field Name="longitude"/>
|
10
|
-
<Field Name="latitude"/>
|
11
|
-
<Field Name="os_reference"/>
|
12
|
-
<Field Name="wgs84_longitude"/>
|
13
|
-
<Field Name="wgs84_latitude"/>
|
14
|
-
</Schema>
|
15
|
-
<Data Items="0"/>
|
16
|
-
</PostcodeAnywhere>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<PostcodeAnywhere Server="WS11" Version="3.0" Date="17/03/2007 18:12:11" Duration="1.703s">
|
3
|
-
<Schema Items="8">
|
4
|
-
<Field Name="line1"/>
|
5
|
-
<Field Name="line2"/>
|
6
|
-
<Field Name="city"/>
|
7
|
-
<Field Name="state"/>
|
8
|
-
<Field Name="postal_code"/>
|
9
|
-
<Field Name="country"/>
|
10
|
-
<Field Name="longitude"/>
|
11
|
-
<Field Name="latitude"/>
|
12
|
-
</Schema>
|
13
|
-
<Data Items="1">
|
14
|
-
<Item line1="204 Campbell Ave" city="Revelstoke" state="BC" postal_code="V0E" country="Canada" longitude="-118.196970002204" latitude="50.9997350418267"/>
|
15
|
-
</Data>
|
16
|
-
</PostcodeAnywhere>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<PostcodeAnywhere Server="WS12" Version="3.0" Date="17/03/2007 19:01:39" Duration="2.422s">
|
3
|
-
<Schema Items="10">
|
4
|
-
<Field Name="id"/>
|
5
|
-
<Field Name="seq"/>
|
6
|
-
<Field Name="location"/>
|
7
|
-
<Field Name="grid_east_m"/>
|
8
|
-
<Field Name="grid_north_m"/>
|
9
|
-
<Field Name="longitude"/>
|
10
|
-
<Field Name="latitude"/>
|
11
|
-
<Field Name="os_reference"/>
|
12
|
-
<Field Name="wgs84_longitude"/>
|
13
|
-
<Field Name="wgs84_latitude"/>
|
14
|
-
</Schema>
|
15
|
-
<Data Items="1">
|
16
|
-
<Item id="17783983.00" seq="0" location="80 Wood Lane London NW9" grid_east_m="521000" grid_north_m="187500" longitude="-0.253788666693255" latitude="51.5728910186362" os_reference="TQ 21000 87500" wgs84_longitude="-0.255365891581496" wgs84_latitude="51.5733397173092"/>
|
17
|
-
</Data>
|
18
|
-
</PostcodeAnywhere>
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
-
|
3
|
-
module Graticule
|
4
|
-
module Geocoder
|
5
|
-
class MetaCartaTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
URI::HTTP.responses = []
|
9
|
-
URI::HTTP.uris = []
|
10
|
-
|
11
|
-
@geocoder = MetaCarta.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_locate
|
15
|
-
prepare_response(:success)
|
16
|
-
|
17
|
-
expected = Location.new :latitude => 44.3939, :longitude => 33.3386
|
18
|
-
|
19
|
-
assert_equal expected, @geocoder.locate('baghdad')
|
20
|
-
assert_equal true, URI::HTTP.responses.empty?
|
21
|
-
assert_equal 1, URI::HTTP.uris.length
|
22
|
-
assert_equal 'http://labs.metacarta.com/GeoParser/?output=locations&q=baghdad',
|
23
|
-
URI::HTTP.uris.first
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_locate_bad_address
|
27
|
-
prepare_response(:bad_address)
|
28
|
-
assert_raises(AddressError) { @geocoder.locate('aoeueou') }
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_locations
|
32
|
-
prepare_response(:multiple)
|
33
|
-
expected = Location.new :latitude => -122.33083, :longitude => 47.60639
|
34
|
-
assert_equal expected, @geocoder.locate('seattle')
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
def prepare_response(id = :success)
|
39
|
-
URI::HTTP.responses << response('meta_carta', id)
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|