interior 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -28,7 +28,7 @@ Section is option. If omitted, the centerpoint latitude and longitude will be fo
28
28
  the township and range:
29
29
 
30
30
  require 'interior'
31
- response = Interior::Geocoder.get_lat_lon('AZ', 14, 1, 'N', 1, 'E') # No section
31
+ response = Interior::Geocoder.get_lat_lon('AZ', 14, 1, 'N', 1, 'E') # no section
32
32
  response.success? => true
33
33
  response.latitude => 33.4211630233451
34
34
  response.longitude => -112.254699834217
@@ -69,351 +69,271 @@ Each meridian has a corresponding numeric key mapping:
69
69
  </tr>
70
70
  <tr>
71
71
  <td>AL</td>
72
- <td>HUNTSVILLE MER</td>
72
+ <td>Huntsville</td>
73
73
  <td>16</td>
74
74
  <td>AL</td>
75
- <td>ST. STEPHENS MER</td>
75
+ <td>St. Stephens</td>
76
76
  <td>25</td>
77
77
  </tr>
78
78
  <tr>
79
79
  <td>AL</td>
80
- <td>TALLAHASEE MER</td>
80
+ <td>Tallahasee</td>
81
81
  <td>29</td>
82
82
  <td>AR</td>
83
- <td>5TH PM</td>
83
+ <td>5th</td>
84
84
  <td>05</td>
85
85
  </tr>
86
86
  <tr>
87
87
  <td>AZ</td>
88
- <td>GILA-SALT RIVER MER</td>
88
+ <td>Gila-Salt River</td>
89
89
  <td>14</td>
90
90
  <td>AZ</td>
91
- <td>NAVAJO MER</td>
91
+ <td>Navajo</td>
92
92
  <td>22</td>
93
93
  </tr>
94
94
  <tr>
95
95
  <td>AZ</td>
96
- <td>SAN BERNARDINO MER</td>
96
+ <td>San Bernardino</td>
97
97
  <td>27</td>
98
98
  <td>CA</td>
99
- <td>GILA-SALT RIVER MER</td>
99
+ <td>Gila-Salt River</td>
100
100
  <td>14</td>
101
101
  </tr>
102
102
  <tr>
103
103
  <td>CA</td>
104
- <td>HUMBOLDT MER</td>
104
+ <td>Humboldt</td>
105
105
  <td>15</td>
106
106
  <td>CA</td>
107
- <td>MOUNT DIABLO MER</td>
107
+ <td>Mount Diablo</td>
108
108
  <td>21</td>
109
109
  </tr>
110
110
  <tr>
111
111
  <td>CA</td>
112
- <td>SAN BERNARDINO MER</td>
112
+ <td>San Bernardino</td>
113
113
  <td>27</td>
114
114
  <td>CO</td>
115
- <td>6TH PM</td>
115
+ <td>6th</td>
116
116
  <td>06</td>
117
117
  </tr>
118
118
  <tr>
119
119
  <td>CO</td>
120
- <td>NEW MEX PM</td>
120
+ <td>New Mex</td>
121
121
  <td>23</td>
122
122
  <td>CO</td>
123
- <td>UTE MER</td>
123
+ <td>Ute</td>
124
124
  <td>31</td>
125
125
  </tr>
126
- <tr>
127
- <td>CT</td>
128
- <td>CONNECTICUT</td>
129
- <td>CT</td>
130
- <td>DE</td>
131
- <td>DELAWARE</td>
132
- <td>DE</td>
133
- </tr>
134
126
  <tr>
135
127
  <td>FL</td>
136
- <td>TALLAHASEE MER</td>
128
+ <td>Tallahasee</td>
137
129
  <td>29</td>
138
- <td>GA</td>
139
- <td>GEORGIA</td>
140
- <td>GA</td>
141
- </tr>
142
- <tr>
143
130
  <td>IA</td>
144
- <td>5TH PM</td>
131
+ <td>5th</td>
145
132
  <td>05</td>
146
- <td>ID</td>
147
- <td>BOISE MER</td>
148
- <td>08</td>
149
133
  </tr>
150
134
  <tr>
135
+ <td>ID</td>
136
+ <td>Boise</td>
137
+ <td>08</td>
151
138
  <td>IL</td>
152
- <td>2ND PM</td>
139
+ <td>2nd</td>
153
140
  <td>02</td>
154
- <td>IL</td>
155
- <td>3RD PM</td>
156
- <td>03</td>
157
141
  </tr>
158
142
  <tr>
159
143
  <td>IL</td>
160
- <td>4TH PM ILLINOIS</td>
144
+ <td>3rd</td>
145
+ <td>03</td>
146
+ <td>IL</td>
147
+ <td>4th Illinois</td>
161
148
  <td>04</td>
162
- <td>IN</td>
163
- <td>1ST PM</td>
164
- <td>01</td>
165
149
  </tr>
166
150
  <tr>
167
151
  <td>IN</td>
168
- <td>2ND PM</td>
152
+ <td>1st</td>
153
+ <td>01</td>
154
+ <td>IN</td>
155
+ <td>2nd</td>
169
156
  <td>02</td>
170
- <td>KS</td>
171
- <td>6TH PM</td>
172
- <td>06</td>
173
157
  </tr>
174
158
  <tr>
175
- <td>KY</td>
176
- <td>KENTUCKY</td>
177
- <td>KY</td>
159
+ <td>KS</td>
160
+ <td>6th</td>
161
+ <td>06</td>
178
162
  <td>LA</td>
179
- <td>LOUISIANA MER</td>
163
+ <td>Louisiana</td>
180
164
  <td>18</td>
181
165
  </tr>
182
166
  <tr>
183
167
  <td>LA</td>
184
- <td>ST. HELENA MER</td>
168
+ <td>St. Helena</td>
185
169
  <td>24</td>
186
- <td>MA</td>
187
- <td>MASSACHUSETS</td>
188
- <td>MA</td>
189
- </tr>
190
- <tr>
191
- <td>MD</td>
192
- <td>MARYLAND</td>
193
- <td>MD</td>
194
- <td>ME</td>
195
- <td>MAINE</td>
196
- <td>ME</td>
197
- </tr>
198
- <tr>
199
170
  <td>MI</td>
200
- <td>MICHIGAN MER</td>
171
+ <td>Michigan</td>
201
172
  <td>19</td>
202
- <td>MN</td>
203
- <td>5TH PM</td>
204
- <td>05</td>
205
173
  </tr>
206
174
  <tr>
207
175
  <td>MN</td>
208
- <td>4TH PM MN-WI</td>
209
- <td>46</td>
210
- <td>MO</td>
211
- <td>5TH PM</td>
176
+ <td>5th</td>
212
177
  <td>05</td>
178
+ <td>MN</td>
179
+ <td>4th</td>
180
+ <td>46</td>
213
181
  </tr>
214
182
  <tr>
183
+ <td>MO</td>
184
+ <td>5th</td>
185
+ <td>05</td>
215
186
  <td>MS</td>
216
- <td>CHICKASAW MER</td>
187
+ <td>Chickasaw</td>
217
188
  <td>09</td>
218
- <td>MS</td>
219
- <td>CHOCTAW MER</td>
220
- <td>10</td>
221
189
  </tr>
222
190
  <tr>
223
191
  <td>MS</td>
224
- <td>HUNTSVILLE MER</td>
225
- <td>16</td>
192
+ <td>Choctaw</td>
193
+ <td>10</td>
226
194
  <td>MS</td>
227
- <td>ST. STEPHENS MER</td>
228
- <td>25</td>
195
+ <td>Huntsville</td>
196
+ <td>16</td>
229
197
  </tr>
230
198
  <tr>
231
199
  <td>MS</td>
232
- <td>WASHINGTON MER</td>
200
+ <td>St. Stephens</td>
201
+ <td>25</td>
202
+ <td>MS</td>
203
+ <td>Washington</td>
233
204
  <td>32</td>
234
- <td>MT</td>
235
- <td>PRIN MER, MT</td>
236
- <td>20</td>
237
205
  </tr>
238
206
  <tr>
239
- <td>NC</td>
240
- <td>NO CAROLINA</td>
241
- <td>NC</td>
207
+ <td>MT</td>
208
+ <td>Prin</td>
209
+ <td>20</td>
242
210
  <td>ND</td>
243
- <td>5TH PM</td>
211
+ <td>5th</td>
244
212
  <td>05</td>
245
213
  </tr>
