Skip to content

Commit 086c329

Browse files
authored
Merge pull request #4349 from hove-io/fix_init_params_from_bdd
[jormungandr]: Use values from BDD for instance parameters if absent
2 parents 7b6c2fe + f43c4d0 commit 086c329

File tree

8 files changed

+69
-38
lines changed

8 files changed

+69
-38
lines changed

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

+58
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,64 @@ def _set_specific_params(mod):
917917
if args.get('_disruptions_on_poi') is None:
918918
args['_disruptions_on_poi'] = mod.disruptions_on_poi
919919

920+
# Set params for advanced parameters for valhalla walking
921+
if args.get('walking_walkway_factor') is None:
922+
args['walking_walkway_factor'] = mod.walking_walkway_factor
923+
if args.get('walking_sidewalk_factor') is None:
924+
args['walking_sidewalk_factor'] = mod.walking_sidewalk_factor
925+
if args.get('walking_alley_factor') is None:
926+
args['walking_alley_factor'] = mod.walking_alley_factor
927+
if args.get('walking_driveway_factor') is None:
928+
args['walking_driveway_factor'] = mod.walking_driveway_factor
929+
if args.get('walking_step_penalty') is None:
930+
args['walking_step_penalty'] = mod.walking_step_penalty
931+
if args.get('walking_use_ferry') is None:
932+
args['walking_use_ferry'] = mod.walking_use_ferry
933+
if args.get('walking_use_living_streets') is None:
934+
args['walking_use_living_streets'] = mod.walking_use_living_streets
935+
if args.get('walking_use_tracks') is None:
936+
args['walking_use_tracks'] = mod.walking_use_tracks
937+
if args.get('walking_use_hills') is None:
938+
args['walking_use_hills'] = mod.walking_use_hills
939+
if args.get('walking_service_factor') is None:
940+
args['walking_service_factor'] = mod.walking_service_factor
941+
if args.get('walking_max_hiking_difficulty') is None:
942+
args['walking_max_hiking_difficulty'] = mod.walking_max_hiking_difficulty
943+
if args.get('walking_shortest') is None:
944+
args['walking_shortest'] = mod.walking_shortest
945+
if args.get('walking_ignore_oneways') is None:
946+
args['walking_ignore_oneways'] = mod.walking_ignore_oneways
947+
if args.get('walking_destination_only_penalty') is None:
948+
args['walking_destination_only_penalty'] = mod.walking_destination_only_penalty
949+
950+
# Set params for advanced parameters for valhalla bike
951+
if args.get('bike_use_roads') is None:
952+
args['bike_use_roads'] = mod.bike_use_roads
953+
if args.get('bike_use_hills') is None:
954+
args['bike_use_hills'] = mod.bike_use_hills
955+
if args.get('bike_use_ferry') is None:
956+
args['bike_use_ferry'] = mod.bike_use_ferry
957+
if args.get('bike_avoid_bad_surfaces') is None:
958+
args['bike_avoid_bad_surfaces'] = mod.bike_avoid_bad_surfaces
959+
if args.get('bike_shortest') is None:
960+
args['bike_shortest'] = mod.bike_shortest
961+
if args.get('bicycle_type') is None:
962+
args['bicycle_type'] = mod.bicycle_type
963+
if args.get('bike_use_living_streets') is None:
964+
args['bike_use_living_streets'] = mod.bike_use_living_streets
965+
if args.get('bike_maneuver_penalty') is None:
966+
args['bike_maneuver_penalty'] = mod.bike_maneuver_penalty
967+
if args.get('bike_service_penalty') is None:
968+
args['bike_service_penalty'] = mod.bike_service_penalty
969+
if args.get('bike_service_factor') is None:
970+
args['bike_service_factor'] = mod.bike_service_factor
971+
if args.get('bike_country_crossing_cost') is None:
972+
args['bike_country_crossing_cost'] = mod.bike_country_crossing_cost
973+
if args.get('bike_country_crossing_penalty') is None:
974+
args['bike_country_crossing_penalty'] = mod.bike_country_crossing_penalty
975+
if args.get('bike_destination_only_penalty') is None:
976+
args['bike_destination_only_penalty'] = mod.bike_destination_only_penalty
977+
920978
# When computing 'same_journey_schedules'(is_journey_schedules=True), some parameters need to be overridden
921979
# because they are contradictory to the request
922980
if args.get("is_journey_schedules"):

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

+1-28
Original file line numberDiff line numberDiff line change
@@ -597,92 +597,79 @@ def __init__(self, output_type_serializer):
597597
"bike_use_roads",
598598
type=FloatRange(0, 1),
599599
hidden=True,
600-
default=0.5,
601600
help="only available for Asgard: A cyclist's propensity to use roads alongside other vehicles.",
602601
)
603602
parser_get.add_argument(
604603
"bike_use_hills",
605604
type=FloatRange(0, 1),
606605
hidden=True,
607-
default=0.5,
608606
help="only available for Asgard: A cyclist's desire to tackle hills in their routes.",
609607
)
610608
parser_get.add_argument(
611609
"bike_use_ferry",
612610
type=FloatRange(0, 1),
613611
hidden=True,
614-
default=0.5,
615612
help="only available for Asgard: This value indicates the willingness to take ferries.",
616613
)
617614
parser_get.add_argument(
618615
"bike_avoid_bad_surfaces",
619616
type=FloatRange(0, 1),
620617
hidden=True,
621-
default=0.25,
622618
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.",
623619
)
624620
parser_get.add_argument(
625621
"bike_shortest",
626622
type=BooleanType(),
627623
hidden=True,
628-
default=False,
629624
help="only available for Asgard: Changes the metric to quasi-shortest, i.e. purely distance-based costing.",
630625
)
631626
parser_get.add_argument(
632627
"bicycle_type",
633628
type=OptionValue(BICYCLE_TYPES),
634629
hidden=True,
635-
default='hybrid',
636-
help="only available for Asgard: The type of bicycle.",
630+
help="only available for Asgard: The type of bicycle. Allowed values (road, hybrid, cross, moutain)",
637631
)
638632
parser_get.add_argument(
639633
"bike_use_living_streets",
640634
type=FloatRange(0, 1),
641635
hidden=True,
642-
default=0.5,
643636
help="only available for Asgard: This value indicates the willingness to take living streets.",
644637
)
645638
parser_get.add_argument(
646639
"bike_maneuver_penalty",
647640
type=float,
648641
hidden=True,
649-
default=5,
650642
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.",
651643
)
652644
parser_get.add_argument(
653645
"bike_service_penalty",
654646
type=float,
655647
hidden=True,
656-
default=0,
657648
help="only available for Asgard: A penalty applied for transition to generic service road. ",
658649
)
659650
parser_get.add_argument(
660651
"bike_service_factor",
661652
type=float,
662653
hidden=True,
663-
default=1,
664654
help="only available for Asgard: A factor that modifies (multiplies) the cost when generic service roads are encountered. ",
665655
)
666656
parser_get.add_argument(
667657
"bike_country_crossing_cost",
668658
type=float,
669659
hidden=True,
670-
default=600,
671660
help="only available for Asgard: A cost applied when encountering an international border. This cost is added to the estimated and elapsed times. ",
672661
)
673662
parser_get.add_argument(
674663
"bike_country_crossing_penalty",
675664
type=float,
676665
hidden=True,
677-
default=0,
678666
help="only available for Asgard: A penalty applied for a country crossing. ",
679667
)
680668

681669
parser_get.add_argument(
682670
"bike_destination_only_penalty",
683671
type=PositiveFloat(),
684672
hidden=True,
685-
default=120,
686673
help="only available for Asgard: penalty when the way is private, private_hgv, parking aisle, drive way, drive thru.",
687674
)
688675

@@ -691,7 +678,6 @@ def __init__(self, output_type_serializer):
691678
"walking_walkway_factor",
692679
type=float,
693680
hidden=True,
694-
default=1.0,
695681
help="only available for Asgard: "
696682
"A factor that modifies (multiplies) the cost when encountering roads classified as footway.",
697683
)
@@ -700,7 +686,6 @@ def __init__(self, output_type_serializer):
700686
"walking_sidewalk_factor",
701687
type=float,
702688
hidden=True,
703-
default=1.0,
704689
help="only available for Asgard: "
705690
"A factor that modifies (multiplies) the cost when encountering roads with dedicated sidewalks.",
706691
)
@@ -709,7 +694,6 @@ def __init__(self, output_type_serializer):
709694
"walking_alley_factor",
710695
type=float,
711696
hidden=True,
712-
default=2.0,
713697
help="only available for Asgard: "
714698
"A factor that modifies (multiplies) the cost when alleys are encountered.",
715699
)
@@ -718,7 +702,6 @@ def __init__(self, output_type_serializer):
718702
"walking_driveway_factor",
719703
type=float,
720704
hidden=True,
721-
default=5.0,
722705
help="only available for Asgard: "
723706
"A factor that modifies (multiplies) the cost when encountering a driveway, "
724707
"which is often a private, service road.",
@@ -728,7 +711,6 @@ def __init__(self, output_type_serializer):
728711
"walking_step_penalty",
729712
type=float,
730713
hidden=True,
731-
default=30.0,
732714
help="only available for Asgard: "
733715
"A penalty in seconds added to each transition onto a path with steps or stairs.",
734716
)
@@ -737,7 +719,6 @@ def __init__(self, output_type_serializer):
737719
"walking_use_ferry",
738720
type=IntervalValue(type=float, min_value=0, max_value=1),
739721
hidden=True,
740-
default=0.5,
741722
help="only available for Asgard: "
742723
"This value indicates the willingness to take ferries. This is range of values between 0 and 1. "
743724
"Values near 0 attempt to avoid ferries and values near 1 will favor ferries.",
@@ -747,7 +728,6 @@ def __init__(self, output_type_serializer):
747728
"walking_use_living_streets",
748729
type=IntervalValue(type=float, min_value=0, max_value=1),
749730
hidden=True,
750-
default=0.6,
751731
help="only available for Asgard: "
752732
"This value indicates the willingness to take living streets.It is a range of values between 0 and 1. "
753733
"Values near 0 attempt to avoid living streets and values near 1 will favor living streets. ",
@@ -757,7 +737,6 @@ def __init__(self, output_type_serializer):
757737
"walking_use_tracks",
758738
type=IntervalValue(type=float, min_value=0, max_value=1),
759739
hidden=True,
760-
default=0.5,
761740
help="only available for Asgard: "
762741
"This value indicates the willingness to take track roads. This is a range of values between 0 and 1. "
763742
"Values near 0 attempt to avoid tracks and values near 1 will favor tracks a little bit.",
@@ -767,7 +746,6 @@ def __init__(self, output_type_serializer):
767746
"walking_use_hills",
768747
type=IntervalValue(type=float, min_value=0, max_value=1),
769748
hidden=True,
770-
default=0.5,
771749
help="only available for Asgard: "
772750
"This is a range of values from 0 to 1, where 0 attempts to avoid hills and steep grades even if it "
773751
"means a longer (time and distance) path, while 1 indicates the pedestrian does not fear hills and "
@@ -786,7 +764,6 @@ def __init__(self, output_type_serializer):
786764
"walking_service_factor",
787765
type=float,
788766
hidden=True,
789-
default=1,
790767
help="only available for Asgard: "
791768
"A factor that modifies (multiplies) the cost when generic service roads are encountered.",
792769
)
@@ -795,7 +772,6 @@ def __init__(self, output_type_serializer):
795772
"walking_max_hiking_difficulty",
796773
type=IntervalValue(type=int, min_value=0, max_value=6),
797774
hidden=True,
798-
default=1,
799775
help="only available for Asgard: "
800776
"This value indicates the maximum difficulty of hiking trails that is allowed. "
801777
"Values between 0 and 6 are allowed.",
@@ -805,7 +781,6 @@ def __init__(self, output_type_serializer):
805781
"walking_shortest",
806782
type=BooleanType(),
807783
hidden=True,
808-
default=False,
809784
help="only available for Asgard: "
810785
"Changes the metric to quasi-shortest, i.e. purely distance-based costing.",
811786
)
@@ -814,15 +789,13 @@ def __init__(self, output_type_serializer):
814789
"walking_ignore_oneways",
815790
type=BooleanType(),
816791
hidden=True,
817-
default=True,
818792
help="only available for Asgard: " "Ignore when encountering roads that are oneway.",
819793
)
820794

821795
parser_get.add_argument(
822796
"walking_destination_only_penalty",
823797
type=PositiveFloat(),
824798
hidden=True,
825-
default=120,
826799
help="only available for Asgard: penalty when the way is private, private_hgv, parking aisle, drive way, drive thru.",
827800
)
828801

