travel_time 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f92636f6a9ef3ed92abd0fba69609a827923c4c2f0f617b8b986921749282224
4
- data.tar.gz: aa5352c332805b59a3057d17cf983691f2866d72de765df7c65d4bf12dc9e91b
3
+ metadata.gz: ede2b3ca9b12f1d411227a72ecf78374b4c2e2440bd554750de51b5aa828c841
4
+ data.tar.gz: 37aec14a1fd0e9c09cd8d101dbbad7cc297b60abc27a596b980cd9884e64ebf7
5
5
  SHA512:
6
- metadata.gz: 45cd2bd0a182a170afb7569720bbe4acb9010e307b75dcdce56917b0ed4efe073934a98d24f838319e7e64b0c020df4ada6340b798fde13de5da5c1b5c15e9da
7
- data.tar.gz: c2ef831952436c81bd1519065c4217dde55fffce7f976a55564304b7b9fa395809b7d6a62893c7dc046d607e1b89fe108042a4c1afd21a4b02b8620604c66408
6
+ metadata.gz: 64831cb1d98876a2aab320c84dfc5b59ed27174c319810bac81800da4fd1a2a9cab0330737b393fd27fc7737cd44c0ccc8d14effbcea342bacbfdaf1f68b9da5
7
+ data.tar.gz: 923ac3cea840237a5e35eb8e4333cec5f84eea8b267851131a246b5f70841a7866205d236f53bbd7c084e10e97680054f275b6a8faf16eb9c73882a099407a01
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![GitHub Actions CI](https://github.com/traveltime-dev/traveltime-sdk-ruby/workflows/CI/badge.svg)](https://github.com/traveltime-dev/traveltime-sdk-ruby/actions?query=workflow%3ACI)
5
5
 
6
6
 
7
- This open-source library allows you to access [TravelTime API](http://docs.traveltime.com/overview/introduction)
7
+ This open-source library allows you to access [TravelTime API](https://docs.traveltime.com/overview/introduction)
8
8
  endpoints.
9
9
 
10
10
  ## Installation
@@ -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.
@@ -43,14 +43,15 @@ module TravelTime
43
43
  perform_request { connection.post('supported-locations', { locations: locations }) }
44
44
  end
45
45
 
46
- def geocoding(query:, within_country: nil, exclude: nil, limit: nil, force_postcode: nil)
46
+ def geocoding(query:, within_country: nil, exclude: nil, limit: nil, force_postcode: nil, bounds: nil)
47
47
  query = {
48
48
  query: query,
49
49
  'within.country': within_country,
50
50
  'exclude.location.types': exclude,
51
51
  limit: limit,
52
- 'force.add.postcode': force_postcode
53
- }.compact!
52
+ 'force.add.postcode': force_postcode,
53
+ bounds: bounds ? bounds.join(',') : nil
54
+ }.compact
54
55
  perform_request { connection.get('geocoding/search', query) }
55
56
  end
56
57
 
@@ -60,7 +61,7 @@ module TravelTime
60
61
  lng: lng,
61
62
  'within.country': within_country,
62
63
  'exclude.location.types': exclude
63
- }.compact!
64
+ }.compact
64
65
  perform_request { connection.get('geocoding/reverse', query) }
65
66
  end
66
67
 
@@ -70,7 +71,7 @@ module TravelTime
70
71
  arrival_searches: arrival_searches,
71
72
  unions: unions,
72
73
  intersections: intersections
73
- }.compact!
74
+ }.compact
74
75
  perform_request { connection.post('time-map', payload) }
75
76
  end
76
77
 
@@ -79,7 +80,7 @@ module TravelTime
79
80
  locations: locations,
80
81
  departure_searches: departure_searches,
81
82
  arrival_searches: arrival_searches
82
- }.compact!
83
+ }.compact
83
84
  perform_request { connection.post('time-filter', payload) }
84
85
  end
85
86
 
@@ -87,7 +88,7 @@ module TravelTime
87
88
  payload = {
88
89
  locations: locations,
89
90
  arrival_searches: arrival_searches
90
- }.compact!
91
+ }.compact
91
92
  perform_request { connection.post('time-filter/fast', payload) }
92
93
  end
93
94
 
@@ -95,7 +96,7 @@ module TravelTime
95
96
  payload = {
96
97
  departure_searches: departure_searches,
97
98
  arrival_searches: arrival_searches
98
- }.compact!
99
+ }.compact
99
100
  perform_request { connection.post('time-filter/postcodes', payload) }
100
101
  end
101
102
 
@@ -103,7 +104,7 @@ module TravelTime
103
104
  payload = {
104
105
  departure_searches: departure_searches,
105
106
  arrival_searches: arrival_searches
106
- }.compact!
107
+ }.compact
107
108
  perform_request { connection.post('time-filter/postcode-districts', payload) }
108
109
  end
109
110
 
@@ -111,7 +112,7 @@ module TravelTime
111
112
  payload = {
112
113
  departure_searches: departure_searches,
113
114
  arrival_searches: arrival_searches
114
- }.compact!
115
+ }.compact
115
116
  perform_request { connection.post('time-filter/postcode-sectors', payload) }
116
117
  end
117
118
 
@@ -120,7 +121,7 @@ module TravelTime
120
121
  locations: locations,
121
122
  departure_searches: departure_searches,
122
123
  arrival_searches: arrival_searches
123
- }.compact!
124
+ }.compact
124
125
  perform_request { connection.post('routes', payload) }
125
126
  end
126
127
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TravelTime
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.1'
5
5
  end
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.2.0
4
+ version: 0.3.1
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-05-03 00:00:00.000000000 Z
11
+ date: 2022-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable