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

[jormungandr]: Use values from BDD for instance parameters if absent #4349

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
59 changes: 59 additions & 0 deletions source/jormungandr/jormungandr/interfaces/v1/Journeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,65 @@ def _set_specific_params(mod):
if args.get('_disruptions_on_poi') is None:
args['_disruptions_on_poi'] = mod.disruptions_on_poi

# Set params for advanced parameters for valhalla walking
if args.get('walking_walkway_factor') is None:
args['walking_walkway_factor'] = mod.walking_walkway_factor
if args.get('walking_sidewalk_factor') is None:
args['walking_sidewalk_factor'] = mod.walking_sidewalk_factor
if args.get('walking_alley_factor') is None:
args['walking_alley_factor'] = mod.walking_alley_factor
if args.get('walking_driveway_factor') is None:
args['walking_driveway_factor'] = mod.walking_driveway_factor
if args.get('walking_step_penalty') is None:
args['walking_step_penalty'] = mod.walking_step_penalty
if args.get('walking_use_ferry') is None:
args['walking_use_ferry'] = mod.walking_use_ferry
if args.get('walking_use_living_streets') is None:
args['walking_use_living_streets'] = mod.walking_use_living_streets
if args.get('walking_use_tracks') is None:
args['walking_use_tracks'] = mod.walking_use_tracks
if args.get('walking_use_hills') is None:
args['walking_use_hills'] = mod.walking_use_hills
if args.get('walking_service_factor') is None:
args['walking_service_factor'] = mod.walking_service_factor
if args.get('walking_max_hiking_difficulty') is None:
args['walking_max_hiking_difficulty'] = mod.walking_max_hiking_difficulty
if args.get('walking_shortest') is None:
args['walking_shortest'] = mod.walking_shortest
if args.get('walking_ignore_oneways') is None:
args['walking_ignore_oneways'] = mod.walking_ignore_oneways
if args.get('walking_destination_only_penalty') is None:
args['walking_destination_only_penalty'] = mod.walking_destination_only_penalty

# Set params for advanced parameters for valhalla bike
if args.get('bike_use_roads') is None:
args['bike_use_roads'] = mod.bike_use_roads
if args.get('bike_use_hills') is None:
args['bike_use_hills'] = mod.bike_use_hills
if args.get('bike_use_ferry') is None:
args['bike_use_ferry'] = mod.bike_use_ferry
if args.get('bike_avoid_bad_surfaces') is None:
args['bike_avoid_bad_surfaces'] = mod.bike_avoid_bad_surfaces
if args.get('bike_shortest') is None:
args['bike_shortest'] = mod.bike_shortest
if args.get('bicycle_type') is None:
args['bicycle_type'] = mod.bicycle_type
if args.get('bike_use_living_streets') is None:
args['bike_use_living_streets'] = mod.bike_use_living_streets
if args.get('bike_maneuver_penalty') is None:
args['bike_maneuver_penalty'] = mod.bike_maneuver_penalty
if args.get('bike_service_penalty') is None:
args['bike_service_penalty'] = mod.bike_service_penalty
if args.get('bike_service_factor') is None:
args['bike_service_factor'] = mod.bike_service_factor
if args.get('bike_country_crossing_cost') is None:
args['bike_country_crossing_cost'] = mod.bike_country_crossing_cost
if args.get('bike_country_crossing_penalty') is None:
args['bike_country_crossing_penalty'] = mod.bike_country_crossing_penalty
if args.get('bike_destination_only_penalty') is None:
args['bike_destination_only_penalty'] = mod.bike_destination_only_penalty


