Skip to content

Commit

Permalink
Merge pull request #4205 from hove-io/add_datetime_to_matrix_for_asgard
Browse files Browse the repository at this point in the history
[Distributed] Add datetime to matrix for asgard
  • Loading branch information
xlqian authored Jan 30, 2024
2 parents 6dd63a1 + d9aeb05 commit e7cdcea
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions source/jormungandr/jormungandr/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,5 @@

PT_FARES_KRAKEN_TIMEOUT = float(os.getenv('JORMUNGANDR_PT_FARES_KRAKEN_TIMEOUT', 0.1)) # second
PT_FARES_KRAKEN_ATTEMPT_NUMBER = int(os.getenv('JORMUNGANDR_PT_FARES_KRAKEN_ATTEMPT_NUMBER', 2))

USE_EXCLUDED_ZONES = boolean(os.getenv('JORMUNGANDR_USE_EXCLUDED_ZONES', False))
3 changes: 3 additions & 0 deletions source/jormungandr/jormungandr/interfaces/v1/Journeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,9 @@ def _set_specific_params(mod):
if args.get('_loki_compute_pt_journey_fare') is None:
args['_loki_compute_pt_journey_fare'] = mod.loki_compute_pt_journey_fare

if args.get('_use_excluded_zones') is None:
args['_use_excluded_zones'] = app.config['USE_EXCLUDED_ZONES']

# When computing 'same_journey_schedules'(is_journey_schedules=True), some parameters need to be overridden
# because they are contradictory to the request
if args.get("is_journey_schedules"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,15 @@ def __init__(self, output_type_serializer):
help="only available for Asgard: " "Ignore when encountering roads that are oneway.",
)

parser_get.add_argument(
"_use_excluded_zones",
type=BooleanType(),
hidden=True,
default=False,
help="only available for Asgard so far: take into account excluded zones pre-defined in Asgard, "
"Warning: this feature may be performance impacting.",
)

def parse_args(self, region=None, uri=None):
args = self.parsers['get'].parse_args()

Expand Down
5 changes: 4 additions & 1 deletion source/jormungandr/jormungandr/street_network/asgard.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ def _create_sn_routing_matrix_request(
self, origins, destinations, street_network_mode, max_duration, speed_switcher, request, **kwargs
)

req.sn_routing_matrix.datetime = request["datetime"]
req.sn_routing_matrix.use_excluded_zones = request["_use_excluded_zones"]

# Asgard/Valhalla bike
req.sn_routing_matrix.streetnetwork_params.bike_use_roads = request['bike_use_roads']
req.sn_routing_matrix.streetnetwork_params.bike_use_hills = request['bike_use_hills']
Expand Down Expand Up @@ -336,7 +339,7 @@ def _create_direct_path_request(
req.direct_path.destination.CopyFrom(self.make_location(pt_object_destination))
req.direct_path.datetime = fallback_extremity.datetime
req.direct_path.clockwise = fallback_extremity.represents_start

req.direct_path.use_excluded_zones = request["_use_excluded_zones"]
profiles = [
DirectPathProfile(
bike_use_roads=request['bike_use_roads'],
Expand Down
3 changes: 1 addition & 2 deletions source/jormungandr/jormungandr/street_network/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def create_kraken_direct_path_request(


def create_kraken_matrix_request(
connector, origins, destinations, street_network_mode, max_duration, speed_switcher, _, **kwargs
connector, origins, destinations, street_network_mode, max_duration, speed_switcher, request, **kwargs
):
req = request_pb2.Request()
req.requested_api = type_pb2.street_network_routing_matrix
Expand All @@ -147,7 +147,6 @@ def create_kraken_matrix_request(
req.sn_routing_matrix.streetnetwork_params.car_no_park_speed = speed_switcher.get(
"car_no_park", kwargs.get("car_no_park")
)

return req


Expand Down
2 changes: 1 addition & 1 deletion source/navitia-proto
Submodule navitia-proto updated 1 files
+3 −0 request.proto

0 comments on commit e7cdcea

Please sign in to comment.