Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Distributed] Add datetime to matrix for asgard #4205

Merged
merged 6 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 2 additions & 1 deletion source/jormungandr/jormungandr/street_network/asgard.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ 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.datetime = request["datetime"]
req.direct_path.use_excluded_zones = request["_use_excluded_zones"]
profiles = [
DirectPathProfile(
bike_use_roads=request['bike_use_roads'],
Expand Down
6 changes: 4 additions & 2 deletions source/jormungandr/jormungandr/street_network/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def create_kraken_direct_path_request(
req.direct_path.origin.CopyFrom(connector.make_location(pt_object_origin))
req.direct_path.destination.CopyFrom(connector.make_location(pt_object_destination))
req.direct_path.datetime = fallback_extremity.datetime
req.direct_path.use_excluded_zones = request['_use_excluded_zones']
req.direct_path.clockwise = fallback_extremity.represents_start
req.direct_path.streetnetwork_params.origin_mode = connector.handle_car_no_park_modes(mode)
req.direct_path.streetnetwork_params.destination_mode = connector.handle_car_no_park_modes(mode)
Expand Down Expand Up @@ -123,7 +124,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 +148,8 @@ 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")
)

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


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