# 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
29 changes: 1 addition & 28 deletions source/jormungandr/jormungandr/interfaces/v1/journey_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,92 +597,79 @@ def __init__(self, output_type_serializer):
"bike_use_roads",
type=FloatRange(0, 1),
hidden=True,
default=0.5,
help="only available for Asgard: A cyclist's propensity to use roads alongside other vehicles.",
)
parser_get.add_argument(
"bike_use_hills",
type=FloatRange(0, 1),
hidden=True,
default=0.5,
help="only available for Asgard: A cyclist's desire to tackle hills in their routes.",
)
parser_get.add_argument(
"bike_use_ferry",
type=FloatRange(0, 1),
hidden=True,
default=0.5,
help="only available for Asgard: This value indicates the willingness to take ferries.",
)
parser_get.add_argument(
"bike_avoid_bad_surfaces",
type=FloatRange(0, 1),
hidden=True,
default=0.25,
help="only available for Asgard: This value is meant to represent how much a cyclist wants to avoid roads with poor surfaces relative to the bicycle type being used.",
)
parser_get.add_argument(
"bike_shortest",
type=BooleanType(),
hidden=True,
default=False,
help="only available for Asgard: Changes the metric to quasi-shortest, i.e. purely distance-based costing.",
)
parser_get.add_argument(
"bicycle_type",
type=OptionValue(BICYCLE_TYPES),
hidden=True,
default='hybrid',
help="only available for Asgard: The type of bicycle.",
help="only available for Asgard: The type of bicycle. Allowed values (road, hybrid, cross, moutain)",
)
parser_get.add_argument(
"bike_use_living_streets",
type=FloatRange(0, 1),
hidden=True,
default=0.5,
help="only available for Asgard: This value indicates the willingness to take living streets.",
)
parser_get.add_argument(
"bike_maneuver_penalty",
type=float,
hidden=True,
default=5,
help="only available for Asgard: A penalty applied when transitioning between roads that do not have consistent naming–in other words, no road names in common. This penalty can be used to create simpler routes that tend to have fewer maneuvers or narrative guidance instructions.",
)
parser_get.add_argument(
"bike_service_penalty",
type=float,
hidden=True,
default=0,
help="only available for Asgard: A penalty applied for transition to generic service road. ",
)
parser_get.add_argument(
"bike_service_factor",
type=float,
hidden=True,
default=1,
help="only available for Asgard: A factor that modifies (multiplies) the cost when generic service roads are encountered. ",
)
parser_get.add_argument(
"bike_country_crossing_cost",
type=float,
hidden=True,
default=600,
help="only available for Asgard: A cost applied when encountering an international border. This cost is added to the estimated and elapsed times. ",
)
parser_get.add_argument(
"bike_country_crossing_penalty",
type=float,
hidden=True,
default=0,
help="only available for Asgard: A penalty applied for a country crossing. ",
)

parser_get.add_argument(
"bike_destination_only_penalty",
type=PositiveFloat(),
hidden=True,
default=120,
help="only available for Asgard: penalty when the way is private, private_hgv, parking aisle, drive way, drive thru.",
)

Expand All @@ -691,7 +678,6 @@ def __init__(self, output_type_serializer):
"walking_walkway_factor",
type=float,
hidden=True,
default=1.0,
help="only available for Asgard: "
"A factor that modifies (multiplies) the cost when encountering roads classified as footway.",
)
Expand All @@ -700,7 +686,6 @@ def __init__(self, output_type_serializer):
"walking_sidewalk_factor",
type=float,
hidden=True,
default=1.0,
help="only available for Asgard: "
"A factor that modifies (multiplies) the cost when encountering roads with dedicated sidewalks.",
)
Expand All @@ -709,7 +694,6 @@ def __init__(self, output_type_serializer):
"walking_alley_factor",
type=float,
hidden=True,
default=2.0,
help="only available for Asgard: "
"A factor that modifies (multiplies) the cost when alleys are encountered.",
)
Expand All @@ -718,7 +702,6 @@ def __init__(self, output_type_serializer):
"walking_driveway_factor",
type=float,
hidden=True,
default=5.0,
help="only available for Asgard: "
"A factor that modifies (multiplies) the cost when encountering a driveway, "
"which is often a private, service road.",
Expand All @@ -728,7 +711,6 @@ def __init__(self, output_type_serializer):
"walking_step_penalty",
type=float,
hidden=True,
default=30.0,
help="only available for Asgard: "
"A penalty in seconds added to each transition onto a path with steps or stairs.",
)
Expand All @@ -737,7 +719,6 @@ def __init__(self, output_type_serializer):
"walking_use_ferry",
type=IntervalValue(type=float, min_value=0, max_value=1),
hidden=True,
default=0.5,
help="only available for Asgard: "
"This value indicates the willingness to take ferries. This is range of values between 0 and 1. "
"Values near 0 attempt to avoid ferries and values near 1 will favor ferries.",
Expand All @@ -747,7 +728,6 @@ def __init__(self, output_type_serializer):
"walking_use_living_streets",
type=IntervalValue(type=float, min_value=0, max_value=1),
hidden=True,
default=0.6,
help="only available for Asgard: "
"This value indicates the willingness to take living streets.It is a range of values between 0 and 1. "
"Values near 0 attempt to avoid living streets and values near 1 will favor living streets. ",
Expand All @@ -757,7 +737,6 @@ def __init__(self, output_type_serializer):
"walking_use_tracks",
type=IntervalValue(type=float, min_value=0, max_value=1),
hidden=True,
default=0.5,
help="only available for Asgard: "
"This value indicates the willingness to take track roads. This is a range of values between 0 and 1. "
"Values near 0 attempt to avoid tracks and values near 1 will favor tracks a little bit.",
Expand All @@ -767,7 +746,6 @@ def __init__(self, output_type_serializer):
"walking_use_hills",
type=IntervalValue(type=float, min_value=0, max_value=1),
hidden=True,
default=0.5,
help="only available for Asgard: "
"This is a range of values from 0 to 1, where 0 attempts to avoid hills and steep grades even if it "
"means a longer (time and distance) path, while 1 indicates the pedestrian does not fear hills and "
Expand All @@ -786,7 +764,6 @@ def __init__(self, output_type_serializer):
"walking_service_factor",
type=float,
hidden=True,
default=1,
help="only available for Asgard: "
"A factor that modifies (multiplies) the cost when generic service roads are encountered.",
)
Expand All @@ -795,7 +772,6 @@ def __init__(self, output_type_serializer):
"walking_max_hiking_difficulty",
type=IntervalValue(type=int, min_value=0, max_value=6),
hidden=True,
default=1,
help="only available for Asgard: "
"This value indicates the maximum difficulty of hiking trails that is allowed. "
"Values between 0 and 6 are allowed.",
Expand All @@ -805,7 +781,6 @@ def __init__(self, output_type_serializer):
"walking_shortest",
type=BooleanType(),
hidden=True,
default=False,
help="only available for Asgard: "
"Changes the metric to quasi-shortest, i.e. purely distance-based costing.",
)
Expand All @@ -814,15 +789,13 @@ def __init__(self, output_type_serializer):
"walking_ignore_oneways",
type=BooleanType(),
hidden=True,
default=True,
help="only available for Asgard: " "Ignore when encountering roads that are oneway.",
)

