travel_time 0.9.1 → 0.10.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 +56 -2
- data/lib/GeohashFastRequest_pb.rb +49 -0
- data/lib/GeohashFastResponse_pb.rb +45 -0
- data/lib/H3FastRequest_pb.rb +49 -0
- data/lib/H3FastResponse_pb.rb +45 -0
- data/lib/TimeFilterFastResponse_pb.rb +1 -1
- data/lib/travel_time/client.rb +88 -15
- data/lib/travel_time/middleware/authentication.rb +7 -2
- data/lib/travel_time/middleware/proto.rb +7 -2
- data/lib/travel_time/proto/source/GeohashFastRequest.proto +32 -0
- data/lib/travel_time/proto/source/GeohashFastResponse.proto +14 -0
- data/lib/travel_time/proto/source/H3FastRequest.proto +32 -0
- data/lib/travel_time/proto/source/H3FastResponse.proto +21 -0
- data/lib/travel_time/proto/source/TimeFilterFastResponse.proto +50 -0
- data/lib/travel_time/response.rb +7 -6
- data/lib/travel_time/version.rb +1 -1
- data/lib/travel_time.rb +6 -5
- data/lib/utils.rb +51 -0
- metadata +10 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0aee6acebdce6aff8b6148cec9f40462ad286ab61d60920cf084744bd1a9a465
|
|
4
|
+
data.tar.gz: e2669e644f779a1489e301d697ad2db403ffe44191c52d0a8b6a1c2e6a4d2543
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7cd1b1bfa1d81d733f8f09bd35995ae9e8f9ea7ec876ab8c829a5cf54842a3acd8d9ebb5952227af54543a06142243551f0c836bd58f05ad7902e0fa10164756
|
|
7
|
+
data.tar.gz: 18245fd2e496b743294370d771411997f1d6bbebec1b06f163bd0256081a0cb3b192eb7873c37b6b18c87881b4e0aad29eaabfb519ff0403bfaa48dc84bbd5fe
|
data/README.md
CHANGED
|
@@ -42,6 +42,17 @@ After that, you can instantiate a client to initiate the API connection:
|
|
|
42
42
|
client = TravelTime::Client.new
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
A client can also be configured individually, for example to use separate credentials for
|
|
46
|
+
batch operations. Settings not overridden in the block are inherited from the global
|
|
47
|
+
configuration:
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
batch_client = TravelTime::Client.new.configure do |config|
|
|
51
|
+
config.application_id = 'YOUR_BATCH_APP_ID'
|
|
52
|
+
config.api_key = 'YOUR_BATCH_APP_KEY'
|
|
53
|
+
end
|
|
54
|
+
```
|
|
55
|
+
|
|
45
56
|
You can then use the client to call API endpoints:
|
|
46
57
|
|
|
47
58
|
```ruby
|
|
@@ -77,7 +88,7 @@ client.time_map(departure_searches: [departure_search])
|
|
|
77
88
|
You may specify an optional rate limit when initializing your client. The `rate_limit` parameter sets a cap on the number of requests that can be made to the API in 60 seconds. Requests are balanced at equal intervals.
|
|
78
89
|
|
|
79
90
|
```ruby
|
|
80
|
-
client = TravelTime::Client.new(rate_limit =
|
|
91
|
+
client = TravelTime::Client.new(rate_limit = 120)
|
|
81
92
|
```
|
|
82
93
|
|
|
83
94
|
### [Isochrones (Time Map)](https://docs.traveltime.com/api/reference/isochrones)
|
|
@@ -379,11 +390,12 @@ A fast version of time filter communicating using [protocol buffers](https://git
|
|
|
379
390
|
|
|
380
391
|
Body attributes:
|
|
381
392
|
* origin: Origin point.
|
|
382
|
-
* destinations: Destination points.
|
|
393
|
+
* destinations: Destination points. There is no fixed limit on the number of destinations; a request can be up to 10MB (around 2 million locations).
|
|
383
394
|
* country: Return the results that are within the specified country.
|
|
384
395
|
* transport: Transportation type (string) or Transportation object.
|
|
385
396
|
* traveltime: Time limit.
|
|
386
397
|
* with_distance: (Optional) If true, returns distances in addition to travel times.
|
|
398
|
+
* with_fares: (Optional) If true, returns monthly public transport fares in addition to travel times.
|
|
387
399
|
* request_type: (Optional) Specifies the request type - either `TravelTime::ProtoUtils::ONE_TO_MANY` (default) or `TravelTime::ProtoUtils::MANY_TO_ONE`.
|
|
388
400
|
|
|
389
401
|
#### One-to-Many (default)
|
|
@@ -487,6 +499,48 @@ response = client.time_filter_fast_proto(
|
|
|
487
499
|
* `parking_time` - constant penalty to apply to simulate the difficulty of finding a parking spot.
|
|
488
500
|
Optional. Must be non-negative. Cannot be greater than the global travel time limit.
|
|
489
501
|
|
|
502
|
+
### [Geohash Fast (Proto)](https://docs.traveltime.com/api/start/geohash-proto)
|
|
503
|
+
|
|
504
|
+
A fast version of geohash communicating using [protocol buffers](https://github.com/protocolbuffers/protobuf).
|
|
505
|
+
|
|
506
|
+
Body attributes:
|
|
507
|
+
* country: Return the results that are within the specified country.
|
|
508
|
+
* origin: Location of the search (departure point, or arrival point with `request_type: :many_to_one`).
|
|
509
|
+
* transport: Transportation type, e.g. `{ type: 'driving+ferry' }`.
|
|
510
|
+
* traveltime: Time limit.
|
|
511
|
+
* resolution: Geohash resolution (cell size).
|
|
512
|
+
* properties: (Optional) Travel time statistics to return — any of `:min`, `:max`, `:mean`.
|
|
513
|
+
* remove_water_bodies: (Optional) When true, returned cells will not cover large nearby water bodies. Only sent when set.
|
|
514
|
+
* request_type: (Optional) `:one_to_many` (default) or `:many_to_one`.
|
|
515
|
+
|
|
516
|
+
```ruby
|
|
517
|
+
response = client.geohash_fast_proto(
|
|
518
|
+
country: :uk,
|
|
519
|
+
origin: { lat: 51.508930, lng: -0.131387 },
|
|
520
|
+
transport: { type: 'driving+ferry' },
|
|
521
|
+
traveltime: 1800,
|
|
522
|
+
resolution: 6,
|
|
523
|
+
properties: [:min]
|
|
524
|
+
)
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### [H3 Fast (Proto)](https://docs.traveltime.com/api/start/h3-proto)
|
|
528
|
+
|
|
529
|
+
A fast version of H3 communicating using [protocol buffers](https://github.com/protocolbuffers/protobuf).
|
|
530
|
+
Takes the same attributes as Geohash Fast (Proto) with an H3 `resolution`; cell ids are returned in their
|
|
531
|
+
15-character hexadecimal form.
|
|
532
|
+
|
|
533
|
+
```ruby
|
|
534
|
+
response = client.h3_fast_proto(
|
|
535
|
+
country: :uk,
|
|
536
|
+
origin: { lat: 51.508930, lng: -0.131387 },
|
|
537
|
+
transport: { type: 'driving+ferry' },
|
|
538
|
+
traveltime: 1800,
|
|
539
|
+
resolution: 7,
|
|
540
|
+
properties: [:min]
|
|
541
|
+
)
|
|
542
|
+
```
|
|
543
|
+
|
|
490
544
|
### [Routes](https://docs.traveltime.com/api/reference/routes)
|
|
491
545
|
Returns routing information between source and destinations.
|
|
492
546
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: GeohashFastRequest.proto
|
|
4
|
+
|
|
5
|
+
require 'google/protobuf'
|
|
6
|
+
|
|
7
|
+
require 'RequestsCommon_pb'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
descriptor_data = "\n\x18GeohashFastRequest.proto\x12)com.igeolise.traveltime.rabbitmq.requests\x1a\x14RequestsCommon.proto\"\xb8\x08\n\x12GeohashFastRequest\x12\x61\n\x10oneToManyRequest\x18\x01 \x01(\x0b\x32G.com.igeolise.traveltime.rabbitmq.requests.GeohashFastRequest.OneToMany\x12\x61\n\x10manyToOneRequest\x18\x02 \x01(\x0b\x32G.com.igeolise.traveltime.rabbitmq.requests.GeohashFastRequest.ManyToOne\x1a\xad\x03\n\tOneToMany\x12L\n\x11\x64\x65partureLocation\x18\x01 \x01(\x0b\x32\x31.com.igeolise.traveltime.rabbitmq.requests.Coords\x12Q\n\x0etransportation\x18\x02 \x01(\x0b\x32\x39.com.igeolise.traveltime.rabbitmq.requests.Transportation\x12P\n\x11\x61rrivalTimePeriod\x18\x03 \x01(\x0e\x32\x35.com.igeolise.traveltime.rabbitmq.requests.TimePeriod\x12\x12\n\ntravelTime\x18\x04 \x01(\x11\x12\x12\n\nresolution\x18\x05 \x01(\r\x12O\n\nproperties\x18\x06 \x03(\x0e\x32;.com.igeolise.traveltime.rabbitmq.requests.CellPropertyType\x12\x1e\n\x11removeWaterBodies\x18\x07 \x01(\x08H\x00\x88\x01\x01\x42\x14\n\x12_removeWaterBodies\x1a\xab\x03\n\tManyToOne\x12J\n\x0f\x61rrivalLocation\x18\x01 \x01(\x0b\x32\x31.com.igeolise.traveltime.rabbitmq.requests.Coords\x12Q\n\x0etransportation\x18\x02 \x01(\x0b\x32\x39.com.igeolise.traveltime.rabbitmq.requests.Transportation\x12P\n\x11\x61rrivalTimePeriod\x18\x03 \x01(\x0e\x32\x35.com.igeolise.traveltime.rabbitmq.requests.TimePeriod\x12\x12\n\ntravelTime\x18\x04 \x01(\x11\x12\x12\n\nresolution\x18\x05 \x01(\r\x12O\n\nproperties\x18\x06 \x03(\x0e\x32;.com.igeolise.traveltime.rabbitmq.requests.CellPropertyType\x12\x1e\n\x11removeWaterBodies\x18\x07 \x01(\x08H\x00\x88\x01\x01\x42\x14\n\x12_removeWaterBodiesb\x06proto3"
|
|
11
|
+
|
|
12
|
+
pool = Google::Protobuf::DescriptorPool.generated_pool
|
|
13
|
+
|
|
14
|
+
begin
|
|
15
|
+
pool.add_serialized_file(descriptor_data)
|
|
16
|
+
rescue TypeError
|
|
17
|
+
# Compatibility code: will be removed in the next major version.
|
|
18
|
+
require 'google/protobuf/descriptor_pb'
|
|
19
|
+
parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
|
|
20
|
+
parsed.clear_dependency
|
|
21
|
+
serialized = parsed.class.encode(parsed)
|
|
22
|
+
file = pool.add_serialized_file(serialized)
|
|
23
|
+
warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
|
|
24
|
+
imports = [
|
|
25
|
+
["com.igeolise.traveltime.rabbitmq.requests.Coords", "RequestsCommon.proto"],
|
|
26
|
+
]
|
|
27
|
+
imports.each do |type_name, expected_filename|
|
|
28
|
+
import_file = pool.lookup(type_name).file_descriptor
|
|
29
|
+
if import_file.name != expected_filename
|
|
30
|
+
warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
warn "Each proto file must use a consistent fully-qualified name."
|
|
34
|
+
warn "This will become an error in the next major version."
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
module Com
|
|
38
|
+
module Igeolise
|
|
39
|
+
module Traveltime
|
|
40
|
+
module Rabbitmq
|
|
41
|
+
module Requests
|
|
42
|
+
GeohashFastRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.GeohashFastRequest").msgclass
|
|
43
|
+
GeohashFastRequest::OneToMany = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.GeohashFastRequest.OneToMany").msgclass
|
|
44
|
+
GeohashFastRequest::ManyToOne = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.GeohashFastRequest.ManyToOne").msgclass
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: GeohashFastResponse.proto
|
|
4
|
+
|
|
5
|
+
require 'google/protobuf'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
descriptor_data = "\n\x19GeohashFastResponse.proto\x12*com.igeolise.traveltime.rabbitmq.responses\"\xca\x01\n\x13GeohashFastResponse\x12T\n\x05\x63\x65lls\x18\x01 \x01(\x0b\x32\x45.com.igeolise.traveltime.rabbitmq.responses.GeohashFastResponse.Cells\x1a]\n\x05\x43\x65lls\x12\x0b\n\x03ids\x18\x01 \x03(\t\x12\x16\n\x0eminTravelTimes\x18\x02 \x03(\x11\x12\x16\n\x0emaxTravelTimes\x18\x03 \x03(\x11\x12\x17\n\x0fmeanTravelTimes\x18\x04 \x03(\x11\x62\x06proto3"
|
|
9
|
+
|
|
10
|
+
pool = Google::Protobuf::DescriptorPool.generated_pool
|
|
11
|
+
|
|
12
|
+
begin
|
|
13
|
+
pool.add_serialized_file(descriptor_data)
|
|
14
|
+
rescue TypeError
|
|
15
|
+
# Compatibility code: will be removed in the next major version.
|
|
16
|
+
require 'google/protobuf/descriptor_pb'
|
|
17
|
+
parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
|
|
18
|
+
parsed.clear_dependency
|
|
19
|
+
serialized = parsed.class.encode(parsed)
|
|
20
|
+
file = pool.add_serialized_file(serialized)
|
|
21
|
+
warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
|
|
22
|
+
imports = [
|
|
23
|
+
]
|
|
24
|
+
imports.each do |type_name, expected_filename|
|
|
25
|
+
import_file = pool.lookup(type_name).file_descriptor
|
|
26
|
+
if import_file.name != expected_filename
|
|
27
|
+
warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
warn "Each proto file must use a consistent fully-qualified name."
|
|
31
|
+
warn "This will become an error in the next major version."
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
module Com
|
|
35
|
+
module Igeolise
|
|
36
|
+
module Traveltime
|
|
37
|
+
module Rabbitmq
|
|
38
|
+
module Responses
|
|
39
|
+
GeohashFastResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.responses.GeohashFastResponse").msgclass
|
|
40
|
+
GeohashFastResponse::Cells = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.responses.GeohashFastResponse.Cells").msgclass
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: H3FastRequest.proto
|
|
4
|
+
|
|
5
|
+
require 'google/protobuf'
|
|
6
|
+
|
|
7
|
+
require 'RequestsCommon_pb'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
descriptor_data = "\n\x13H3FastRequest.proto\x12)com.igeolise.traveltime.rabbitmq.requests\x1a\x14RequestsCommon.proto\"\xa9\x08\n\rH3FastRequest\x12\\\n\x10oneToManyRequest\x18\x01 \x01(\x0b\x32\x42.com.igeolise.traveltime.rabbitmq.requests.H3FastRequest.OneToMany\x12\\\n\x10manyToOneRequest\x18\x02 \x01(\x0b\x32\x42.com.igeolise.traveltime.rabbitmq.requests.H3FastRequest.ManyToOne\x1a\xad\x03\n\tOneToMany\x12L\n\x11\x64\x65partureLocation\x18\x01 \x01(\x0b\x32\x31.com.igeolise.traveltime.rabbitmq.requests.Coords\x12Q\n\x0etransportation\x18\x02 \x01(\x0b\x32\x39.com.igeolise.traveltime.rabbitmq.requests.Transportation\x12P\n\x11\x61rrivalTimePeriod\x18\x03 \x01(\x0e\x32\x35.com.igeolise.traveltime.rabbitmq.requests.TimePeriod\x12\x12\n\ntravelTime\x18\x04 \x01(\x11\x12\x12\n\nresolution\x18\x05 \x01(\r\x12O\n\nproperties\x18\x06 \x03(\x0e\x32;.com.igeolise.traveltime.rabbitmq.requests.CellPropertyType\x12\x1e\n\x11removeWaterBodies\x18\x07 \x01(\x08H\x00\x88\x01\x01\x42\x14\n\x12_removeWaterBodies\x1a\xab\x03\n\tManyToOne\x12J\n\x0f\x61rrivalLocation\x18\x01 \x01(\x0b\x32\x31.com.igeolise.traveltime.rabbitmq.requests.Coords\x12Q\n\x0etransportation\x18\x02 \x01(\x0b\x32\x39.com.igeolise.traveltime.rabbitmq.requests.Transportation\x12P\n\x11\x61rrivalTimePeriod\x18\x03 \x01(\x0e\x32\x35.com.igeolise.traveltime.rabbitmq.requests.TimePeriod\x12\x12\n\ntravelTime\x18\x04 \x01(\x11\x12\x12\n\nresolution\x18\x05 \x01(\r\x12O\n\nproperties\x18\x06 \x03(\x0e\x32;.com.igeolise.traveltime.rabbitmq.requests.CellPropertyType\x12\x1e\n\x11removeWaterBodies\x18\x07 \x01(\x08H\x00\x88\x01\x01\x42\x14\n\x12_removeWaterBodiesb\x06proto3"
|
|
11
|
+
|
|
12
|
+
pool = Google::Protobuf::DescriptorPool.generated_pool
|
|
13
|
+
|
|
14
|
+
begin
|
|
15
|
+
pool.add_serialized_file(descriptor_data)
|
|
16
|
+
rescue TypeError
|
|
17
|
+
# Compatibility code: will be removed in the next major version.
|
|
18
|
+
require 'google/protobuf/descriptor_pb'
|
|
19
|
+
parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
|
|
20
|
+
parsed.clear_dependency
|
|
21
|
+
serialized = parsed.class.encode(parsed)
|
|
22
|
+
file = pool.add_serialized_file(serialized)
|
|
23
|
+
warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
|
|
24
|
+
imports = [
|
|
25
|
+
["com.igeolise.traveltime.rabbitmq.requests.Coords", "RequestsCommon.proto"],
|
|
26
|
+
]
|
|
27
|
+
imports.each do |type_name, expected_filename|
|
|
28
|
+
import_file = pool.lookup(type_name).file_descriptor
|
|
29
|
+
if import_file.name != expected_filename
|
|
30
|
+
warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
warn "Each proto file must use a consistent fully-qualified name."
|
|
34
|
+
warn "This will become an error in the next major version."
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
module Com
|
|
38
|
+
module Igeolise
|
|
39
|
+
module Traveltime
|
|
40
|
+
module Rabbitmq
|
|
41
|
+
module Requests
|
|
42
|
+
H3FastRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.H3FastRequest").msgclass
|
|
43
|
+
H3FastRequest::OneToMany = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.H3FastRequest.OneToMany").msgclass
|
|
44
|
+
H3FastRequest::ManyToOne = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.requests.H3FastRequest.ManyToOne").msgclass
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: H3FastResponse.proto
|
|
4
|
+
|
|
5
|
+
require 'google/protobuf'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
descriptor_data = "\n\x14H3FastResponse.proto\x12*com.igeolise.traveltime.rabbitmq.responses\"\xc0\x01\n\x0eH3FastResponse\x12O\n\x05\x63\x65lls\x18\x01 \x01(\x0b\x32@.com.igeolise.traveltime.rabbitmq.responses.H3FastResponse.Cells\x1a]\n\x05\x43\x65lls\x12\x0b\n\x03ids\x18\x01 \x03(\x06\x12\x16\n\x0eminTravelTimes\x18\x02 \x03(\x11\x12\x16\n\x0emaxTravelTimes\x18\x03 \x03(\x11\x12\x17\n\x0fmeanTravelTimes\x18\x04 \x03(\x11\x62\x06proto3"
|
|
9
|
+
|
|
10
|
+
pool = Google::Protobuf::DescriptorPool.generated_pool
|
|
11
|
+
|
|
12
|
+
begin
|
|
13
|
+
pool.add_serialized_file(descriptor_data)
|
|
14
|
+
rescue TypeError
|
|
15
|
+
# Compatibility code: will be removed in the next major version.
|
|
16
|
+
require 'google/protobuf/descriptor_pb'
|
|
17
|
+
parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
|
|
18
|
+
parsed.clear_dependency
|
|
19
|
+
serialized = parsed.class.encode(parsed)
|
|
20
|
+
file = pool.add_serialized_file(serialized)
|
|
21
|
+
warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
|
|
22
|
+
imports = [
|
|
23
|
+
]
|
|
24
|
+
imports.each do |type_name, expected_filename|
|
|
25
|
+
import_file = pool.lookup(type_name).file_descriptor
|
|
26
|
+
if import_file.name != expected_filename
|
|
27
|
+
warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
warn "Each proto file must use a consistent fully-qualified name."
|
|
31
|
+
warn "This will become an error in the next major version."
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
module Com
|
|
35
|
+
module Igeolise
|
|
36
|
+
module Traveltime
|
|
37
|
+
module Rabbitmq
|
|
38
|
+
module Responses
|
|
39
|
+
H3FastResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.responses.H3FastResponse").msgclass
|
|
40
|
+
H3FastResponse::Cells = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("com.igeolise.traveltime.rabbitmq.responses.H3FastResponse.Cells").msgclass
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
require 'google/protobuf'
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
descriptor_data = "\n\x1cTimeFilterFastResponse.proto\x12*com.igeolise.traveltime.rabbitmq.responses\"\
|
|
8
|
+
descriptor_data = "\n\x1cTimeFilterFastResponse.proto\x12*com.igeolise.traveltime.rabbitmq.responses\"\xf0\n\n\x16TimeFilterFastResponse\x12[\n\x05\x65rror\x18\x01 \x01(\x0b\x32H.com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.ErrorB\x02\x18\x01\x12\x61\n\nproperties\x18\x02 \x01(\x0b\x32M.com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.Properties\x1aJ\n\nProperties\x12\x13\n\x0btravelTimes\x18\x01 \x03(\x11\x12\x14\n\x0cmonthlyFares\x18\x02 \x03(\x05\x12\x11\n\tdistances\x18\x03 \x03(\x05\x1a\x63\n\x05\x45rror\x12Z\n\x04type\x18\x01 \x01(\x0e\x32L.com.igeolise.traveltime.rabbitmq.responses.TimeFilterFastResponse.ErrorType\"\xe4\x07\n\tErrorType\x12\x0f\n\x07UNKNOWN\x10\x00\x1a\x02\x08\x01\x12$\n\x1cONE_TO_MANY_MUST_NOT_BE_NULL\x10\x01\x1a\x02\x08\x01\x12\x1f\n\x17SOURCE_MUST_NOT_BE_NULL\x10\x02\x1a\x02\x08\x01\x12\'\n\x1fTRANSPORTATION_MUST_NOT_BE_NULL\x10\x03\x1a\x02\x08\x01\x12\x1e\n\x16SOURCE_NOT_IN_GEOMETRY\x10\x04\x1a\x02\x08\x01\x12(\n UNRECOGNIZED_TRANSPORTATION_MODE\x10\x05\x1a\x02\x08\x01\x12!\n\x19TRAVEL_TIME_LIMIT_TOO_LOW\x10\x06\x1a\x02\x08\x01\x12\"\n\x1aTRAVEL_TIME_LIMIT_TOO_HIGH\x10\x07\x1a\x02\x08\x01\x12\x1d\n\x15\x41UTH_ERROR_NO_USER_ID\x10\x08\x1a\x02\x08\x01\x12\x32\n*SERVICE_MISMATCH_WRONG_TRANSPORTATION_MODE\x10\t\x1a\x02\x08\x01\x12\x1b\n\x13SOURCE_OUT_OF_REACH\x10\n\x1a\x02\x08\x01\x12\x33\n+INTERLEAVED_DELTAS_INVALID_COORDINATE_PAIRS\x10\x0b\x1a\x02\x08\x01\x12\'\n\x1f\x44ISTANCE_PROPERTY_NOT_SUPPORTED\x10\x0c\x1a\x02\x08\x01\x12\x37\n/BOTH_MANY_TO_ONE_AND_ONE_TO_MANY_CANNOT_BE_SENT\x10\r\x1a\x02\x08\x01\x12\x33\n+ONE_TO_MANY_OR_MANY_TO_ONE_MUST_NOT_BE_NULL\x10\x0e\x1a\x02\x08\x01\x12\x1d\n\x15INVALID_PROTO_REQUEST\x10\x0f\x1a\x02\x08\x01\x12\x19\n\x11TOO_MANY_REQUESTS\x10\x10\x1a\x02\x08\x01\x12+\n#PARKING_TIME_OVER_TRAVEL_TIME_LIMIT\x10\x11\x1a\x02\x08\x01\x12(\n WALK_TO_STATION_MUST_BE_POSITIVE\x10\x12\x1a\x02\x08\x01\x12.\n&WALK_TO_STATION_OVER_TRAVEL_TIME_LIMIT\x10\x13\x1a\x02\x08\x01\x12 \n\x18WALK_TO_STATION_TOO_HIGH\x10\x14\x1a\x02\x08\x01\x12)\n!DRIVE_TO_STATION_MUST_BE_POSITIVE\x10\x15\x1a\x02\x08\x01\x12/\n\'DRIVE_TO_STATION_OVER_TRAVEL_TIME_LIMIT\x10\x16\x1a\x02\x08\x01\x12!\n\x19\x44RIVE_TO_STATION_TOO_HIGH\x10\x17\x1a\x02\x08\x01\x12\'\n\x1fTRANSPORTATION_DETAILS_MISMATCH\x10\x18\x1a\x02\x08\x01\x62\x06proto3"
|
|
9
9
|
|
|
10
10
|
pool = Google::Protobuf::DescriptorPool.generated_pool
|
|
11
11
|
|
data/lib/travel_time/client.rb
CHANGED
|
@@ -9,11 +9,20 @@ require 'limiter'
|
|
|
9
9
|
module TravelTime
|
|
10
10
|
# The Client class provides the main interface to interact with the TravelTime API
|
|
11
11
|
class Client # rubocop:disable Metrics/ClassLength
|
|
12
|
+
include Dry::Configurable
|
|
12
13
|
extend Limiter::Mixin
|
|
13
14
|
|
|
14
15
|
API_BASE_URL = 'https://api.traveltimeapp.com/v4/'
|
|
15
16
|
PROTO_BASE_URL = 'https://proto.api.traveltimeapp.com/api/v3/'
|
|
16
17
|
|
|
18
|
+
TravelTime.settings.each do |s|
|
|
19
|
+
if s.default.nil?
|
|
20
|
+
setting s.name
|
|
21
|
+
else
|
|
22
|
+
setting s.name, default: s.default
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
17
26
|
attr_reader :connection, :proto_connection
|
|
18
27
|
|
|
19
28
|
def initialize(rate_limit = nil)
|
|
@@ -27,32 +36,66 @@ module TravelTime
|
|
|
27
36
|
end
|
|
28
37
|
end
|
|
29
38
|
|
|
39
|
+
# Instance configuration starts as a copy of the global config, so settings not
|
|
40
|
+
# overridden in the block keep their globally configured values. Connections are
|
|
41
|
+
# rebuilt afterwards so the new config takes effect.
|
|
42
|
+
def configure
|
|
43
|
+
inherit_global_config unless @instance_configured
|
|
44
|
+
super.tap do
|
|
45
|
+
@instance_configured = true
|
|
46
|
+
init_connection
|
|
47
|
+
init_proto_connection
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def effective_config
|
|
52
|
+
@instance_configured ? config : TravelTime.config
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def inherit_global_config
|
|
56
|
+
TravelTime.settings.each do |s|
|
|
57
|
+
config.public_send(:"#{s.name}=", TravelTime.config.public_send(s.name))
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
private :inherit_global_config
|
|
61
|
+
|
|
30
62
|
def init_connection
|
|
63
|
+
cfg = effective_config
|
|
31
64
|
@connection = Faraday.new(API_BASE_URL) do |f|
|
|
32
65
|
f.request :json
|
|
33
|
-
f.response :raise_error if
|
|
34
|
-
f.response :logger if
|
|
66
|
+
f.response :raise_error if cfg.raise_on_failure
|
|
67
|
+
f.response :logger if cfg.enable_logging
|
|
35
68
|
f.response :json
|
|
36
|
-
f.use TravelTime::Middleware::Authentication
|
|
37
|
-
f.adapter
|
|
69
|
+
f.use TravelTime::Middleware::Authentication, config: cfg
|
|
70
|
+
f.adapter cfg.http_adapter || Faraday.default_adapter
|
|
38
71
|
end
|
|
39
72
|
end
|
|
40
73
|
|
|
41
74
|
def init_proto_connection
|
|
75
|
+
cfg = effective_config
|
|
42
76
|
@proto_connection = Faraday.new do |f|
|
|
43
|
-
f.response :raise_error if
|
|
44
|
-
f.response :logger if
|
|
45
|
-
f.use TravelTime::Middleware::ProtoMiddleware
|
|
46
|
-
f.adapter
|
|
77
|
+
f.response :raise_error if cfg.raise_on_failure
|
|
78
|
+
f.response :logger if cfg.enable_logging
|
|
79
|
+
f.use TravelTime::Middleware::ProtoMiddleware, config: cfg
|
|
80
|
+
f.adapter cfg.http_adapter || Faraday.default_adapter
|
|
47
81
|
end
|
|
48
82
|
end
|
|
49
83
|
|
|
84
|
+
def proto_properties(with_fares, with_distance)
|
|
85
|
+
property_enum = Com::Igeolise::Traveltime::Rabbitmq::Requests::TimeFilterFastRequest::Property
|
|
86
|
+
properties = []
|
|
87
|
+
properties << property_enum::FARES if with_fares
|
|
88
|
+
properties << property_enum::DISTANCES if with_distance
|
|
89
|
+
properties.empty? ? nil : properties
|
|
90
|
+
end
|
|
91
|
+
private :proto_properties
|
|
92
|
+
|
|
50
93
|
def unwrap(response)
|
|
51
94
|
Response.from_object(response)
|
|
52
95
|
end
|
|
53
96
|
|
|
54
|
-
def unwrap_proto(response)
|
|
55
|
-
Response.from_object_proto(response)
|
|
97
|
+
def unwrap_proto(response, decoder: nil)
|
|
98
|
+
Response.from_object_proto(response, decoder: decoder)
|
|
56
99
|
end
|
|
57
100
|
|
|
58
101
|
def perform_request
|
|
@@ -65,8 +108,8 @@ module TravelTime
|
|
|
65
108
|
raise TravelTime::Error.new(exception: e)
|
|
66
109
|
end
|
|
67
110
|
|
|
68
|
-
def perform_request_proto
|
|
69
|
-
unwrap_proto(yield)
|
|
111
|
+
def perform_request_proto(decoder: nil)
|
|
112
|
+
unwrap_proto(yield, decoder: decoder)
|
|
70
113
|
rescue Faraday::Error => e
|
|
71
114
|
raise TravelTime::Error.new(response: Response.from_proto_error(e.response), exception: e) if e.response
|
|
72
115
|
|
|
@@ -152,10 +195,9 @@ module TravelTime
|
|
|
152
195
|
end
|
|
153
196
|
|
|
154
197
|
def time_filter_fast_proto(country:, origin:, destinations:, transport:, traveltime:, with_distance: false,
|
|
155
|
-
request_type: nil)
|
|
198
|
+
with_fares: false, request_type: nil)
|
|
156
199
|
transport_obj = Transport.new(transport)
|
|
157
|
-
|
|
158
|
-
properties = with_distance ? [distance_prop] : nil
|
|
200
|
+
properties = proto_properties(with_fares, with_distance)
|
|
159
201
|
message = ProtoUtils.make_proto_message(origin, destinations, transport_obj, traveltime,
|
|
160
202
|
properties: properties, request_type: request_type)
|
|
161
203
|
payload = ProtoUtils.encode_proto_message(message)
|
|
@@ -163,6 +205,37 @@ module TravelTime
|
|
|
163
205
|
perform_request_proto { proto_connection.post(path, payload) }
|
|
164
206
|
end
|
|
165
207
|
|
|
208
|
+
def geohash_fast_proto(country:, origin:, transport:, traveltime:, resolution:, properties: nil,
|
|
209
|
+
remove_water_bodies: nil, request_type: nil)
|
|
210
|
+
requests = Com::Igeolise::Traveltime::Rabbitmq::Requests
|
|
211
|
+
responses = Com::Igeolise::Traveltime::Rabbitmq::Responses
|
|
212
|
+
cell_fast_proto(requests::GeohashFastRequest, responses::GeohashFastResponse, 'geohash', country, origin,
|
|
213
|
+
transport, traveltime, resolution: resolution, properties: properties,
|
|
214
|
+
remove_water_bodies: remove_water_bodies, request_type: request_type)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def h3_fast_proto(country:, origin:, transport:, traveltime:, resolution:, properties: nil,
|
|
218
|
+
remove_water_bodies: nil, request_type: nil)
|
|
219
|
+
requests = Com::Igeolise::Traveltime::Rabbitmq::Requests
|
|
220
|
+
responses = Com::Igeolise::Traveltime::Rabbitmq::Responses
|
|
221
|
+
response = cell_fast_proto(requests::H3FastRequest, responses::H3FastResponse, 'h3', country, origin,
|
|
222
|
+
transport, traveltime, resolution: resolution, properties: properties,
|
|
223
|
+
remove_water_bodies: remove_water_bodies,
|
|
224
|
+
request_type: request_type)
|
|
225
|
+
response.body.dig(:cells, :ids)&.map! { |id| format('%x', id) }
|
|
226
|
+
response
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def cell_fast_proto(request_klass, response_klass, endpoint, country, origin, transport, traveltime, options)
|
|
230
|
+
transport_obj = Transport.new(transport)
|
|
231
|
+
message = ProtoUtils.make_cell_proto_message(request_klass, origin, transport_obj, traveltime, options)
|
|
232
|
+
payload = request_klass.encode(message)
|
|
233
|
+
path = "#{PROTO_BASE_URL}#{country.to_s.downcase}/#{endpoint}/fast/#{transport_obj.url_name}"
|
|
234
|
+
decoder = ProtoUtils.cell_response_decoder(response_klass)
|
|
235
|
+
perform_request_proto(decoder: decoder) { proto_connection.post(path, payload) }
|
|
236
|
+
end
|
|
237
|
+
private :cell_fast_proto
|
|
238
|
+
|
|
166
239
|
def time_filter_postcodes(departure_searches: nil, arrival_searches: nil)
|
|
167
240
|
payload = {
|
|
168
241
|
departure_searches: departure_searches,
|
|
@@ -11,9 +11,14 @@ module TravelTime
|
|
|
11
11
|
API_KEY_HEADER = 'X-Api-Key'
|
|
12
12
|
USER_AGENT = 'User-Agent'
|
|
13
13
|
|
|
14
|
+
def initialize(app, options = {})
|
|
15
|
+
super(app)
|
|
16
|
+
@config = options[:config] || TravelTime.config
|
|
17
|
+
end
|
|
18
|
+
|
|
14
19
|
def on_request(env)
|
|
15
|
-
env.request_headers[APP_ID_HEADER] =
|
|
16
|
-
env.request_headers[API_KEY_HEADER] =
|
|
20
|
+
env.request_headers[APP_ID_HEADER] = @config.application_id
|
|
21
|
+
env.request_headers[API_KEY_HEADER] = @config.api_key
|
|
17
22
|
env.request_headers[USER_AGENT] = "Travel Time Ruby SDK #{TravelTime::VERSION}"
|
|
18
23
|
end
|
|
19
24
|
end
|
|
@@ -9,15 +9,20 @@ module TravelTime
|
|
|
9
9
|
# The Proto middleware is responsible for setting the basic auth headers for proto requests
|
|
10
10
|
# on each request. These are automatically taken from the `TravelTime.config`.
|
|
11
11
|
class ProtoMiddleware < Faraday::Middleware
|
|
12
|
+
def initialize(app, options = {})
|
|
13
|
+
super(app)
|
|
14
|
+
@config = options[:config] || TravelTime.config
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
def on_request(env)
|
|
13
18
|
scheme = env.url.scheme
|
|
14
19
|
raise TravelTime::Error, "Refusing to send credentials over #{scheme}" unless scheme == 'https'
|
|
15
20
|
|
|
16
21
|
env.request_headers['Authorization'] =
|
|
17
|
-
"Basic #{Base64.strict_encode64("#{
|
|
22
|
+
"Basic #{Base64.strict_encode64("#{@config.application_id}:#{@config.api_key}")}"
|
|
18
23
|
env.request_headers['Content-Type'] = 'application/octet-stream'
|
|
19
24
|
env.request_headers['Accept'] = 'application/octet-stream'
|
|
20
|
-
env.request_headers['User-Agent'] =
|
|
25
|
+
env.request_headers['User-Agent'] = "Travel Time Ruby SDK #{TravelTime::VERSION}"
|
|
21
26
|
end
|
|
22
27
|
end
|
|
23
28
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package com.igeolise.traveltime.rabbitmq.requests;
|
|
4
|
+
|
|
5
|
+
import "RequestsCommon.proto";
|
|
6
|
+
|
|
7
|
+
message GeohashFastRequest {
|
|
8
|
+
message OneToMany {
|
|
9
|
+
Coords departureLocation = 1;
|
|
10
|
+
Transportation transportation = 2;
|
|
11
|
+
TimePeriod arrivalTimePeriod = 3;
|
|
12
|
+
sint32 travelTime = 4;
|
|
13
|
+
uint32 resolution = 5;
|
|
14
|
+
repeated CellPropertyType properties = 6;
|
|
15
|
+
// if absent will default to `true`
|
|
16
|
+
optional bool removeWaterBodies = 7;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
message ManyToOne {
|
|
20
|
+
Coords arrivalLocation = 1;
|
|
21
|
+
Transportation transportation = 2;
|
|
22
|
+
TimePeriod arrivalTimePeriod = 3;
|
|
23
|
+
sint32 travelTime = 4;
|
|
24
|
+
uint32 resolution = 5;
|
|
25
|
+
repeated CellPropertyType properties = 6;
|
|
26
|
+
// if absent will default to `true`
|
|
27
|
+
optional bool removeWaterBodies = 7;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
OneToMany oneToManyRequest = 1;
|
|
31
|
+
ManyToOne manyToOneRequest = 2;
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package com.igeolise.traveltime.rabbitmq.responses;
|
|
4
|
+
|
|
5
|
+
message GeohashFastResponse {
|
|
6
|
+
message Cells {
|
|
7
|
+
repeated string ids = 1;
|
|
8
|
+
repeated sint32 minTravelTimes = 2;
|
|
9
|
+
repeated sint32 maxTravelTimes = 3;
|
|
10
|
+
repeated sint32 meanTravelTimes = 4;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Cells cells = 1;
|
|
14
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package com.igeolise.traveltime.rabbitmq.requests;
|
|
4
|
+
|
|
5
|
+
import "RequestsCommon.proto";
|
|
6
|
+
|
|
7
|
+
message H3FastRequest {
|
|
8
|
+
message OneToMany {
|
|
9
|
+
Coords departureLocation = 1;
|
|
10
|
+
Transportation transportation = 2;
|
|
11
|
+
TimePeriod arrivalTimePeriod = 3;
|
|
12
|
+
sint32 travelTime = 4;
|
|
13
|
+
uint32 resolution = 5;
|
|
14
|
+
repeated CellPropertyType properties = 6;
|
|
15
|
+
// if absent will default to `true`
|
|
16
|
+
optional bool removeWaterBodies = 7;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
message ManyToOne {
|
|
20
|
+
Coords arrivalLocation = 1;
|
|
21
|
+
Transportation transportation = 2;
|
|
22
|
+
TimePeriod arrivalTimePeriod = 3;
|
|
23
|
+
sint32 travelTime = 4;
|
|
24
|
+
uint32 resolution = 5;
|
|
25
|
+
repeated CellPropertyType properties = 6;
|
|
26
|
+
// if absent will default to `true`
|
|
27
|
+
optional bool removeWaterBodies = 7;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
OneToMany oneToManyRequest = 1;
|
|
31
|
+
ManyToOne manyToOneRequest = 2;
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package com.igeolise.traveltime.rabbitmq.responses;
|
|
4
|
+
|
|
5
|
+
message H3FastResponse {
|
|
6
|
+
message Cells {
|
|
7
|
+
// H3 cell indices as fixed64 (the native H3Index representation,
|
|
8
|
+
// see https://h3geo.org/docs/library/index/cell). fixed64 (not uint64):
|
|
9
|
+
// every valid H3 cell ID has the mode bit set (bit 59), so values are
|
|
10
|
+
// always >= 2^59 and varint would always spend the full 9 bytes.
|
|
11
|
+
// fixed64 is 8 bytes and avoids varint encode/decode overhead.
|
|
12
|
+
// Clients that need the 15-char hex form should call their H3 library's
|
|
13
|
+
// int-to-string.
|
|
14
|
+
repeated fixed64 ids = 1;
|
|
15
|
+
repeated sint32 minTravelTimes = 2;
|
|
16
|
+
repeated sint32 maxTravelTimes = 3;
|
|
17
|
+
repeated sint32 meanTravelTimes = 4;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Cells cells = 1;
|
|
21
|
+
}
|
|
@@ -91,6 +91,56 @@ message TimeFilterFastResponse {
|
|
|
91
91
|
* Invalid proto request
|
|
92
92
|
*/
|
|
93
93
|
INVALID_PROTO_REQUEST = 15 [deprecated = true];
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
* The user has gone over their request limit rate
|
|
97
|
+
*/
|
|
98
|
+
TOO_MANY_REQUESTS = 16 [deprecated = true];
|
|
99
|
+
|
|
100
|
+
/*
|
|
101
|
+
* Parking time penalty is over the overall travel time limit for the journey
|
|
102
|
+
*/
|
|
103
|
+
PARKING_TIME_OVER_TRAVEL_TIME_LIMIT = 17 [deprecated = true];
|
|
104
|
+
|
|
105
|
+
/*
|
|
106
|
+
* Walk to station penalty must be > 0
|
|
107
|
+
*/
|
|
108
|
+
WALK_TO_STATION_MUST_BE_POSITIVE = 18 [deprecated = true];
|
|
109
|
+
|
|
110
|
+
/*
|
|
111
|
+
* Walk to station limit cannot be greater than the global travel time
|
|
112
|
+
* limit for the journey.
|
|
113
|
+
*/
|
|
114
|
+
WALK_TO_STATION_OVER_TRAVEL_TIME_LIMIT = 19 [deprecated = true];
|
|
115
|
+
|
|
116
|
+
/*
|
|
117
|
+
* Walk to station limit cannot be greater than 1800
|
|
118
|
+
*/
|
|
119
|
+
WALK_TO_STATION_TOO_HIGH = 20 [deprecated = true];
|
|
120
|
+
|
|
121
|
+
/*
|
|
122
|
+
* Drive to station penalty must be > 0
|
|
123
|
+
*/
|
|
124
|
+
DRIVE_TO_STATION_MUST_BE_POSITIVE = 21 [deprecated = true];
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
* Drive to station limit cannot be greater than the global travel time
|
|
128
|
+
* limit for the journey.
|
|
129
|
+
*/
|
|
130
|
+
DRIVE_TO_STATION_OVER_TRAVEL_TIME_LIMIT = 22 [deprecated = true];
|
|
131
|
+
|
|
132
|
+
/*
|
|
133
|
+
* Drive to station limit cannot be greater than the global travel time
|
|
134
|
+
* limit for the journey.
|
|
135
|
+
*/
|
|
136
|
+
DRIVE_TO_STATION_TOO_HIGH = 23 [deprecated = true];
|
|
137
|
+
|
|
138
|
+
/*
|
|
139
|
+
* Transportation details do not match mode. See
|
|
140
|
+
* * RequestsCommon.PublicTransportDetails
|
|
141
|
+
* * RequestsCommon.DrivingAndPublicTransportDetails
|
|
142
|
+
*/
|
|
143
|
+
TRANSPORTATION_DETAILS_MISMATCH = 24 [deprecated = true];
|
|
94
144
|
}
|
|
95
145
|
|
|
96
146
|
Error error = 1 [deprecated = true];
|
data/lib/travel_time/response.rb
CHANGED
|
@@ -15,12 +15,13 @@ module TravelTime
|
|
|
15
15
|
)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def self.from_object_proto(response)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
def self.from_object_proto(response, decoder: nil)
|
|
19
|
+
body = if response.success?
|
|
20
|
+
decoder ? decoder.call(response.body) : ProtoUtils.decode_proto_response(response.body)
|
|
21
|
+
else
|
|
22
|
+
proto_error(response.headers)
|
|
23
|
+
end
|
|
24
|
+
new(status: response.status, headers: response.headers, body: body)
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
def self.from_hash(response)
|
data/lib/travel_time/version.rb
CHANGED
data/lib/travel_time.rb
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'dry/configurable'
|
|
4
|
-
require 'travel_time/client'
|
|
5
|
-
require 'travel_time/error'
|
|
6
|
-
require 'travel_time/response'
|
|
7
|
-
require 'travel_time/version'
|
|
8
|
-
require 'utils'
|
|
9
4
|
|
|
10
5
|
# Main TravelTime module
|
|
11
6
|
module TravelTime
|
|
@@ -20,3 +15,9 @@ module TravelTime
|
|
|
20
15
|
setting :enable_logging, default: false
|
|
21
16
|
setting :raise_on_failure, default: false
|
|
22
17
|
end
|
|
18
|
+
|
|
19
|
+
require 'travel_time/client'
|
|
20
|
+
require 'travel_time/error'
|
|
21
|
+
require 'travel_time/response'
|
|
22
|
+
require 'travel_time/version'
|
|
23
|
+
require 'utils'
|
data/lib/utils.rb
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
require 'RequestsCommon_pb'
|
|
4
4
|
require 'TimeFilterFastRequest_pb'
|
|
5
5
|
require 'TimeFilterFastResponse_pb'
|
|
6
|
+
require 'GeohashFastRequest_pb'
|
|
7
|
+
require 'GeohashFastResponse_pb'
|
|
8
|
+
require 'H3FastRequest_pb'
|
|
9
|
+
require 'H3FastResponse_pb'
|
|
6
10
|
|
|
7
11
|
module TravelTime
|
|
8
12
|
# Utilities for encoding/decoding protobuf requests
|
|
@@ -68,8 +72,55 @@ module TravelTime
|
|
|
68
72
|
Com::Igeolise::Traveltime::Rabbitmq::Requests::TimeFilterFastRequest.encode(message)
|
|
69
73
|
end
|
|
70
74
|
|
|
75
|
+
def self.make_cell_search(search_klass, transport_obj, traveltime, options)
|
|
76
|
+
search = search_klass.new(
|
|
77
|
+
transportation: make_transportation(transport_obj),
|
|
78
|
+
arrivalTimePeriod: 0,
|
|
79
|
+
travelTime: traveltime,
|
|
80
|
+
resolution: options[:resolution],
|
|
81
|
+
properties: cell_properties(options[:properties])
|
|
82
|
+
)
|
|
83
|
+
search.removeWaterBodies = options[:remove_water_bodies] unless options[:remove_water_bodies].nil?
|
|
84
|
+
search
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.make_transportation(transport_obj)
|
|
88
|
+
transportation = Com::Igeolise::Traveltime::Rabbitmq::Requests::Transportation.new
|
|
89
|
+
transport_obj.apply_to_proto(transportation)
|
|
90
|
+
transportation
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.cell_properties(properties)
|
|
94
|
+
properties&.map { |property| property.to_s.upcase.to_sym }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def self.cell_search_klass(request_klass, request_type)
|
|
98
|
+
case request_type
|
|
99
|
+
when ONE_TO_MANY then request_klass::OneToMany
|
|
100
|
+
when MANY_TO_ONE then request_klass::ManyToOne
|
|
101
|
+
else raise ArgumentError, "Invalid request_type: #{request_type}. Must be ONE_TO_MANY or MANY_TO_ONE"
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def self.make_cell_proto_message(request_klass, origin, transport_obj, traveltime, options)
|
|
106
|
+
request_type = options[:request_type] || ONE_TO_MANY
|
|
107
|
+
search = make_cell_search(cell_search_klass(request_klass, request_type), transport_obj, traveltime, options)
|
|
108
|
+
location = Com::Igeolise::Traveltime::Rabbitmq::Requests::Coords.new(origin)
|
|
109
|
+
if request_type == ONE_TO_MANY
|
|
110
|
+
search.departureLocation = location
|
|
111
|
+
request_klass.new(oneToManyRequest: search)
|
|
112
|
+
else
|
|
113
|
+
search.arrivalLocation = location
|
|
114
|
+
request_klass.new(manyToOneRequest: search)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
71
118
|
def self.decode_proto_response(response)
|
|
72
119
|
Com::Igeolise::Traveltime::Rabbitmq::Responses::TimeFilterFastResponse.decode(response).to_h
|
|
73
120
|
end
|
|
121
|
+
|
|
122
|
+
def self.cell_response_decoder(response_klass)
|
|
123
|
+
->(response) { response_klass.decode(response).to_h }
|
|
124
|
+
end
|
|
74
125
|
end
|
|
75
126
|
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.
|
|
4
|
+
version: 0.10.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: 2026-
|
|
11
|
+
date: 2026-09-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -105,6 +105,10 @@ files:
|
|
|
105
105
|
- Rakefile
|
|
106
106
|
- bin/console
|
|
107
107
|
- bin/setup
|
|
108
|
+
- lib/GeohashFastRequest_pb.rb
|
|
109
|
+
- lib/GeohashFastResponse_pb.rb
|
|
110
|
+
- lib/H3FastRequest_pb.rb
|
|
111
|
+
- lib/H3FastResponse_pb.rb
|
|
108
112
|
- lib/RequestsCommon_pb.rb
|
|
109
113
|
- lib/TimeFilterFastRequest_pb.rb
|
|
110
114
|
- lib/TimeFilterFastResponse_pb.rb
|
|
@@ -113,6 +117,10 @@ files:
|
|
|
113
117
|
- lib/travel_time/error.rb
|
|
114
118
|
- lib/travel_time/middleware/authentication.rb
|
|
115
119
|
- lib/travel_time/middleware/proto.rb
|
|
120
|
+
- lib/travel_time/proto/source/GeohashFastRequest.proto
|
|
121
|
+
- lib/travel_time/proto/source/GeohashFastResponse.proto
|
|
122
|
+
- lib/travel_time/proto/source/H3FastRequest.proto
|
|
123
|
+
- lib/travel_time/proto/source/H3FastResponse.proto
|
|
116
124
|
- lib/travel_time/proto/source/RequestsCommon.proto
|
|
117
125
|
- lib/travel_time/proto/source/TimeFilterFastRequest.proto
|
|
118
126
|
- lib/travel_time/proto/source/TimeFilterFastResponse.proto
|