246
214
  <tr>
247
215
  <td>NE</td>
248
- <td>6TH PM</td>
216
+ <td>6th</td>
249
217
  <td>06</td>
250
- <td>NH</td>
251
- <td>NEW HAMPSHIRE</td>
252
- <td>NH</td>
253
- </tr>
254
- <tr>
255
- <td>NJ</td>
256
- <td>NEW JERSEY</td>
257
- <td>NJ</td>
258
218
  <td>NM</td>
259
- <td>NEW MEX PM</td>
219
+ <td>New Mex</td>
260
220
  <td>23</td>
261
221
  </tr>
262
222
  <tr>
263
223
  <td>NV</td>
264
- <td>MOUNT DIABLO MER</td>
224
+ <td>Mount Diablo</td>
265
225
  <td>21</td>
266
226
  <td>NV</td>
267
- <td>SAN BERNARDINO MER</td>
227
+ <td>San Bernardino</td>
268
228
  <td>27</td>
269
229
  </tr>
270
230
  <tr>
271
- <td>NY</td>
272
- <td>NEW YORK</td>
273
- <td>NY</td>
274
231
  <td>OH</td>
275
- <td>1ST PM</td>
232
+ <td>1st</td>
276
233
  <td>01</td>
277
- </tr>
278
- <tr>
279
234
  <td>OH</td>
280
- <td>MICHIGAN MER</td>
235
+ <td>Michigan</td>
281
236
  <td>19</td>
282
- <td>OH</td>
283
- <td>OHIO RIVER SURVEY</td>
284
- <td>35</td>
285
237
  </tr>
286
238
  <tr>
287
239
  <td>OH</td>
288
- <td>BETWEEN THE MIAMIS</td>
289
- <td>36</td>
240
+ <td>Ohio River Survey</td>
241
+ <td>35</td>
290
242
  <td>OH</td>
291
- <td>MUSKINGUM RIVER BASIN</td>
292
- <td>37</td>
243
+ <td>Between the Miamis</td>
244
+ <td>36</td>
293
245
  </tr>
294
246
  <tr>
295
247
  <td>OH</td>
296
- <td>OHIO RIVER BASIN</td>
297
- <td>38</td>
248
+ <td>Muskingum River Basin</td>
249
+ <td>37</td>
298
250
  <td>OH</td>
299
- <td>1ST SCIOTO RIVER BASE</td>
300
- <td>39</td>
251
+ <td>Ohio River Basin</td>
252
+ <td>38</td>
301
253
  </tr>
302
254
  <tr>
303
255
  <td>OH</td>
304
- <td>2ND SCIOTO RIVER BASE</td>
305
- <td>40</td>
256
+ <td>1st Scioto River Base</td>
257
+ <td>39</td>
306
258
  <td>OH</td>
307
- <td>3RD SCIOTO RIVER BASE</td>
308
- <td>41</td>
259
+ <td>2nd Scioto River Base</td>
260
+ <td>40</td>
309
261
  </tr>
310
262
  <tr>
311
263
  <td>OH</td>
312
- <td>TWELVE MILE SQUARE</td>
313
- <td>43</td>
264
+ <td>3rd Scioto River Base</td>
265
+ <td>41</td>
314
266
  <td>OH</td>
315
- <td>WEST OF GREAT MIAMI</td>
316
- <td>47</td>
267
+ <td>Twelve Mile Square</td>
268
+ <td>43</td>
317
269
  </tr>
318
270
  <tr>
319
271
  <td>OH</td>
320
- <td>US MILITARY SURVEY</td>
321
- <td>48</td>
272
+ <td>West of Great Miami</td>
273
+ <td>47</td>
322
274
  <td>OH</td>
323
- <td>CT WEST RES-OHIO</td>
324
- <td>91</td>
275
+ <td>US Military Survey</td>
276
+ <td>48</td>
325
277
  </tr>
326
278
  <tr>
327
279
  <td>OH</td>
328
- <td>OHIO CO PUR-OHIO</td>
329
- <td>92</td>
280
+ <td>Ct West Res</td>
281
+ <td>91</td>
330
282
  <td>OH</td>
331
- <td>VA MILITARY SURVEY-OHIO</td>
332
- <td>93</td>
283
+ <td>Ohio CO Pur</td>
284
+ <td>92</td>
333
285
  </tr>
