Skip to content

Commit c730ce2

Browse files
authored
Merge pull request #4320 from hove-io/penality_parking_bike
[NAV-3444] add penality bike parking
2 parents d389810 + 49a0db8 commit c730ce2

22 files changed

+476
-37
lines changed

source/jormungandr/jormungandr/instance.py

+2
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,8 @@ def additional_parameters(self):
820820
additional_time_after_first_section_taxi = _make_property_getter('additional_time_after_first_section_taxi')
821821
additional_time_before_last_section_taxi = _make_property_getter('additional_time_before_last_section_taxi')
822822

823+
on_street_bike_parking_duration = _make_property_getter('on_street_bike_parking_duration')
824+
823825
max_walking_direct_path_duration = _make_property_getter('max_walking_direct_path_duration')
824826
max_bike_direct_path_duration = _make_property_getter('max_bike_direct_path_duration')
825827
max_bss_direct_path_duration = _make_property_getter('max_bss_direct_path_duration')

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

+3
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,9 @@ def _set_specific_params(mod):
843843
if args.get('additional_time_before_last_section_taxi') is None:
844844
args['additional_time_before_last_section_taxi'] = mod.additional_time_before_last_section_taxi
845845

846+
if args.get("on_street_bike_parking_duration") is None:
847+
args["on_street_bike_parking_duration"] = mod.on_street_bike_parking_duration
848+
846849
if args.get('_stop_points_nearby_duration') is None:
847850
args['_stop_points_nearby_duration'] = mod.stop_points_nearby_duration
848851

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

+22-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# www.navitia.io
3131

