travel_time 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/README.md +413 -2
- data/lib/travel_time/client.rb +9 -9
- data/lib/travel_time/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b3e81554adec31d0273e4a8800d9f31ee0b6bbd74277a8e0b61592629e813b5
|
4
|
+
data.tar.gz: 74d2300d335ba54c7191848fede142c37b001516bedd6a84da01d8b8fab82cf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e171245021dbb7c0ff92d601c61b7dd28e67972dc440f7f9d3accb0023c18d0d97e10227d9be269cf6290b02005a070cd9d2913c4b8a733b511d349138460b3a
|
7
|
+
data.tar.gz: 1ddde0b924c7dcb823230514942bab274b9654bfba612e1778ad7bf79634bc9ce7321d2ece7c410021ddd80957b1409e938c35d8dda963f8a0cde70895551ee8
|
data/README.md
CHANGED
@@ -70,6 +70,418 @@ departure_search = {
|
|
70
70
|
client.time_map(departure_searches: [departure_search])
|
71
71
|
```
|
72
72
|
|
73
|
+
|
74
|
+
### [Isochrones (Time Map)](https://traveltime.com/docs/api/reference/isochrones)
|
75
|
+
Given origin coordinates, find shapes of zones reachable within corresponding travel time.
|
76
|
+
Find unions/intersections between different searches.
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
require 'time'
|
80
|
+
|
81
|
+
departure_search = {
|
82
|
+
id: "public transport from Trafalgar Square",
|
83
|
+
coords: {
|
84
|
+
lat: 51.506756,
|
85
|
+
lng: -0.128050
|
86
|
+
},
|
87
|
+
transportation: { type: "public_transport" },
|
88
|
+
departure_time: Time.now.iso8601,
|
89
|
+
travel_time: 1800,
|
90
|
+
}
|
91
|
+
|
92
|
+
arrival_search = {
|
93
|
+
id: "public transport to Trafalgar Square",
|
94
|
+
coords: {
|
95
|
+
lat: 51.506756,
|
96
|
+
lng: -0.128050
|
97
|
+
},
|
98
|
+
transportation: { type: "public_transport" },
|
99
|
+
arrival_time: Time.now.iso8601,
|
100
|
+
travel_time: 1800,
|
101
|
+
range: { enabled: true, width: 3600 }
|
102
|
+
}
|
103
|
+
|
104
|
+
union = {
|
105
|
+
id: 'union of driving and public transport',
|
106
|
+
search_ids: ['public transport from Trafalgar Square', 'public transport to Trafalgar Square']
|
107
|
+
}
|
108
|
+
intersection = {
|
109
|
+
id: 'intersection of driving and public transport',
|
110
|
+
search_ids: ['public transport from Trafalgar Square', 'public transport to Trafalgar Square']
|
111
|
+
}
|
112
|
+
|
113
|
+
response = client.time_map(
|
114
|
+
departure_searches: [departure_search],
|
115
|
+
arrival_searches: [arrival_search],
|
116
|
+
unions: [union],
|
117
|
+
intersections: [intersection]
|
118
|
+
)
|
119
|
+
|
120
|
+
puts response.body
|
121
|
+
```
|
122
|
+
|
123
|
+
### [Distance Matrix (Time Filter)](https://traveltime.com/docs/api/reference/distance-matrix)
|
124
|
+
Given origin and destination points filter out points that cannot be reached within specified time limit.
|
125
|
+
Find out travel times, distances and costs between an origin and up to 2,000 destination points.
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
require 'time'
|
129
|
+
|
130
|
+
locations = [
|
131
|
+
{
|
132
|
+
id: 'London center',
|
133
|
+
coords: {
|
134
|
+
lat: 51.508930,
|
135
|
+
lng: -0.131387
|
136
|
+
}
|
137
|
+
},
|
138
|
+
{
|
139
|
+
id: 'Hyde Park',
|
140
|
+
coords: {
|
141
|
+
lat: 51.508824,
|
142
|
+
lng: -0.167093
|
143
|
+
}
|
144
|
+
},
|
145
|
+
{
|
146
|
+
id: 'ZSL London Zoo',
|
147
|
+
coords: {
|
148
|
+
lat: 51.536067,
|
149
|
+
lng: -0.153596
|
150
|
+
}
|
151
|
+
}
|
152
|
+
]
|
153
|
+
|
154
|
+
departure_search = {
|
155
|
+
id: 'forward search example',
|
156
|
+
departure_location_id: 'London center',
|
157
|
+
arrival_location_ids: ['Hyde Park', 'ZSL London Zoo'],
|
158
|
+
transportation: { type: 'bus' },
|
159
|
+
departure_time: Time.now.iso8601,
|
160
|
+
travel_time: 1800,
|
161
|
+
properties: ['travel_time'],
|
162
|
+
range: { enabled: true, max_results: 3, width: 600 }
|
163
|
+
}
|
164
|
+
|
165
|
+
arrival_search = {
|
166
|
+
id: 'backward search example',
|
167
|
+
departure_location_ids: ['Hyde Park', 'ZSL London Zoo'],
|
168
|
+
arrival_location_id: 'London center',
|
169
|
+
transportation: { type: 'public_transport' },
|
170
|
+
arrival_time: Time.now.iso8601,
|
171
|
+
travel_time: 1800,
|
172
|
+
properties: ['travel_time', 'distance', 'distance_breakdown', 'fares']
|
173
|
+
}
|
174
|
+
|
175
|
+
response = client.time_filter(
|
176
|
+
locations: locations,
|
177
|
+
departure_searches: [departure_search],
|
178
|
+
arrival_searches: [arrival_search]
|
179
|
+
)
|
180
|
+
|
181
|
+
puts response.body
|
182
|
+
```
|
183
|
+
|
184
|
+
### [Routes](https://traveltime.com/docs/api/reference/routes)
|
185
|
+
Returns routing information between source and destinations.
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
require 'time'
|
189
|
+
|
190
|
+
locations = [{
|
191
|
+
id: 'London center',
|
192
|
+
coords: {
|
193
|
+
lat: 51.508930,
|
194
|
+
lng: -0.131387
|
195
|
+
}
|
196
|
+
},
|
197
|
+
{
|
198
|
+
id: 'Hyde Park',
|
199
|
+
coords: {
|
200
|
+
lat: 51.508824,
|
201
|
+
lng: -0.167093
|
202
|
+
}
|
203
|
+
},
|
204
|
+
{
|
205
|
+
id: 'ZSL London Zoo',
|
206
|
+
coords: {
|
207
|
+
lat: 51.536067,
|
208
|
+
lng: -0.153596
|
209
|
+
}
|
210
|
+
}]
|
211
|
+
|
212
|
+
departure_search = {
|
213
|
+
id: 'forward search example',
|
214
|
+
departure_location_id: 'London center',
|
215
|
+
arrival_location_ids: ['Hyde Park', 'ZSL London Zoo'],
|
216
|
+
transportation: {
|
217
|
+
type: 'bus'
|
218
|
+
},
|
219
|
+
departure_time: Time.now.iso8601,
|
220
|
+
travel_time: 1800,
|
221
|
+
properties: ['travel_time'],
|
222
|
+
range: {
|
223
|
+
enabled: true,
|
224
|
+
max_results: 3,
|
225
|
+
width: 600
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
arrival_search = {
|
230
|
+
id: 'backward search example',
|
231
|
+
departure_location_ids: ['Hyde Park', 'ZSL London Zoo'],
|
232
|
+
arrival_location_id: 'London center',
|
233
|
+
transportation: {
|
234
|
+
type: 'public_transport'
|
235
|
+
},
|
236
|
+
arrival_time: Time.now.iso8601,
|
237
|
+
travel_time: 1800,
|
238
|
+
properties: ['travel_time', 'distance', 'fares', 'route']
|
239
|
+
}
|
240
|
+
|
241
|
+
response = client.routes(
|
242
|
+
locations: locations,
|
243
|
+
departure_searches: [departure_search],
|
244
|
+
arrival_searches: [arrival_search]
|
245
|
+
)
|
246
|
+
|
247
|
+
puts response.body
|
248
|
+
```
|
249
|
+
|
250
|
+
### [Time Filter (Fast)](https://traveltime.com/docs/api/reference/time-filter-fast)
|
251
|
+
A very fast version of time_filter().
|
252
|
+
However, the request parameters are much more limited.
|
253
|
+
Currently only supports UK and Ireland.
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
locations = [
|
257
|
+
{
|
258
|
+
id: 'London center',
|
259
|
+
coords: {
|
260
|
+
lat: 51.508930,
|
261
|
+
lng: -0.131387
|
262
|
+
}
|
263
|
+
},
|
264
|
+
{
|
265
|
+
id: 'Hyde Park',
|
266
|
+
coords: {
|
267
|
+
lat: 51.508824,
|
268
|
+
lng: -0.167093
|
269
|
+
}
|
270
|
+
},
|
271
|
+
{
|
272
|
+
id: 'ZSL London Zoo',
|
273
|
+
coords: {
|
274
|
+
lat: 51.536067,
|
275
|
+
lng: -0.153596
|
276
|
+
}
|
277
|
+
}
|
278
|
+
]
|
279
|
+
|
280
|
+
arrival_many_to_one = {
|
281
|
+
id: 'arrive-at many-to-one search example',
|
282
|
+
departure_location_ids: ['Hyde Park', 'ZSL London Zoo'],
|
283
|
+
arrival_location_id: 'London center',
|
284
|
+
transportation: { type: 'public_transport' },
|
285
|
+
arrival_time_period: 'weekday_morning',
|
286
|
+
travel_time: 1900,
|
287
|
+
properties: ['travel_time', 'fares']
|
288
|
+
}
|
289
|
+
|
290
|
+
arrival_one_to_many = {
|
291
|
+
id: 'arrive-at one-to-many search example',
|
292
|
+
arrival_location_ids: ['Hyde Park', 'ZSL London Zoo'],
|
293
|
+
departure_location_id: 'London center',
|
294
|
+
transportation: { type: 'public_transport' },
|
295
|
+
arrival_time_period: 'weekday_morning',
|
296
|
+
travel_time: 1900,
|
297
|
+
properties: ['travel_time', 'fares']
|
298
|
+
}
|
299
|
+
|
300
|
+
arrival_searches = {
|
301
|
+
many_to_one: [arrival_many_to_one],
|
302
|
+
one_to_many: [arrival_one_to_many]
|
303
|
+
}
|
304
|
+
|
305
|
+
response = client.time_filter_fast(
|
306
|
+
locations: locations,
|
307
|
+
arrival_searches: arrival_searches
|
308
|
+
)
|
309
|
+
|
310
|
+
puts response.body
|
311
|
+
```
|
312
|
+
|
313
|
+
### [Time Filter (Postcode Districts)](https://traveltime.com/docs/api/reference/postcode-district-filter)
|
314
|
+
Find districts that have a certain coverage from origin (or to destination) and get statistics about postcodes within such districts.
|
315
|
+
Currently only supports United Kingdom.
|
316
|
+
|
317
|
+
```ruby
|
318
|
+
require 'time'
|
319
|
+
|
320
|
+
departure_search = {
|
321
|
+
id: 'public transport from Trafalgar Square',
|
322
|
+
departure_time: Time.now.iso8601,
|
323
|
+
travel_time: 1800,
|
324
|
+
coords: { lat: 51.507609, lng: -0.128315 },
|
325
|
+
transportation: { type: 'public_transport' },
|
326
|
+
properties: ['coverage', 'travel_time_reachable', 'travel_time_all'],
|
327
|
+
reachable_postcodes_threshold: 0.1
|
328
|
+
}
|
329
|
+
|
330
|
+
arrival_search = {
|
331
|
+
id: 'public transport to Trafalgar Square',
|
332
|
+
arrival_time: Time.now.iso8601,
|
333
|
+
travel_time: 1800,
|
334
|
+
coords: { lat: 51.507609, lng: -0.128315 },
|
335
|
+
transportation: { type: 'public_transport' },
|
336
|
+
properties: ['coverage', 'travel_time_reachable', 'travel_time_all'],
|
337
|
+
reachable_postcodes_threshold: 0.1
|
338
|
+
}
|
339
|
+
|
340
|
+
response = client.time_filter_postcode_districts(
|
341
|
+
departure_searches: [departure_search],
|
342
|
+
arrival_searches: [arrival_search]
|
343
|
+
)
|
344
|
+
|
345
|
+
puts response.body
|
346
|
+
```
|
347
|
+
|
348
|
+
### [Time Filter (Postcode Sectors)](https://traveltime.com/docs/api/reference/postcode-sector-filter)
|
349
|
+
Find sectors that have a certain coverage from origin (or to destination) and get statistics about postcodes within such sectors.
|
350
|
+
Currently only supports United Kingdom.
|
351
|
+
|
352
|
+
```ruby
|
353
|
+
require 'time'
|
354
|
+
|
355
|
+
departure_search = {
|
356
|
+
id: 'public transport from Trafalgar Square',
|
357
|
+
departure_time: Time.now.iso8601,
|
358
|
+
travel_time: 1800,
|
359
|
+
coords: { lat: 51.507609, lng: -0.128315 },
|
360
|
+
transportation: { type: 'public_transport' },
|
361
|
+
properties: ['coverage', 'travel_time_reachable', 'travel_time_all'],
|
362
|
+
reachable_postcodes_threshold: 0.1
|
363
|
+
}
|
364
|
+
|
365
|
+
arrival_search = {
|
366
|
+
id: 'public transport to Trafalgar Square',
|
367
|
+
arrival_time: Time.now.iso8601,
|
368
|
+
travel_time: 1800,
|
369
|
+
coords: { lat: 51.507609, lng: -0.128315 },
|
370
|
+
transportation: { type: 'public_transport' },
|
371
|
+
properties: ['coverage', 'travel_time_reachable', 'travel_time_all'],
|
372
|
+
reachable_postcodes_threshold: 0.1
|
373
|
+
}
|
374
|
+
|
375
|
+
response = client.time_filter_postcode_sectors(
|
376
|
+
departure_searches: [departure_search],
|
377
|
+
arrival_searches: [arrival_search]
|
378
|
+
)
|
379
|
+
|
380
|
+
puts response.body
|
381
|
+
```
|
382
|
+
|
383
|
+
### [Time Filter (Postcodes)](https://traveltime.com/docs/api/reference/postcode-search)
|
384
|
+
Find reachable postcodes from origin (or to destination) and get statistics about such postcodes.
|
385
|
+
Currently only supports United Kingdom.
|
386
|
+
|
387
|
+
```ruby
|
388
|
+
require 'time'
|
389
|
+
|
390
|
+
TravelTime.configure do |config|
|
391
|
+
config.application_id = 'YOUR_API_ID'
|
392
|
+
config.api_key = 'YOUR_API_KEY'
|
393
|
+
end
|
394
|
+
|
395
|
+
client = TravelTime::Client.new
|
396
|
+
|
397
|
+
departure_search = {
|
398
|
+
id: 'public transport from Trafalgar Square',
|
399
|
+
departure_time: Time.now.iso8601,
|
400
|
+
travel_time: 1800,
|
401
|
+
coords: { lat: 51.507609, lng: -0.128315 },
|
402
|
+
transportation: { type: 'public_transport' },
|
403
|
+
properties: ['travel_time', 'distance']
|
404
|
+
}
|
405
|
+
|
406
|
+
arrival_search = {
|
407
|
+
id: 'public transport to Trafalgar Square',
|
408
|
+
arrival_time: Time.now.iso8601,
|
409
|
+
travel_time: 1800,
|
410
|
+
coords: { lat: 51.507609, lng: -0.128315 },
|
411
|
+
transportation: { type: 'public_transport' },
|
412
|
+
properties: ['travel_time', 'distance']
|
413
|
+
}
|
414
|
+
|
415
|
+
response = client.time_filter_postcodes(
|
416
|
+
departure_searches: [departure_search],
|
417
|
+
arrival_searches: [arrival_search]
|
418
|
+
)
|
419
|
+
|
420
|
+
puts response.body
|
421
|
+
```
|
422
|
+
|
423
|
+
### [Geocoding (Search)](https://traveltime.com/docs/api/reference/geocoding-search)
|
424
|
+
Match a query string to geographic coordinates.
|
425
|
+
|
426
|
+
```ruby
|
427
|
+
response = client.geocoding(query: 'London', within_country: 'GB')
|
428
|
+
puts response.body
|
429
|
+
```
|
430
|
+
|
431
|
+
### [Reverse Geocoding](https://traveltime.com/docs/api/reference/geocoding-reverse)
|
432
|
+
Attempt to match a latitude, longitude pair to an address.
|
433
|
+
|
434
|
+
```ruby
|
435
|
+
response = client.reverse_geocoding(lat: 51.506756, lng: -0.128050)
|
436
|
+
puts response.body
|
437
|
+
```
|
438
|
+
|
439
|
+
### [Map Info](https://traveltime.com/docs/api/reference/map-info)
|
440
|
+
Get information about currently supported countries.
|
441
|
+
|
442
|
+
```ruby
|
443
|
+
response = client.map_info
|
444
|
+
puts response.body
|
445
|
+
```
|
446
|
+
|
447
|
+
### [Supported Locations](https://traveltime.com/docs/api/reference/supported-locations)
|
448
|
+
Find out what points are supported by the api.
|
449
|
+
|
450
|
+
```ruby
|
451
|
+
locations = [{
|
452
|
+
id: "London",
|
453
|
+
coords: {
|
454
|
+
lat: 51.506756,
|
455
|
+
lng: -0.128050
|
456
|
+
}
|
457
|
+
},
|
458
|
+
{
|
459
|
+
id: "Bangkok",
|
460
|
+
coords: {
|
461
|
+
lat: 13.761866,
|
462
|
+
lng: 100.544818
|
463
|
+
}
|
464
|
+
},
|
465
|
+
{
|
466
|
+
id: "Lisbon",
|
467
|
+
coords: {
|
468
|
+
lat: 38.721869,
|
469
|
+
lng: -9.138549
|
470
|
+
}
|
471
|
+
},
|
472
|
+
{
|
473
|
+
id: "Kaunas",
|
474
|
+
coords: {
|
475
|
+
lat: 54.900008,
|
476
|
+
lng: 23.957734
|
477
|
+
}
|
478
|
+
}]
|
479
|
+
|
480
|
+
response = client.supported_locations(locations: locations)
|
481
|
+
|
482
|
+
puts response.body
|
483
|
+
```
|
484
|
+
|
73
485
|
## Development
|
74
486
|
|
75
487
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can
|
@@ -82,5 +494,4 @@ a GitHub Action which will push the `.gem` file to [rubygems.org](https://rubyge
|
|
82
494
|
|
83
495
|
## Contributing
|
84
496
|
|
85
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/traveltime-dev/travel_time.
|
86
|
-
|
497
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/traveltime-dev/travel_time.
|
data/lib/travel_time/client.rb
CHANGED
@@ -50,7 +50,7 @@ module TravelTime
|
|
50
50
|
'exclude.location.types': exclude,
|
51
51
|
limit: limit,
|
52
52
|
'force.add.postcode': force_postcode
|
53
|
-
}.compact
|
53
|
+
}.compact
|
54
54
|
perform_request { connection.get('geocoding/search', query) }
|
55
55
|
end
|
56
56
|
|
@@ -60,7 +60,7 @@ module TravelTime
|
|
60
60
|
lng: lng,
|
61
61
|
'within.country': within_country,
|
62
62
|
'exclude.location.types': exclude
|
63
|
-
}.compact
|
63
|
+
}.compact
|
64
64
|
perform_request { connection.get('geocoding/reverse', query) }
|
65
65
|
end
|
66
66
|
|
@@ -70,7 +70,7 @@ module TravelTime
|
|
70
70
|
arrival_searches: arrival_searches,
|
71
71
|
unions: unions,
|
72
72
|
intersections: intersections
|
73
|
-
}.compact
|
73
|
+
}.compact
|
74
74
|
perform_request { connection.post('time-map', payload) }
|
75
75
|
end
|
76
76
|
|
@@ -79,7 +79,7 @@ module TravelTime
|
|
79
79
|
locations: locations,
|
80
80
|
departure_searches: departure_searches,
|
81
81
|
arrival_searches: arrival_searches
|
82
|
-
}.compact
|
82
|
+
}.compact
|
83
83
|
perform_request { connection.post('time-filter', payload) }
|
84
84
|
end
|
85
85
|
|
@@ -87,7 +87,7 @@ module TravelTime
|
|
87
87
|
payload = {
|
88
88
|
locations: locations,
|
89
89
|
arrival_searches: arrival_searches
|
90
|
-
}.compact
|
90
|
+
}.compact
|
91
91
|
perform_request { connection.post('time-filter/fast', payload) }
|
92
92
|
end
|
93
93
|
|
@@ -95,7 +95,7 @@ module TravelTime
|
|
95
95
|
payload = {
|
96
96
|
departure_searches: departure_searches,
|
97
97
|
arrival_searches: arrival_searches
|
98
|
-
}.compact
|
98
|
+
}.compact
|
99
99
|
perform_request { connection.post('time-filter/postcodes', payload) }
|
100
100
|
end
|
101
101
|
|
@@ -103,7 +103,7 @@ module TravelTime
|
|
103
103
|
payload = {
|
104
104
|
departure_searches: departure_searches,
|
105
105
|
arrival_searches: arrival_searches
|
106
|
-
}.compact
|
106
|
+
}.compact
|
107
107
|
perform_request { connection.post('time-filter/postcode-districts', payload) }
|
108
108
|
end
|
109
109
|
|
@@ -111,7 +111,7 @@ module TravelTime
|
|
111
111
|
payload = {
|
112
112
|
departure_searches: departure_searches,
|
113
113
|
arrival_searches: arrival_searches
|
114
|
-
}.compact
|
114
|
+
}.compact
|
115
115
|
perform_request { connection.post('time-filter/postcode-sectors', payload) }
|
116
116
|
end
|
117
117
|
|
@@ -120,7 +120,7 @@ module TravelTime
|
|
120
120
|
locations: locations,
|
121
121
|
departure_searches: departure_searches,
|
122
122
|
arrival_searches: arrival_searches
|
123
|
-
}.compact
|
123
|
+
}.compact
|
124
124
|
perform_request { connection.post('routes', payload) }
|
125
125
|
end
|
126
126
|
end
|
data/lib/travel_time/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travel_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TravelTime Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|