334
286
  <tr>
335
287
  <td>OH</td>
336
- <td>OHIO</td>
337
- <td>OH</td>
288
+ <td>Va Military Survey</td>
289
+ <td>93</td>
338
290
  <td>OK</td>
339
- <td>CIMARRON MER</td>
291
+ <td>Cimarron</td>
340
292
  <td>11</td>
341
293
  </tr>
342
294
  <tr>
343
295
  <td>OK</td>
344
- <td>INDIAN MER</td>
296
+ <td>Indian</td>
345
297
  <td>17</td>
346
298
  <td>OR</td>
347
- <td>WILLAMETTE MER</td>
299
+ <td>Willamette</td>
348
300
  <td>33</td>
349
301
  </tr>
350
302
  <tr>
351
- <td>PA</td>
352
- <td>PENNSYLVANIA</td>
353
- <td>PA</td>
354
- <td>RI</td>
355
- <td>RHODE ISLAND</td>
356
- <td>RI</td>
357
- </tr>
358
- <tr>
359
- <td>SC</td>
360
- <td>SO CAROLINA</td>
361
- <td>SC</td>
362
303
  <td>SD</td>
363
- <td>5TH PM</td>
304
+ <td>5th</td>
364
305
  <td>05</td>
365
- </tr>
366
- <tr>
367
306
  <td>SD</td>
368
- <td>6TH PM</td>
307
+ <td>6th</td>
369
308
  <td>06</td>
370
- <td>SD</td>
371
- <td>BLACK HILLS MER</td>
372
- <td>07</td>
373
- </tr>
374
- <tr>
375
- <td>TN</td>
376
- <td>TENNESSEE</td>
377
- <td>TN</td>
378
- <td>TX</td>
379
- <td>TEXAS</td>
380
- <td>TX</td>
381
309
  </tr>
382
310
  <tr>
311
+ <td>SD</td>
312
+ <td>Black Hills</td>
313
+ <td>07</td>
383
314
  <td>UT</td>
384
- <td>SALT LAKE MER</td>
315
+ <td>Salt Lake</td>
385
316
  <td>26</td>
386
- <td>UT</td>
387
- <td>UINTAH SPEC MER</td>
388
- <td>30</td>
389
- </tr>
390
- <tr>
391
- <td>VA</td>
392
- <td>VIRGINIA</td>
393
- <td>VA</td>
394
- <td>VT</td>
395
- <td>VERMONT</td>
396
- <td>VT</td>
397
317
  </tr>
398
318
  <tr>
319
+ <td>UT</td>
320
+ <td>Uintah Spec</td>
321
+ <td>30</td>
399
322
  <td>WA</td>
400
- <td>WILLAMETTE MER</td>
323
+ <td>Willamette</td>
401
324
  <td>33</td>
402
- <td>WI</td>
403
- <td>4TH PM MN-WI</td>
404
- <td>46</td>
405
325
  </tr>
406
326
  <tr>
407
- <td>WV</td>
408
- <td>WEST VIRGINIA</td>
409
- <td>WV</td>
327
+ <td>WI</td>
328
+ <td>4th</td>
329
+ <td>46</td>
410
330
  <td>WY</td>
411
- <td>6TH PM</td>
331
+ <td>6th</td>
412
332
  <td>06</td>
413
333
  </tr>
414
334
  <tr>
415
335
  <td>WY</td>
416
- <td>WIND RIVER MER</td>
336
+ <td>Wind River</td>
417
337
  <td>34</td>
418
338
  <td></td>
419
339
  <td></td>
@@ -49,9 +49,9 @@ module Interior
49
49
  doc = Nokogiri::XML(xml)
50
50
  data = Nokogiri::XML(doc.children[0].children[5].text)
51
51
  points = data.xpath('//georss:point').first.child.text.split
52
- lon, lat = points
52
+ lon, lat = points == ['0', '0'] ? nil : points
53
53
 
54
- { :lat => lat.to_f, :lon => lon.to_f }
54
+ { :lat => lat.to_f, :lon => lon.to_f } if lon && lat
55
55
  rescue
56
56
  nil # if XML is the wrong format, return nil
57
57
  end