3232
from __future__ import absolute_import, print_function, unicode_literals, division
33-
from jormungandr import i_manager, fallback_modes, partner_services, app
33+
from jormungandr import i_manager, fallback_modes, park_modes, partner_services, app
3434
from jormungandr.interfaces.v1.ResourceUri import ResourceUri
3535
from datetime import datetime
3636
from jormungandr.resources_utils import ResourceUtc
@@ -239,6 +239,20 @@ def __init__(self, output_type_serializer):
239239
action="append",
240240
help='Same as first_section_mode but for the last section.',
241241
)
242+
243+
parser_get.add_argument(
244+
"park_mode[]",
245+
type=OptionValue(park_modes.all_park_modes),
246+
dest="park_mode",
247+
action="append",
248+
help='Force the park mode for the first or last section of a journey\n'
249+
'Need to be set with one of the first_section_mode[] or last_section_mode[] corresponding to vehicles that could be parked\n'
250+
'Note: Only work with the first or last section mode being a bike for the moment\n'
251+
'Eg: If you want to park a bike at the departure, you need:\n'
252+
'`first_section_mode[]=bike&park_mode[]=on_street`'
253+
'Eg: If you want to park a bike at the arrival, you need:\n'
254+
'`last_section_mode[]=bike&park_mode[]=on_street`',
255+
)
242256
# for retrocompatibility purpose, we duplicate (without []):
243257
parser_get.add_argument(
244258
"first_section_mode",
@@ -506,6 +520,13 @@ def __init__(self, output_type_serializer):
506520
type=int,
507521
help="the additional time added to the taxi section, right before riding the taxi but after hopping off the public transit",
508522
)
523+
524+
parser_get.add_argument(
525+
"on_street_bike_parking_duration",
526+
type=int,
527+
help="the additional time added to the bike section before and after parking the bike",
528+
)
529+
509530
parser_get.add_argument(
510531
"_pt_planner",
511532
type=OptionValue(['kraken', 'loki']),

source/jormungandr/jormungandr/interfaces/v1/serializer/status.py

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class ParametersSerializer(serpy.Serializer):
7474
max_extra_second_pass = Field(schema_type=int)
7575
additional_time_after_first_section_taxi = Field(schema_type=int)
7676
additional_time_before_last_section_taxi = Field(schema_type=int)
77+
on_street_bike_parking_duration = Field(schema_type=int)
7778
max_walking_direct_path_duration = Field(schema_type=int)
7879
max_bike_direct_path_duration = Field(schema_type=int)
7980
max_bss_direct_path_duration = Field(schema_type=int)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2001-2024, Hove and/or its affiliates. All rights reserved.
2+
#
3+
# This file is part of Navitia,
4+
# the software to build cool stuff with public transport.
5+
#
6+
# Hope you'll enjoy and contribute to this project,
7+
# powered by Hove (www.hove.com).
8+
# Help us simplify mobility and open public transport:
9+
# a non ending quest to the responsive locomotion way of traveling!
10+
#
11+
# LICENCE: This program is free software; you can redistribute it and/or modify
12+
# it under the terms of the GNU Affero General Public License as published by
13+
# the Free Software Foundation, either version 3 of the License, or
14+
# (at your option) any later version.
15+
#
16+
# This program is distributed in the hope that it will be useful,
17+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
# GNU Affero General Public License for more details.
20+
#
21+
# You should have received a copy of the GNU Affero General Public License
22+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
#
24+
# Stay tuned using
25+
# twitter @navitia
26+
# channel `#navitia` on riot https://riot.im/app/#/room/#navitia:matrix.org
27+
# https://groups.google.com/d/forum/navitia
28+
# www.navitia.io
29+
#
30+
#
31+
32+
33+
from enum import Enum
34+
from navitiacommon import request_pb2
35+
36+
37+
class ParkMode(Enum):
38+
none = request_pb2.NONE
39+
on_street = request_pb2.OnStreet
40+
park_and_ride = request_pb2.ParkAndRide
41+
42+
@classmethod
43+
def modes_str(cls):
44+
45+
return {e.name for e in cls}
46+
47+
48+
all_park_modes = ParkMode.modes_str()

source/jormungandr/jormungandr/scenarios/distributed.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
from jormungandr.new_relic import record_custom_parameter
5454
from navitiacommon import response_pb2, type_pb2
5555
from flask_restful import abort
56-
from .helper_classes.helper_utils import timed_logger
56+
from .helper_classes.timer_logger_helper import timed_logger
5757
from .helper_classes.helper_exceptions import (
5858
NoGraphicalIsochroneFoundException,
5959
PtException,
@@ -355,6 +355,9 @@ def finalise_journeys(self, future_manager, request, responses, context, instanc
355355
request=request,
356356
journeys=journeys_to_complete,
357357
request_id="{}_complete_pt_journey".format(request_id),
358+
instance=instance,
359+
future_manager=future_manager,
360+
_request_id=request_id,
358361
)
359362
if request['_loki_compute_pt_journey_fare'] is True and request['_pt_planner'] == "loki":
360363
wait_and_complete_pt_journey_fare(
@@ -589,6 +592,9 @@ def graphical_isochrones(self, request, instance):
589592
'additional_time_before_last_section_taxi'
590593
] = instance.additional_time_after_first_section_taxi
591594

595+
if request.get('on_street_bike_parking_duration') is None:
596+
request['on_street_bike_parking_duration'] = instance.on_street_bike_parking_duration
597+
592598
krakens_call = set({(request["origin_mode"][0], request["destination_mode"][0], "indifferent")})
593599
pt_object_origin = None
594600
pt_object_destination = None

source/jormungandr/jormungandr/scenarios/helper_classes/complete_pt_journey.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
complete_pt_journey,
3333
compute_fallback,
3434
_build_crowflies,
35-
timed_logger,
3635
complete_transfer,
3736
)
37+
from .timer_logger_helper import timed_logger
3838
from .helper_exceptions import InvalidDateBoundException
3939
from jormungandr.street_network.street_network import StreetNetworkPathType
4040
from collections import namedtuple
@@ -166,6 +166,7 @@ def wait_and_complete_pt_journey(
166166
request,
167167
journeys,
168168
request_id,
169+
**kwargs
169170
):
170171
"""
171172
In this function, we compute all fallback path once the pt journey is finished, then we build the
@@ -206,6 +207,7 @@ def wait_and_complete_pt_journey(
206207
orig_fallback_durations_pool=orig_fallback_durations_pool,
207208
dest_fallback_durations_pool=dest_fallback_durations_pool,
208209
request=request,
210+
**kwargs
209211
)
210212
if {pt_element.dep_mode, pt_element.arr_mode} & {'car', 'car_no_park'}:
211213
tag_LEZ(pt_element.pt_journeys)

source/jormungandr/jormungandr/scenarios/helper_classes/fallback_durations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from jormungandr import new_relic, excluded_zones_manager
3939
from jormungandr.fallback_modes import FallbackModes
4040
import logging
41-
from .helper_utils import timed_logger
41+
from .timer_logger_helper import timed_logger
4242
import six
4343
from navitiacommon import type_pb2
4444
from jormungandr.exceptions import GeoveloTechnicalError

0 commit comments

Comments
 (0)