source/jormungandr/tests/direct_path_asgard_integration_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"modes": ['walking', 'car', 'bss', 'bike', 'car_no_park'],
4141
"class": "tests.direct_path_asgard_integration_tests.MockAsgard",
4242
"args": {
43-
"costing_options": {"bicycle": {"bicycle_type": "Hybrid"}},
43+
"costing_options": {"bicycle": {"bicycle_type": "hybrid"}},
4444
"api_key": "",
4545
"asgard_socket": "bob_socket",
4646
"service_url": "http://bob.com",
@@ -53,7 +53,7 @@
5353
"modes": ['walking', 'car', 'bss', 'bike'],
5454
"class": "tests.direct_path_asgard_integration_tests.MockAsgardWithBadResponse",
5555
"args": {
56-
"costing_options": {"bicycle": {"bicycle_type": "Hybrid"}},
56+
"costing_options": {"bicycle": {"bicycle_type": "hybrid"}},
5757
"api_key": "",
5858
"asgard_socket": "bob_socket",
5959
"service_url": "http://bob.com",

source/jormungandr/tests/direct_path_parking_with_asgard_integration_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"modes": ['walking', 'bike', 'bss'],
5151
"class": "tests.direct_path_asgard_integration_tests.MockAsgard",
5252
"args": {
53-
"costing_options": {"bicycle": {"bicycle_type": "Hybrid"}},
53+
"costing_options": {"bicycle": {"bicycle_type": "hybrid"}},
5454
"api_key": "",
5555
"asgard_socket": "bob_socket",
5656
"service_url": "http://bob.com",
@@ -130,7 +130,7 @@ def _request(self, *_, **__):
130130
"modes": ['walking', 'bike', 'bss'],
131131
"class": "tests.direct_path_asgard_integration_tests.MockAsgard",
132132
"args": {
133-
"costing_options": {"bicycle": {"bicycle_type": "Hybrid"}},
133+
"costing_options": {"bicycle": {"bicycle_type": "hybrid"}},
134134
"api_key": "",
135135
"asgard_socket": "bob_socket",
136136
"service_url": "http://bob.com",

source/jormungandr/tests/end_point_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def test_parameters_in_one_status(self):
309309
assert parameters['bike_use_ferry'] == 0.5
310310
assert parameters['bike_avoid_bad_surfaces'] == 0.25
311311
assert parameters['bike_shortest'] is False
312-
assert parameters['bicycle_type'] == 'Hybrid'
312+
assert parameters['bicycle_type'] == 'hybrid'
313313
assert parameters['bike_use_living_streets'] == 0.5
314314
assert parameters['bike_maneuver_penalty'] == 5
315315
assert parameters['bike_service_penalty'] == 0

source/navitiacommon/navitiacommon/default_values.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287
bike_use_ferry = 0.5 # (0 - 1.0)
288288
bike_avoid_bad_surfaces = 0.25 # (0 - 1.0)
289289
bike_shortest = False
290-
bicycle_type = 'Hybrid' # The type of bicycle [Road, Hybrid, City, Cross, Mountain]
290+
bicycle_type = 'hybrid' # The type of bicycle [road, hybrid, cross, mountain]
291291
bike_use_living_streets = 0.5 # (0 - 1.0)
292292
bike_maneuver_penalty = 5 # (seconds)
293293
bike_service_penalty = 0

source/tyr/tests/integration/instance_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ def test_on_attributs_starting_with_bike(create_instance):
787787
assert resp[0]['bike_use_ferry'] == 0.5
788788
assert resp[0]['bike_avoid_bad_surfaces'] == 0.25
789789
assert resp[0]['bike_shortest'] is False
790-
assert resp[0]['bicycle_type'] == "Hybrid"
790+
assert resp[0]['bicycle_type'] == "hybrid"
791791
assert resp[0]['bike_use_living_streets'] == 0.5
792792
assert resp[0]['bike_maneuver_penalty'] == 5
793793
assert resp[0]['bike_service_penalty'] == 0
@@ -802,7 +802,7 @@ def test_on_attributs_starting_with_bike(create_instance):
802802
'bike_use_ferry': 0.6,
803803
'bike_avoid_bad_surfaces': 0.75,
804804
'bike_shortest': True,
805-
'bicycle_type': "Road",
805+
'bicycle_type': "road",
806806
'bike_use_living_streets': 0.7,
807807
'bike_maneuver_penalty': 6,
808808
'bike_service_penalty': 1,
@@ -820,7 +820,7 @@ def test_on_attributs_starting_with_bike(create_instance):
820820
assert resp[0]['bike_use_ferry'] == 0.6
821821
assert resp[0]['bike_avoid_bad_surfaces'] == 0.75
822822
assert resp[0]['bike_shortest'] is True
823-
assert resp[0]['bicycle_type'] == "Road"
823+
assert resp[0]['bicycle_type'] == "road"
824824
assert resp[0]['bike_use_living_streets'] == 0.7
825825
assert resp[0]['bike_maneuver_penalty'] == 6
826826
assert resp[0]['bike_service_penalty'] == 1

source/tyr/tyr/resources.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ def put(self, version=0, id=None, name=None):
11751175

11761176
parser.add_argument(
11771177
'bicycle_type',
1178-
type=OptionValue(['Road', 'Hybrid', 'City', 'Cross', 'Mountain']),
1178+
type=OptionValue(['road', 'hybrid', 'cross', 'mountain']),
11791179
help='The type of bicycle',
11801180
location=('json', 'values'),
11811181
default=instance.bicycle_type,

0 commit comments

Comments
 (0)