parser_get.add_argument(
"walking_destination_only_penalty",
type=PositiveFloat(),
hidden=True,
default=120,
help="only available for Asgard: penalty when the way is private, private_hgv, parking aisle, drive way, drive thru.",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"modes": ['walking', 'car', 'bss', 'bike', 'car_no_park'],
"class": "tests.direct_path_asgard_integration_tests.MockAsgard",
"args": {
"costing_options": {"bicycle": {"bicycle_type": "Hybrid"}},
"costing_options": {"bicycle": {"bicycle_type": "hybrid"}},
"api_key": "",
"asgard_socket": "bob_socket",
"service_url": "http://bob.com",
Expand All @@ -53,7 +53,7 @@
"modes": ['walking', 'car', 'bss', 'bike'],
"class": "tests.direct_path_asgard_integration_tests.MockAsgardWithBadResponse",
"args": {
"costing_options": {"bicycle": {"bicycle_type": "Hybrid"}},
"costing_options": {"bicycle": {"bicycle_type": "hybrid"}},
"api_key": "",
"asgard_socket": "bob_socket",
"service_url": "http://bob.com",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"modes": ['walking', 'bike', 'bss'],
"class": "tests.direct_path_asgard_integration_tests.MockAsgard",
"args": {
"costing_options": {"bicycle": {"bicycle_type": "Hybrid"}},
"costing_options": {"bicycle": {"bicycle_type": "hybrid"}},
"api_key": "",
"asgard_socket": "bob_socket",
"service_url": "http://bob.com",
Expand Down Expand Up @@ -130,7 +130,7 @@ def _request(self, *_, **__):
"modes": ['walking', 'bike', 'bss'],
"class": "tests.direct_path_asgard_integration_tests.MockAsgard",
"args": {
"costing_options": {"bicycle": {"bicycle_type": "Hybrid"}},
"costing_options": {"bicycle": {"bicycle_type": "hybrid"}},
"api_key": "",
"asgard_socket": "bob_socket",
"service_url": "http://bob.com",
Expand Down
2 changes: 1 addition & 1 deletion source/jormungandr/tests/end_point_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def test_parameters_in_one_status(self):
assert parameters['bike_use_ferry'] == 0.5
assert parameters['bike_avoid_bad_surfaces'] == 0.25
assert parameters['bike_shortest'] is False
assert parameters['bicycle_type'] == 'Hybrid'
assert parameters['bicycle_type'] == 'hybrid'
assert parameters['bike_use_living_streets'] == 0.5
assert parameters['bike_maneuver_penalty'] == 5
assert parameters['bike_service_penalty'] == 0
Expand Down
2 changes: 1 addition & 1 deletion source/navitiacommon/navitiacommon/default_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
bike_use_ferry = 0.5 # (0 - 1.0)
bike_avoid_bad_surfaces = 0.25 # (0 - 1.0)
bike_shortest = False
bicycle_type = 'Hybrid' # The type of bicycle [Road, Hybrid, City, Cross, Mountain]
bicycle_type = 'hybrid' # The type of bicycle [road, hybrid, cross, mountain]
bike_use_living_streets = 0.5 # (0 - 1.0)
bike_maneuver_penalty = 5 # (seconds)
bike_service_penalty = 0
Expand Down
Loading