Skip to content

Commit e7cdcea

Browse files
authored
Merge pull request #4205 from hove-io/add_datetime_to_matrix_for_asgard
[Distributed] Add datetime to matrix for asgard
2 parents 6dd63a1 + d9aeb05 commit e7cdcea

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

source/jormungandr/jormungandr/default_settings.py

+2
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,5 @@
401401

402402
PT_FARES_KRAKEN_TIMEOUT = float(os.getenv('JORMUNGANDR_PT_FARES_KRAKEN_TIMEOUT', 0.1)) # second
403403
PT_FARES_KRAKEN_ATTEMPT_NUMBER = int(os.getenv('JORMUNGANDR_PT_FARES_KRAKEN_ATTEMPT_NUMBER', 2))
404+
405+
USE_EXCLUDED_ZONES = boolean(os.getenv('JORMUNGANDR_USE_EXCLUDED_ZONES', False))

source/jormungandr/jormungandr/interfaces/v1/Journeys.py

+3
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,9 @@ def _set_specific_params(mod):
856856
if args.get('_loki_compute_pt_journey_fare') is None:
857857
args['_loki_compute_pt_journey_fare'] = mod.loki_compute_pt_journey_fare
858858

859+
if args.get('_use_excluded_zones') is None:
860+
args['_use_excluded_zones'] = app.config['USE_EXCLUDED_ZONES']
861+
859862
# When computing 'same_journey_schedules'(is_journey_schedules=True), some parameters need to be overridden
860863
# because they are contradictory to the request
861864
if args.get("is_journey_schedules"):

source/jormungandr/jormungandr/interfaces/v1/journey_common.py

+9
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,15 @@ def __init__(self, output_type_serializer):
768768
help="only available for Asgard: " "Ignore when encountering roads that are oneway.",
769769
)
770770

771+
parser_get.add_argument(
772+
"_use_excluded_zones",
773+
type=BooleanType(),
774+
hidden=True,
775+
default=False,
776+
help="only available for Asgard so far: take into account excluded zones pre-defined in Asgard, "
777+
"Warning: this feature may be performance impacting.",
778+
)
779+
771780
def parse_args(self, region=None, uri=None):
772781
args = self.parsers['get'].parse_args()
773782

source/jormungandr/jormungandr/street_network/asgard.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ def _create_sn_routing_matrix_request(
193193
self, origins, destinations, street_network_mode, max_duration, speed_switcher, request, **kwargs
194194
)
195195

196+
req.sn_routing_matrix.datetime = request["datetime"]
197+
req.sn_routing_matrix.use_excluded_zones = request["_use_excluded_zones"]
198+
196199
# Asgard/Valhalla bike
197200
req.sn_routing_matrix.streetnetwork_params.bike_use_roads = request['bike_use_roads']
198201
req.sn_routing_matrix.streetnetwork_params.bike_use_hills = request['bike_use_hills']
@@ -336,7 +339,7 @@ def _create_direct_path_request(
336339
req.direct_path.destination.CopyFrom(self.make_location(pt_object_destination))
337340
req.direct_path.datetime = fallback_extremity.datetime
338341
req.direct_path.clockwise = fallback_extremity.represents_start
339-
342+
req.direct_path.use_excluded_zones = request["_use_excluded_zones"]
340343
profiles = [
341344
DirectPathProfile(
342345
bike_use_roads=request['bike_use_roads'],

source/jormungandr/jormungandr/street_network/utils.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def create_kraken_direct_path_request(
123123

124124

125125
def create_kraken_matrix_request(
126-
connector, origins, destinations, street_network_mode, max_duration, speed_switcher, _, **kwargs
126+
connector, origins, destinations, street_network_mode, max_duration, speed_switcher, request, **kwargs
127127
):
128128
req = request_pb2.Request()
129129
req.requested_api = type_pb2.street_network_routing_matrix
@@ -147,7 +147,6 @@ def create_kraken_matrix_request(
147147
req.sn_routing_matrix.streetnetwork_params.car_no_park_speed = speed_switcher.get(
148148
"car_no_park", kwargs.get("car_no_park")
149149
)
150-
151150
return req
152151

153152

source/navitia-proto

0 commit comments

Comments
 (0)