bing-location 0.0.1b → 0.0.2b
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/README.md +34 -0
- data/bing-location-0.0.1b.gem +0 -0
- data/bing-location.gemspec +3 -1
- data/doc/BingLocator.html +1009 -0
- data/doc/created.rid +4 -0
- data/doc/index.html +67 -0
- data/doc/lib/location_rb.html +60 -0
- data/doc/rdoc.css +706 -0
- data/doc/test/api_key_rb.html +54 -0
- data/doc/test/images_rb.html +54 -0
- metadata +14 -5
data/README.md
CHANGED
@@ -7,3 +7,37 @@ The file listed in .gitignore will need to be recreated with the following synta
|
|
7
7
|
key: YOUR API KEY
|
8
8
|
development:
|
9
9
|
key: YOUR API KEY
|
10
|
+
## Install
|
11
|
+
gem install bing-location --pre
|
12
|
+
## Dependencies
|
13
|
+
- net/http
|
14
|
+
- tempfile
|
15
|
+
- fileutils
|
16
|
+
- yaml
|
17
|
+
|
18
|
+
## Example
|
19
|
+
require 'location'
|
20
|
+
|
21
|
+
my_loc = BingLocator.new()
|
22
|
+
my_loc.api_key = 'YOUR API KEY GOES HERE'
|
23
|
+
|
24
|
+
# Using detailed addresses
|
25
|
+
# my_loc.country_region = 'US'
|
26
|
+
# my_loc.admin_district = 'PA'
|
27
|
+
# my_loc.locality = 'Pittsburgh'
|
28
|
+
# my_loc.address_line = '738 William Pitt Union'
|
29
|
+
|
30
|
+
# Using a query
|
31
|
+
my_loc.query = '738 William Pitt Union Pittsburgh PA 15260'
|
32
|
+
# my_loc.query = 'south side pittsburgh'
|
33
|
+
# my_loc.query = 'eiffel tower'
|
34
|
+
|
35
|
+
# Using latitude and longitude
|
36
|
+
# my_loc.latitude = 40.383545
|
37
|
+
# my_loc.longitude = -80.046509
|
38
|
+
|
39
|
+
# Returning the results
|
40
|
+
# my_loc.obj_type = 'json'
|
41
|
+
# my_loc.get_obj_by_address
|
42
|
+
# puts my_loc.object
|
43
|
+
puts my_loc.get_img_url_by_query(800,600)
|
Binary file
|
data/bing-location.gemspec
CHANGED
@@ -2,8 +2,10 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |s|
|
4
4
|
s.name = 'bing-location'
|
5
|
-
s.version = '0.0.
|
5
|
+
s.version = '0.0.2b'
|
6
6
|
s.summary = 'Access the Bing Maps API by creating location objects with string based queries or geolocation data'
|
7
|
+
s.description = 'Access the Bing Maps API by creating location objects with string based queries or geolocation data'
|
8
|
+
s.homepage = 'http://www.dashdingo.org'
|
7
9
|
s.files = Dir.glob("**/**/**")
|
8
10
|
s.test_files = Dir.glob("test/*")
|
9
11
|
s.author = "Justin Reese"
|
@@ -0,0 +1,1009 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Class: BingLocator</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="./js/jquery.js" type="text/javascript"
|
13
|
+
charset="utf-8"></script>
|
14
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript"
|
15
|
+
charset="utf-8"></script>
|
16
|
+
<script src="./js/quicksearch.js" type="text/javascript"
|
17
|
+
charset="utf-8"></script>
|
18
|
+
<script src="./js/darkfish.js" type="text/javascript"
|
19
|
+
charset="utf-8"></script>
|
20
|
+
|
21
|
+
</head>
|
22
|
+
<body class="class">
|
23
|
+
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="./index.html">Home</a>
|
29
|
+
<a href="./index.html#classes">Classes</a>
|
30
|
+
<a href="./index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="file-metadata">
|
36
|
+
<div id="file-list-section" class="section">
|
37
|
+
<h3 class="section-header">In Files</h3>
|
38
|
+
<div class="section-body">
|
39
|
+
<ul>
|
40
|
+
|
41
|
+
<li><a href="./lib/location_rb.html?TB_iframe=true&height=550&width=785"
|
42
|
+
class="thickbox" title="lib/location.rb">lib/location.rb</a></li>
|
43
|
+
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div id="class-metadata">
|
52
|
+
|
53
|
+
<!-- Parent Class -->
|
54
|
+
|
55
|
+
<div id="parent-class-section" class="section">
|
56
|
+
<h3 class="section-header">Parent</h3>
|
57
|
+
|
58
|
+
<p class="link">Object</p>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Namespace Contents -->
|
64
|
+
|
65
|
+
|
66
|
+
<!-- Method Quickref -->
|
67
|
+
|
68
|
+
<div id="method-list-section" class="section">
|
69
|
+
<h3 class="section-header">Methods</h3>
|
70
|
+
<ul class="link-list">
|
71
|
+
|
72
|
+
<li><a href="#method-i-get_img_by_point">#get_img_by_point</a></li>
|
73
|
+
|
74
|
+
<li><a href="#method-i-get_img_by_query">#get_img_by_query</a></li>
|
75
|
+
|
76
|
+
<li><a href="#method-i-get_img_url_by_point">#get_img_url_by_point</a></li>
|
77
|
+
|
78
|
+
<li><a href="#method-i-get_img_url_by_query">#get_img_url_by_query</a></li>
|
79
|
+
|
80
|
+
<li><a href="#method-i-get_obj_by_address">#get_obj_by_address</a></li>
|
81
|
+
|
82
|
+
<li><a href="#method-i-get_obj_by_point">#get_obj_by_point</a></li>
|
83
|
+
|
84
|
+
<li><a href="#method-i-get_obj_by_query">#get_obj_by_query</a></li>
|
85
|
+
|
86
|
+
<li><a href="#method-i-parse_obj">#parse_obj</a></li>
|
87
|
+
|
88
|
+
<li><a href="#method-i-set_defaults">#set_defaults</a></li>
|
89
|
+
|
90
|
+
</ul>
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
<!-- Included Modules -->
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
<div id="project-metadata">
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
<div id="classindex-section" class="section project-section">
|
103
|
+
<h3 class="section-header">Class Index
|
104
|
+
<span class="search-toggle"><img src="./images/find.png"
|
105
|
+
height="16" width="16" alt="[+]"
|
106
|
+
title="show/hide quicksearch" /></span></h3>
|
107
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
108
|
+
<fieldset>
|
109
|
+
<legend>Quicksearch</legend>
|
110
|
+
<input type="text" name="quicksearch" value=""
|
111
|
+
class="quicksearch-field" />
|
112
|
+
</fieldset>
|
113
|
+
</form>
|
114
|
+
|
115
|
+
<ul class="link-list">
|
116
|
+
|
117
|
+
<li><a href="./BingLocator.html">BingLocator</a></li>
|
118
|
+
|
119
|
+
</ul>
|
120
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
121
|
+
</div>
|
122
|
+
|
123
|
+
|
124
|
+
</div>
|
125
|
+
</div>
|
126
|
+
|
127
|
+
<div id="documentation">
|
128
|
+
<h1 class="class">BingLocator</h1>
|
129
|
+
|
130
|
+
<div id="description">
|
131
|
+
<p>
|
132
|
+
This class is a wrapper for the Bing Maps API (<a
|
133
|
+
href="http://msdn.microsoft.com/en-us/library/ff701724.aspx">API
|
134
|
+
Documentation</a>) that makes it easy to get more information about a
|
135
|
+
location or create maps.
|
136
|
+
</p>
|
137
|
+
<p>
|
138
|
+
Currently the class is built for dealing with one object (point on a
|
139
|
+
map/location).
|
140
|
+
</p>
|
141
|
+
<h1>Example Usage</h1>
|
142
|
+
<pre>
|
143
|
+
my_loc = BingLocator.new()
|
144
|
+
my_loc.api_key = "YOU-BING-MAPS-API-KEY"
|
145
|
+
my_loc.country_region = 'US'
|
146
|
+
my_loc.admin_district = 'PA'
|
147
|
+
my_loc.locality = 'Pittsburgh'
|
148
|
+
my_loc.address_line = '430 Atwood St'
|
149
|
+
my_loc.obj_type = 'json'
|
150
|
+
my_loc.get_obj_by_address
|
151
|
+
puts my_loc.object
|
152
|
+
|
153
|
+
my_loc = BingLocator.new()
|
154
|
+
my_loc.api_key = "YOU-BING-MAPS-API-KEY"
|
155
|
+
my_loc.query = 'University of Pittsburgh'
|
156
|
+
puts my_loc.get_img_url_by_query(800,600)</pre>
|
157
|
+
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<!-- Constants -->
|
161
|
+
|
162
|
+
|
163
|
+
<!-- Attributes -->
|
164
|
+
|
165
|
+
<div id="attribute-method-details" class="method-section section">
|
166
|
+
<h3 class="section-header">Attributes</h3>
|
167
|
+
|
168
|
+
|
169
|
+
<div id="country-region-attribute-method" class="method-detail">
|
170
|
+
<a name="country_region"></a>
|
171
|
+
|
172
|
+
<a name="country_region="></a>
|
173
|
+
|
174
|
+
<div class="method-heading attribute-method-heading">
|
175
|
+
<span class="method-name">country_region</span><span
|
176
|
+
class="attribute-access-type">[RW]</span>
|
177
|
+
</div>
|
178
|
+
|
179
|
+
<div class="method-description">
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
</div>
|
184
|
+
</div>
|
185
|
+
|
186
|
+
<div id="admin-district-attribute-method" class="method-detail">
|
187
|
+
<a name="admin_district"></a>
|
188
|
+
|
189
|
+
<a name="admin_district="></a>
|
190
|
+
|
191
|
+
<div class="method-heading attribute-method-heading">
|
192
|
+
<span class="method-name">admin_district</span><span
|
193
|
+
class="attribute-access-type">[RW]</span>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
<div class="method-description">
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
</div>
|
201
|
+
</div>
|
202
|
+
|
203
|
+
<div id="postal-code-attribute-method" class="method-detail">
|
204
|
+
<a name="postal_code"></a>
|
205
|
+
|
206
|
+
<a name="postal_code="></a>
|
207
|
+
|
208
|
+
<div class="method-heading attribute-method-heading">
|
209
|
+
<span class="method-name">postal_code</span><span
|
210
|
+
class="attribute-access-type">[RW]</span>
|
211
|
+
</div>
|
212
|
+
|
213
|
+
<div class="method-description">
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
</div>
|
218
|
+
</div>
|
219
|
+
|
220
|
+
<div id="locality-attribute-method" class="method-detail">
|
221
|
+
<a name="locality"></a>
|
222
|
+
|
223
|
+
<a name="locality="></a>
|
224
|
+
|
225
|
+
<div class="method-heading attribute-method-heading">
|
226
|
+
<span class="method-name">locality</span><span
|
227
|
+
class="attribute-access-type">[RW]</span>
|
228
|
+
</div>
|
229
|
+
|
230
|
+
<div class="method-description">
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
</div>
|
235
|
+
</div>
|
236
|
+
|
237
|
+
<div id="address-line-attribute-method" class="method-detail">
|
238
|
+
<a name="address_line"></a>
|
239
|
+
|
240
|
+
<a name="address_line="></a>
|
241
|
+
|
242
|
+
<div class="method-heading attribute-method-heading">
|
243
|
+
<span class="method-name">address_line</span><span
|
244
|
+
class="attribute-access-type">[RW]</span>
|
245
|
+
</div>
|
246
|
+
|
247
|
+
<div class="method-description">
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
</div>
|
252
|
+
</div>
|
253
|
+
|
254
|
+
<div id="api-key-attribute-method" class="method-detail">
|
255
|
+
<a name="api_key"></a>
|
256
|
+
|
257
|
+
<a name="api_key="></a>
|
258
|
+
|
259
|
+
<div class="method-heading attribute-method-heading">
|
260
|
+
<span class="method-name">api_key</span><span
|
261
|
+
class="attribute-access-type">[RW]</span>
|
262
|
+
</div>
|
263
|
+
|
264
|
+
<div class="method-description">
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
</div>
|
269
|
+
</div>
|
270
|
+
|
271
|
+
<div id="obj-type-attribute-method" class="method-detail">
|
272
|
+
<a name="obj_type"></a>
|
273
|
+
|
274
|
+
<a name="obj_type="></a>
|
275
|
+
|
276
|
+
<div class="method-heading attribute-method-heading">
|
277
|
+
<span class="method-name">obj_type</span><span
|
278
|
+
class="attribute-access-type">[RW]</span>
|
279
|
+
</div>
|
280
|
+
|
281
|
+
<div class="method-description">
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
</div>
|
286
|
+
</div>
|
287
|
+
|
288
|
+
<div id="query-attribute-method" class="method-detail">
|
289
|
+
<a name="query"></a>
|
290
|
+
|
291
|
+
<a name="query="></a>
|
292
|
+
|
293
|
+
<div class="method-heading attribute-method-heading">
|
294
|
+
<span class="method-name">query</span><span
|
295
|
+
class="attribute-access-type">[RW]</span>
|
296
|
+
</div>
|
297
|
+
|
298
|
+
<div class="method-description">
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
</div>
|
303
|
+
</div>
|
304
|
+
|
305
|
+
<div id="map-type-attribute-method" class="method-detail">
|
306
|
+
<a name="map_type"></a>
|
307
|
+
|
308
|
+
<a name="map_type="></a>
|
309
|
+
|
310
|
+
<div class="method-heading attribute-method-heading">
|
311
|
+
<span class="method-name">map_type</span><span
|
312
|
+
class="attribute-access-type">[RW]</span>
|
313
|
+
</div>
|
314
|
+
|
315
|
+
<div class="method-description">
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
</div>
|
320
|
+
</div>
|
321
|
+
|
322
|
+
<div id="show-traffic-attribute-method" class="method-detail">
|
323
|
+
<a name="show_traffic"></a>
|
324
|
+
|
325
|
+
<a name="show_traffic="></a>
|
326
|
+
|
327
|
+
<div class="method-heading attribute-method-heading">
|
328
|
+
<span class="method-name">show_traffic</span><span
|
329
|
+
class="attribute-access-type">[RW]</span>
|
330
|
+
</div>
|
331
|
+
|
332
|
+
<div class="method-description">
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
</div>
|
337
|
+
</div>
|
338
|
+
|
339
|
+
<div id="zoom-level-attribute-method" class="method-detail">
|
340
|
+
<a name="zoom_level"></a>
|
341
|
+
|
342
|
+
<a name="zoom_level="></a>
|
343
|
+
|
344
|
+
<div class="method-heading attribute-method-heading">
|
345
|
+
<span class="method-name">zoom_level</span><span
|
346
|
+
class="attribute-access-type">[RW]</span>
|
347
|
+
</div>
|
348
|
+
|
349
|
+
<div class="method-description">
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
</div>
|
354
|
+
</div>
|
355
|
+
|
356
|
+
<div id="name-attribute-method" class="method-detail">
|
357
|
+
<a name="name"></a>
|
358
|
+
|
359
|
+
<a name="name="></a>
|
360
|
+
|
361
|
+
<div class="method-heading attribute-method-heading">
|
362
|
+
<span class="method-name">name</span><span
|
363
|
+
class="attribute-access-type">[RW]</span>
|
364
|
+
</div>
|
365
|
+
|
366
|
+
<div class="method-description">
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
</div>
|
371
|
+
</div>
|
372
|
+
|
373
|
+
<div id="point-attribute-method" class="method-detail">
|
374
|
+
<a name="point"></a>
|
375
|
+
|
376
|
+
<a name="point="></a>
|
377
|
+
|
378
|
+
<div class="method-heading attribute-method-heading">
|
379
|
+
<span class="method-name">point</span><span
|
380
|
+
class="attribute-access-type">[RW]</span>
|
381
|
+
</div>
|
382
|
+
|
383
|
+
<div class="method-description">
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
</div>
|
388
|
+
</div>
|
389
|
+
|
390
|
+
<div id="latitude-attribute-method" class="method-detail">
|
391
|
+
<a name="latitude"></a>
|
392
|
+
|
393
|
+
<a name="latitude="></a>
|
394
|
+
|
395
|
+
<div class="method-heading attribute-method-heading">
|
396
|
+
<span class="method-name">latitude</span><span
|
397
|
+
class="attribute-access-type">[RW]</span>
|
398
|
+
</div>
|
399
|
+
|
400
|
+
<div class="method-description">
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
</div>
|
405
|
+
</div>
|
406
|
+
|
407
|
+
<div id="longitude-attribute-method" class="method-detail">
|
408
|
+
<a name="longitude"></a>
|
409
|
+
|
410
|
+
<a name="longitude="></a>
|
411
|
+
|
412
|
+
<div class="method-heading attribute-method-heading">
|
413
|
+
<span class="method-name">longitude</span><span
|
414
|
+
class="attribute-access-type">[RW]</span>
|
415
|
+
</div>
|
416
|
+
|
417
|
+
<div class="method-description">
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
</div>
|
422
|
+
</div>
|
423
|
+
|
424
|
+
<div id="admin-district--attribute-method" class="method-detail">
|
425
|
+
<a name="admin_district_2"></a>
|
426
|
+
|
427
|
+
<a name="admin_district_2="></a>
|
428
|
+
|
429
|
+
<div class="method-heading attribute-method-heading">
|
430
|
+
<span class="method-name">admin_district_2</span><span
|
431
|
+
class="attribute-access-type">[RW]</span>
|
432
|
+
</div>
|
433
|
+
|
434
|
+
<div class="method-description">
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
</div>
|
439
|
+
</div>
|
440
|
+
|
441
|
+
<div id="formatted-address-attribute-method" class="method-detail">
|
442
|
+
<a name="formatted_address"></a>
|
443
|
+
|
444
|
+
<a name="formatted_address="></a>
|
445
|
+
|
446
|
+
<div class="method-heading attribute-method-heading">
|
447
|
+
<span class="method-name">formatted_address</span><span
|
448
|
+
class="attribute-access-type">[RW]</span>
|
449
|
+
</div>
|
450
|
+
|
451
|
+
<div class="method-description">
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
</div>
|
456
|
+
</div>
|
457
|
+
|
458
|
+
<div id="confidence-attribute-method" class="method-detail">
|
459
|
+
<a name="confidence"></a>
|
460
|
+
|
461
|
+
<a name="confidence="></a>
|
462
|
+
|
463
|
+
<div class="method-heading attribute-method-heading">
|
464
|
+
<span class="method-name">confidence</span><span
|
465
|
+
class="attribute-access-type">[RW]</span>
|
466
|
+
</div>
|
467
|
+
|
468
|
+
<div class="method-description">
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
</div>
|
473
|
+
</div>
|
474
|
+
|
475
|
+
<div id="object-attribute-method" class="method-detail">
|
476
|
+
<a name="object"></a>
|
477
|
+
|
478
|
+
<a name="object="></a>
|
479
|
+
|
480
|
+
<div class="method-heading attribute-method-heading">
|
481
|
+
<span class="method-name">object</span><span
|
482
|
+
class="attribute-access-type">[RW]</span>
|
483
|
+
</div>
|
484
|
+
|
485
|
+
<div class="method-description">
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
</div>
|
490
|
+
</div>
|
491
|
+
|
492
|
+
<div id="image-attribute-method" class="method-detail">
|
493
|
+
<a name="image"></a>
|
494
|
+
|
495
|
+
<a name="image="></a>
|
496
|
+
|
497
|
+
<div class="method-heading attribute-method-heading">
|
498
|
+
<span class="method-name">image</span><span
|
499
|
+
class="attribute-access-type">[RW]</span>
|
500
|
+
</div>
|
501
|
+
|
502
|
+
<div class="method-description">
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
</div>
|
507
|
+
</div>
|
508
|
+
|
509
|
+
</div>
|
510
|
+
|
511
|
+
|
512
|
+
<!-- Methods -->
|
513
|
+
|
514
|
+
<div id="public-instance-method-details" class="method-section section">
|
515
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
516
|
+
|
517
|
+
|
518
|
+
<div id="get-img-by-point-method" class="method-detail ">
|
519
|
+
<a name="method-i-get_img_by_point"></a>
|
520
|
+
|
521
|
+
<div class="method-heading">
|
522
|
+
|
523
|
+
<span class="method-name">get_img_by_point</span><span
|
524
|
+
class="method-args">(width,height)</span>
|
525
|
+
<span class="method-click-advice">click to toggle source</span>
|
526
|
+
|
527
|
+
</div>
|
528
|
+
|
529
|
+
<div class="method-description">
|
530
|
+
|
531
|
+
<p>
|
532
|
+
Uses the object’s latitude and longitude to get an image file from
|
533
|
+
the Bing API.
|
534
|
+
</p>
|
535
|
+
<p>
|
536
|
+
The file will be returned as a File object. To save the file use something
|
537
|
+
like the following:
|
538
|
+
</p>
|
539
|
+
<pre>
|
540
|
+
File.rename(my_loc.get_img_by_point(800,600).path,'map.jpeg')</pre>
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
<div class="method-source-code"
|
545
|
+
id="get-img-by-point-source">
|
546
|
+
<pre>
|
547
|
+
<span class="ruby-comment cmt"># File lib/location.rb, line 169</span>
|
548
|
+
169: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_img_by_point</span>(<span class="ruby-identifier">width</span>,<span class="ruby-identifier">height</span>)
|
549
|
+
170: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">set_defaults</span>
|
550
|
+
171: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">'No latitude or longitude set for location'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">latitude</span> <span class="ruby-operator">&&</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">longitude</span>
|
551
|
+
172: <span class="ruby-comment cmt"># Build request URL</span>
|
552
|
+
173: <span class="ruby-identifier">params</span> = <span class="ruby-node">"#{self.map_type}/#{self.latitude},#{self.longitude}/#{self.zoom_level}"</span>
|
553
|
+
174: <span class="ruby-identifier">params</span> <span class="ruby-operator">+=</span> <span class="ruby-node">"?mapSize=#{width},#{height}&pushpin=#{self.latitude},#{self.longitude}"</span>
|
554
|
+
175: <span class="ruby-identifier">params</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">"&mapLayer=TrafficFlow"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">show_traffic</span> <span class="ruby-operator">==</span> <span class="ruby-constant">TRUE</span>
|
555
|
+
176: <span class="ruby-identifier">request_url</span> = <span class="ruby-identifier">$img_base_url</span><span class="ruby-operator">+</span><span class="ruby-identifier">params</span><span class="ruby-operator">+</span><span class="ruby-node">"&key=#{self.api_key}"</span>
|
556
|
+
177: <span class="ruby-comment cmt"># REST request !</span>
|
557
|
+
178: <span class="ruby-keyword kw">begin</span>
|
558
|
+
179: <span class="ruby-identifier">tmp</span> = <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'map_image.jpeg'</span>)
|
559
|
+
180: <span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">write</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get_response</span>(<span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">request_url</span>)).<span class="ruby-identifier">body</span>
|
560
|
+
181: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">flush</span>
|
561
|
+
182: <span class="ruby-keyword kw">rescue</span>
|
562
|
+
183: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">FALSE</span>
|
563
|
+
184: <span class="ruby-keyword kw">end</span>
|
564
|
+
185: <span class="ruby-keyword kw">end</span></pre>
|
565
|
+
</div>
|
566
|
+
|
567
|
+
</div>
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
|
572
|
+
</div>
|
573
|
+
|
574
|
+
|
575
|
+
<div id="get-img-by-query-method" class="method-detail ">
|
576
|
+
<a name="method-i-get_img_by_query"></a>
|
577
|
+
|
578
|
+
<div class="method-heading">
|
579
|
+
|
580
|
+
<span class="method-name">get_img_by_query</span><span
|
581
|
+
class="method-args">(width,height)</span>
|
582
|
+
<span class="method-click-advice">click to toggle source</span>
|
583
|
+
|
584
|
+
</div>
|
585
|
+
|
586
|
+
<div class="method-description">
|
587
|
+
|
588
|
+
<p>
|
589
|
+
Uses the object’s query to get an image file from the Bing API.
|
590
|
+
</p>
|
591
|
+
<p>
|
592
|
+
The file will be returned as a File object. To save the file use something
|
593
|
+
like the following:
|
594
|
+
</p>
|
595
|
+
<pre>
|
596
|
+
File.rename(my_loc.get_img_by_query(800,600).path,'map.jpeg')</pre>
|
597
|
+
|
598
|
+
|
599
|
+
|
600
|
+
<div class="method-source-code"
|
601
|
+
id="get-img-by-query-source">
|
602
|
+
<pre>
|
603
|
+
<span class="ruby-comment cmt"># File lib/location.rb, line 122</span>
|
604
|
+
122: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_img_by_query</span>(<span class="ruby-identifier">width</span>,<span class="ruby-identifier">height</span>)
|
605
|
+
123: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">set_defaults</span>
|
606
|
+
124: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">'No query set for location'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>
|
607
|
+
125: <span class="ruby-identifier">query</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">' '</span>,<span class="ruby-value str">'%20'</span>)
|
608
|
+
126: <span class="ruby-comment cmt"># Build request URL</span>
|
609
|
+
127: <span class="ruby-identifier">params</span> = <span class="ruby-node">"#{self.map_type}/#{query}?mapSize=#{width},#{height}"</span>
|
610
|
+
128: <span class="ruby-identifier">params</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">"&mapLayer=TrafficFlow"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">show_traffic</span> <span class="ruby-operator">==</span> <span class="ruby-constant">TRUE</span>
|
611
|
+
129: <span class="ruby-identifier">request_url</span> = <span class="ruby-identifier">$img_base_url</span><span class="ruby-operator">+</span><span class="ruby-identifier">params</span><span class="ruby-operator">+</span><span class="ruby-node">"&key=#{self.api_key}"</span>
|
612
|
+
130: <span class="ruby-comment cmt"># REST request !</span>
|
613
|
+
131: <span class="ruby-keyword kw">begin</span>
|
614
|
+
132: <span class="ruby-identifier">tmp</span> = <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'map_image.jpeg'</span>)
|
615
|
+
133: <span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">write</span> <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get_response</span>(<span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">request_url</span>)).<span class="ruby-identifier">body</span>
|
616
|
+
134: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">flush</span>
|
617
|
+
135: <span class="ruby-keyword kw">rescue</span>
|
618
|
+
136: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">FALSE</span>
|
619
|
+
137: <span class="ruby-keyword kw">end</span>
|
620
|
+
138: <span class="ruby-keyword kw">end</span></pre>
|
621
|
+
</div>
|
622
|
+
|
623
|
+
</div>
|
624
|
+
|
625
|
+
|
626
|
+
|
627
|
+
|
628
|
+
</div>
|
629
|
+
|
630
|
+
|
631
|
+
<div id="get-img-url-by-point-method" class="method-detail ">
|
632
|
+
<a name="method-i-get_img_url_by_point"></a>
|
633
|
+
|
634
|
+
<div class="method-heading">
|
635
|
+
|
636
|
+
<span class="method-name">get_img_url_by_point</span><span
|
637
|
+
class="method-args">(width,height)</span>
|
638
|
+
<span class="method-click-advice">click to toggle source</span>
|
639
|
+
|
640
|
+
</div>
|
641
|
+
|
642
|
+
<div class="method-description">
|
643
|
+
|
644
|
+
<p>
|
645
|
+
Uses the object’s latitude and longitude to get an image url from the
|
646
|
+
Bing API. Using the Bing URL is discouraged.
|
647
|
+
</p>
|
648
|
+
|
649
|
+
|
650
|
+
|
651
|
+
<div class="method-source-code"
|
652
|
+
id="get-img-url-by-point-source">
|
653
|
+
<pre>
|
654
|
+
<span class="ruby-comment cmt"># File lib/location.rb, line 154</span>
|
655
|
+
154: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_img_url_by_point</span>(<span class="ruby-identifier">width</span>,<span class="ruby-identifier">height</span>)
|
656
|
+
155: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">set_defaults</span>
|
657
|
+
156: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">'No latitude or longitude set for location'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">latitude</span> <span class="ruby-operator">&&</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">longitude</span>
|
658
|
+
157: <span class="ruby-comment cmt"># Build request URL</span>
|
659
|
+
158: <span class="ruby-identifier">params</span> = <span class="ruby-node">"#{self.map_type}/#{self.latitude},#{self.longitude}/#{self.zoom_level}"</span>
|
660
|
+
159: <span class="ruby-identifier">params</span> <span class="ruby-operator">+=</span> <span class="ruby-node">"?mapSize=#{width},#{height}&pushpin=#{self.latitude},#{self.longitude}"</span>
|
661
|
+
160: <span class="ruby-identifier">params</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">"&mapLayer=TrafficFlow"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">show_traffic</span> <span class="ruby-operator">==</span> <span class="ruby-constant">TRUE</span>
|
662
|
+
161: <span class="ruby-identifier">request_url</span> = <span class="ruby-identifier">$img_base_url</span><span class="ruby-operator">+</span><span class="ruby-identifier">params</span><span class="ruby-operator">+</span><span class="ruby-node">"&key=#{self.api_key}"</span>
|
663
|
+
162: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">request_url</span>
|
664
|
+
163: <span class="ruby-keyword kw">end</span></pre>
|
665
|
+
</div>
|
666
|
+
|
667
|
+
</div>
|
668
|
+
|
669
|
+
|
670
|
+
|
671
|
+
|
672
|
+
</div>
|
673
|
+
|
674
|
+
|
675
|
+
<div id="get-img-url-by-query-method" class="method-detail ">
|
676
|
+
<a name="method-i-get_img_url_by_query"></a>
|
677
|
+
|
678
|
+
<div class="method-heading">
|
679
|
+
|
680
|
+
<span class="method-name">get_img_url_by_query</span><span
|
681
|
+
class="method-args">(width,height)</span>
|
682
|
+
<span class="method-click-advice">click to toggle source</span>
|
683
|
+
|
684
|
+
</div>
|
685
|
+
|
686
|
+
<div class="method-description">
|
687
|
+
|
688
|
+
<p>
|
689
|
+
Uses the object’s query to get an image url from the Bing API. Using
|
690
|
+
the Bing URL is discouraged.
|
691
|
+
</p>
|
692
|
+
|
693
|
+
|
694
|
+
|
695
|
+
<div class="method-source-code"
|
696
|
+
id="get-img-url-by-query-source">
|
697
|
+
<pre>
|
698
|
+
<span class="ruby-comment cmt"># File lib/location.rb, line 141</span>
|
699
|
+
141: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_img_url_by_query</span>(<span class="ruby-identifier">width</span>,<span class="ruby-identifier">height</span>)
|
700
|
+
142: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">set_defaults</span>
|
701
|
+
143: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">'No query set for location'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>
|
702
|
+
144: <span class="ruby-identifier">query</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">' '</span>,<span class="ruby-value str">'%20'</span>)
|
703
|
+
145: <span class="ruby-comment cmt"># Build request URL</span>
|
704
|
+
146: <span class="ruby-identifier">params</span> = <span class="ruby-node">"#{self.map_type}/#{query}?mapSize=#{width},#{height}"</span>
|
705
|
+
147: <span class="ruby-identifier">params</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">"&mapLayer=TrafficFlow"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">show_traffic</span> <span class="ruby-operator">==</span> <span class="ruby-constant">TRUE</span>
|
706
|
+
148: <span class="ruby-identifier">request_url</span> = <span class="ruby-identifier">$img_base_url</span><span class="ruby-operator">+</span><span class="ruby-identifier">params</span><span class="ruby-operator">+</span><span class="ruby-node">"&key=#{self.api_key}"</span>
|
707
|
+
149: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">request_url</span>
|
708
|
+
150: <span class="ruby-keyword kw">end</span></pre>
|
709
|
+
</div>
|
710
|
+
|
711
|
+
</div>
|
712
|
+
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
</div>
|
717
|
+
|
718
|
+
|
719
|
+
<div id="get-obj-by-address-method" class="method-detail ">
|
720
|
+
<a name="method-i-get_obj_by_address"></a>
|
721
|
+
|
722
|
+
<div class="method-heading">
|
723
|
+
|
724
|
+
<span class="method-name">get_obj_by_address</span><span
|
725
|
+
class="method-args">()</span>
|
726
|
+
<span class="method-click-advice">click to toggle source</span>
|
727
|
+
|
728
|
+
</div>
|
729
|
+
|
730
|
+
<div class="method-description">
|
731
|
+
|
732
|
+
<p>
|
733
|
+
Uses the object’s address to get a Location object from the Bing API.
|
734
|
+
The object contains a normalized address, extra information, and latitude,
|
735
|
+
longitude information
|
736
|
+
</p>
|
737
|
+
|
738
|
+
|
739
|
+
|
740
|
+
<div class="method-source-code"
|
741
|
+
id="get-obj-by-address-source">
|
742
|
+
<pre>
|
743
|
+
<span class="ruby-comment cmt"># File lib/location.rb, line 62</span>
|
744
|
+
62: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_obj_by_address</span>
|
745
|
+
63: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">set_defaults</span>
|
746
|
+
64: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">'No address set for location'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">country_region</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">admin_district</span> <span class="ruby-operator">&&</span>
|
747
|
+
65: <span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">postal_code</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">locality</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">address_line</span>
|
748
|
+
66: <span class="ruby-comment cmt"># Reformat strings</span>
|
749
|
+
67: <span class="ruby-identifier">address_line</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">address_line</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">' '</span>,<span class="ruby-value str">'%20'</span>)
|
750
|
+
68: <span class="ruby-identifier">locality</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">locality</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">' '</span>,<span class="ruby-value str">'%20'</span>)
|
751
|
+
69: <span class="ruby-comment cmt"># Build request URL</span>
|
752
|
+
70: <span class="ruby-identifier">params</span> = <span class="ruby-node">"#{self.country_region}/#{self.admin_district}/#{self.postal_code}/"</span>
|
753
|
+
71: <span class="ruby-identifier">params</span> <span class="ruby-operator">+=</span> <span class="ruby-node">"#{locality}/#{address_line}?o=#{self.obj_type}"</span>
|
754
|
+
72: <span class="ruby-identifier">request_url</span> = <span class="ruby-identifier">$obj_base_url</span><span class="ruby-operator">+</span><span class="ruby-identifier">params</span><span class="ruby-operator">+</span><span class="ruby-node">"&key=#{self.api_key}"</span>
|
755
|
+
73: <span class="ruby-comment cmt"># REST request !</span>
|
756
|
+
74: <span class="ruby-keyword kw">begin</span>
|
757
|
+
75: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">object</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get_response</span>(<span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">request_url</span>)).<span class="ruby-identifier">body</span>
|
758
|
+
76: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">object</span>
|
759
|
+
77: <span class="ruby-keyword kw">rescue</span>
|
760
|
+
78: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">FALSE</span>
|
761
|
+
79: <span class="ruby-keyword kw">end</span>
|
762
|
+
80: <span class="ruby-keyword kw">end</span></pre>
|
763
|
+
</div>
|
764
|
+
|
765
|
+
</div>
|
766
|
+
|
767
|
+
|
768
|
+
|
769
|
+
|
770
|
+
</div>
|
771
|
+
|
772
|
+
|
773
|
+
<div id="get-obj-by-point-method" class="method-detail ">
|
774
|
+
<a name="method-i-get_obj_by_point"></a>
|
775
|
+
|
776
|
+
<div class="method-heading">
|
777
|
+
|
778
|
+
<span class="method-name">get_obj_by_point</span><span
|
779
|
+
class="method-args">()</span>
|
780
|
+
<span class="method-click-advice">click to toggle source</span>
|
781
|
+
|
782
|
+
</div>
|
783
|
+
|
784
|
+
<div class="method-description">
|
785
|
+
|
786
|
+
<p>
|
787
|
+
Uses the object’s latitude and longitude to get a Location object
|
788
|
+
from the Bing API. The object contains a normalized address, extra
|
789
|
+
information, and latitude, longitude information
|
790
|
+
</p>
|
791
|
+
|
792
|
+
|
793
|
+
|
794
|
+
<div class="method-source-code"
|
795
|
+
id="get-obj-by-point-source">
|
796
|
+
<pre>
|
797
|
+
<span class="ruby-comment cmt"># File lib/location.rb, line 84</span>
|
798
|
+
84: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_obj_by_point</span>
|
799
|
+
85: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">set_defaults</span>
|
800
|
+
86: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">'No latitude or longitude set for location'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">latitude</span> <span class="ruby-operator">&&</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">longitude</span>
|
801
|
+
87: <span class="ruby-comment cmt"># Build request URL</span>
|
802
|
+
88: <span class="ruby-identifier">params</span> = <span class="ruby-operator">+</span><span class="ruby-node">"#{self.latitude},#{self.longitude}?o=#{self.obj_type}"</span>
|
803
|
+
89: <span class="ruby-identifier">request_url</span> = <span class="ruby-identifier">$obj_base_url</span><span class="ruby-operator">+</span><span class="ruby-identifier">params</span><span class="ruby-operator">+</span><span class="ruby-node">"&key=#{self.api_key}"</span>
|
804
|
+
90: <span class="ruby-comment cmt"># REST request !</span>
|
805
|
+
91: <span class="ruby-keyword kw">begin</span>
|
806
|
+
92: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">object</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get_response</span>(<span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">request_url</span>)).<span class="ruby-identifier">body</span>
|
807
|
+
93: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">object</span>
|
808
|
+
94: <span class="ruby-keyword kw">rescue</span>
|
809
|
+
95: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">FALSE</span>
|
810
|
+
96: <span class="ruby-keyword kw">end</span>
|
811
|
+
97: <span class="ruby-keyword kw">end</span></pre>
|
812
|
+
</div>
|
813
|
+
|
814
|
+
</div>
|
815
|
+
|
816
|
+
|
817
|
+
|
818
|
+
|
819
|
+
</div>
|
820
|
+
|
821
|
+
|
822
|
+
<div id="get-obj-by-query-method" class="method-detail ">
|
823
|
+
<a name="method-i-get_obj_by_query"></a>
|
824
|
+
|
825
|
+
<div class="method-heading">
|
826
|
+
|
827
|
+
<span class="method-name">get_obj_by_query</span><span
|
828
|
+
class="method-args">()</span>
|
829
|
+
<span class="method-click-advice">click to toggle source</span>
|
830
|
+
|
831
|
+
</div>
|
832
|
+
|
833
|
+
<div class="method-description">
|
834
|
+
|
835
|
+
<p>
|
836
|
+
Uses the object’s query to get a Location object from the Bing API.
|
837
|
+
The object contains a normalized address, extra information, and latitude,
|
838
|
+
longitude information
|
839
|
+
</p>
|
840
|
+
|
841
|
+
|
842
|
+
|
843
|
+
<div class="method-source-code"
|
844
|
+
id="get-obj-by-query-source">
|
845
|
+
<pre>
|
846
|
+
<span class="ruby-comment cmt"># File lib/location.rb, line 102</span>
|
847
|
+
102: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_obj_by_query</span>
|
848
|
+
103: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">set_defaults</span>
|
849
|
+
104: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">'No query set for location'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>
|
850
|
+
105: <span class="ruby-identifier">query</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">' '</span>,<span class="ruby-value str">'%20'</span>)
|
851
|
+
106: <span class="ruby-comment cmt"># Build request URL</span>
|
852
|
+
107: <span class="ruby-identifier">params</span> = <span class="ruby-node">"#{query}?o=#{self.obj_type}"</span>
|
853
|
+
108: <span class="ruby-identifier">request_url</span> = <span class="ruby-identifier">$obj_base_url</span><span class="ruby-operator">+</span><span class="ruby-identifier">params</span><span class="ruby-operator">+</span><span class="ruby-node">"&key=#{self.api_key}"</span>
|
854
|
+
109: <span class="ruby-comment cmt"># REST request !</span>
|
855
|
+
110: <span class="ruby-keyword kw">begin</span>
|
856
|
+
111: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">object</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get_response</span>(<span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">request_url</span>)).<span class="ruby-identifier">body</span>
|
857
|
+
112: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">object</span>
|
858
|
+
113: <span class="ruby-keyword kw">rescue</span>
|
859
|
+
114: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">FALSE</span>
|
860
|
+
115: <span class="ruby-keyword kw">end</span>
|
861
|
+
116: <span class="ruby-keyword kw">end</span></pre>
|
862
|
+
</div>
|
863
|
+
|
864
|
+
</div>
|
865
|
+
|
866
|
+
|
867
|
+
|
868
|
+
|
869
|
+
</div>
|
870
|
+
|
871
|
+
|
872
|
+
<div id="parse-obj-method" class="method-detail ">
|
873
|
+
<a name="method-i-parse_obj"></a>
|
874
|
+
|
875
|
+
<div class="method-heading">
|
876
|
+
|
877
|
+
<span class="method-name">parse_obj</span><span
|
878
|
+
class="method-args">()</span>
|
879
|
+
<span class="method-click-advice">click to toggle source</span>
|
880
|
+
|
881
|
+
</div>
|
882
|
+
|
883
|
+
<div class="method-description">
|
884
|
+
|
885
|
+
|
886
|
+
|
887
|
+
|
888
|
+
|
889
|
+
<div class="method-source-code"
|
890
|
+
id="parse-obj-source">
|
891
|
+
<pre>
|
892
|
+
<span class="ruby-comment cmt"># File lib/location.rb, line 187</span>
|
893
|
+
187: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_obj</span>
|
894
|
+
188: <span class="ruby-comment cmt"># TODO - WRITE THIS</span>
|
895
|
+
189: <span class="ruby-keyword kw">end</span></pre>
|
896
|
+
</div>
|
897
|
+
|
898
|
+
</div>
|
899
|
+
|
900
|
+
|
901
|
+
|
902
|
+
|
903
|
+
</div>
|
904
|
+
|
905
|
+
|
906
|
+
<div id="set-defaults-method" class="method-detail ">
|
907
|
+
<a name="method-i-set_defaults"></a>
|
908
|
+
|
909
|
+
<div class="method-heading">
|
910
|
+
|
911
|
+
<span class="method-name">set_defaults</span><span
|
912
|
+
class="method-args">()</span>
|
913
|
+
<span class="method-click-advice">click to toggle source</span>
|
914
|
+
|
915
|
+
</div>
|
916
|
+
|
917
|
+
<div class="method-description">
|
918
|
+
|
919
|
+
<p>
|
920
|
+
Makes assumptions for required fields that are not yet defined. Assumptions
|
921
|
+
can be overridden by assigning values
|
922
|
+
</p>
|
923
|
+
<dl>
|
924
|
+
<dt><a href="BingLocator.html#country_region">country_region</a></dt><dd><p>
|
925
|
+
Country or region, i.e. ‘US’
|
926
|
+
</p>
|
927
|
+
</dd>
|
928
|
+
<dt><a href="BingLocator.html#admin_district">admin_district</a></dt><dd><p>
|
929
|
+
Administrative District. In the US this is State i.e. ‘PA’
|
930
|
+
</p>
|
931
|
+
</dd>
|
932
|
+
<dt><a href="BingLocator.html#postal_code">postal_code</a></dt><dd><p>
|
933
|
+
Postal code or zip code. i.e. ‘15213’
|
934
|
+
</p>
|
935
|
+
</dd>
|
936
|
+
<dt>locality</dt><dd><p>
|
937
|
+
Locality The locality, such as the city or neighborhood, that corresponds
|
938
|
+
to an address i.e. ‘Pittsburgh’
|
939
|
+
</p>
|
940
|
+
</dd>
|
941
|
+
<dt><a href="BingLocator.html#address_line">address_line</a></dt><dd><p>
|
942
|
+
The official street line of an address relative to the area i.e. ‘430
|
943
|
+
Atwood St’
|
944
|
+
</p>
|
945
|
+
</dd>
|
946
|
+
<dt><a href="BingLocator.html#obj_type">obj_type</a></dt><dd><p>
|
947
|
+
Type of object returned by REST request
|
948
|
+
</p>
|
949
|
+
</dd>
|
950
|
+
<dt><a href="BingLocator.html#map_type">map_type</a></dt><dd><p>
|
951
|
+
Imagery to use for maps
|
952
|
+
</p>
|
953
|
+
</dd>
|
954
|
+
<dt><a href="BingLocator.html#zoom_level">zoom_level</a></dt><dd><p>
|
955
|
+
Zoom level of a map
|
956
|
+
</p>
|
957
|
+
</dd>
|
958
|
+
</dl>
|
959
|
+
|
960
|
+
|
961
|
+
|
962
|
+
<div class="method-source-code"
|
963
|
+
id="set-defaults-source">
|
964
|
+
<pre>
|
965
|
+
<span class="ruby-comment cmt"># File lib/location.rb, line 46</span>
|
966
|
+
46: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_defaults</span>
|
967
|
+
47: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">country_region</span> = <span class="ruby-value str">'-'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">country_region</span>
|
968
|
+
48: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">admin_district</span> = <span class="ruby-value str">'-'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">admin_district</span>
|
969
|
+
49: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">postal_code</span> = <span class="ruby-value str">'-'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">postal_code</span>
|
970
|
+
50: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">locality</span> = <span class="ruby-value str">'-'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">locality</span>
|
971
|
+
51: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">address_line</span> = <span class="ruby-value str">'-'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">address_line</span>
|
972
|
+
52: <span class="ruby-comment cmt"># Allowed values - json, xml</span>
|
973
|
+
53: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">obj_type</span> = <span class="ruby-value str">'json'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">obj_type</span>
|
974
|
+
54: <span class="ruby-comment cmt"># Allowed values - Aerial, AerialWithLabels, Road</span>
|
975
|
+
55: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">map_type</span> = <span class="ruby-value str">'Road'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">map_type</span>
|
976
|
+
56: <span class="ruby-comment cmt"># Allowed values - An integer between 1 and 22 </span>
|
977
|
+
57: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">zoom_level</span> = <span class="ruby-value str">'11'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">zoom_level</span>
|
978
|
+
58: <span class="ruby-keyword kw">end</span></pre>
|
979
|
+
</div>
|
980
|
+
|
981
|
+
</div>
|
982
|
+
|
983
|
+
|
984
|
+
|
985
|
+
|
986
|
+
</div>
|
987
|
+
|
988
|
+
|
989
|
+
</div>
|
990
|
+
|
991
|
+
|
992
|
+
</div>
|
993
|
+
|
994
|
+
|
995
|
+
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
996
|
+
|
997
|
+
<p>Disabled; run with --debug to generate this.</p>
|
998
|
+
|
999
|
+
</div>
|
1000
|
+
|
1001
|
+
<div id="validator-badges">
|
1002
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
1003
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
1004
|
+
Rdoc Generator</a> 1.1.6</small>.</p>
|
1005
|
+
</div>
|
1006
|
+
|
1007
|
+
</body>
|
1008
|
+
</html>
|
1009
|
+
|