@@ -1,3 +1,3 @@
1
1
  module Interior
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <TownshipGeocoderResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.esri.com/">
3
+ <CompletionStatus>true</CompletionStatus>
4
+ <Message>Ok</Message>
5
+ <Data>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
6
+
7
+ &lt;rss version="2.0" xmlns:georss="http://www.georss.org/georss"&gt;
8
+ &lt;channel&gt;
9
+ &lt;title&gt;Township GeoCoder&lt;/title&gt;
10
+ &lt;item&gt;
11
+ &lt;title&gt;Lat Lon&lt;/title&gt;
12
+ &lt;link&gt;http://www.geocommunicator.gov&lt;/link&gt;
13
+ &lt;description&gt;Latitude(33.384549272498), Longitude(-112.228362739723)&lt;/description&gt;
14
+ &lt;pubDate&gt;1/17/2012 1:45:18 PM&lt;/pubDate&gt;
15
+ &lt;georss:point&gt;0 0&lt;/georss:point&gt;
16
+ &lt;/item&gt;
17
+
18
+ &lt;item&gt;&lt;title&gt;Township Range Section&lt;/title&gt;
19
+ &lt;link&gt;http://www.geocommunicator.gov&lt;/link&gt;
20
+ &lt;description&gt;AZ,14,1,0,N,1,0,E,35,,0&lt;/description&gt;
21
+ &lt;pubDate&gt;1/17/2012 1:45:18 PM&lt;/pubDate&gt;
22
+ &lt;georss:polygon&gt;33.377309949200253,-112.22473576975602,33.377309762935738,-112.22508655240432,33.377309134293,-112.22616916833266,33.37730785372446,-112.22833437690633,33.377306363608341,-112.22906648958326,33.377305152888994,-112.23266758802146,33.377303662772874,-112.23339967741532,33.3773024054874,-112.23700079913641,33.380924970911053,-112.2369908107018,33.38454753633448,-112.23698082226719,33.387510306279239,-112.23697386063094,33.388168308962179,-112.23697292930837,33.39085871361948,-112.23697462897206,33.3917808161018,-112.23697244036401,33.391802213237952,-112.23269233791888,33.3918235638082,-112.22841218890744,33.391844751396775,-112.22413655681072,33.391865892419219,-112.21986092471394,33.388228751797271,-112.21980846796981,33.384591634458559,-112.21975596465961,33.380954284289089,-112.21970516101294,33.377316934119563,-112.21965433408343,33.377315932947795,-112.22005654902097,33.377313464942972,-112.22295871314896,33.3773114858825,-112.22400412274044,33.377309949200253,-112.22473576975602&lt;/georss:polygon&gt;
23
+ &lt;/item&gt;&lt;/channel&gt;&lt;/rss&gt;</Data>
24
+ </TownshipGeocoderResult>
@@ -195,6 +195,15 @@ describe Interior::Geocoder do
195
195
  end
196
196
  end
197
197
 
198
+ # Interior web services sometimes has bad response
199
+ context 'when xml is invalid' do
200
+ let(:xml) { File.open('spec/fixtures/az_bad_response.xml').read }
201
+
202
+ it 'returns nil' do
203
+ subject.should == nil
204
+ end
205
+ end
206
+
198
207
  context 'when no xml is provided' do
199
208
  let(:xml) { nil }
200
209
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interior
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 1
10
- version: 0.9.1
9
+ - 2
10
+ version: 0.9.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Hunt
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-18 00:00:00 Z
18
+ date: 2012-01-21 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rake
@@ -96,6 +96,7 @@ files:
96
96
  - lib/interior/response.rb
97
97
  - lib/interior/version.rb
98
98
  - spec/fixtures/az.xml
99
+ - spec/fixtures/az_bad_response.xml
99
100
  - spec/fixtures/az_invalid_section.xml
100
101
  - spec/fixtures/az_no_section.xml
101
102
  - spec/fixtures/co.xml
@@ -137,6 +138,7 @@ specification_version: 3
137
138
  summary: Convert PLSS to latitude and longitude
138
139
  test_files:
139
140
  - spec/fixtures/az.xml
141
+ - spec/fixtures/az_bad_response.xml
140
142
  - spec/fixtures/az_invalid_section.xml
141
143
  - spec/fixtures/az_no_section.xml
142
144
  - spec/fixtures/co.xml