Add better ferry handling
This commit is contained in:
parent
666c78ff59
commit
30266e72d2
6 changed files with 69 additions and 10 deletions
|
@ -341,5 +341,27 @@ namespace AspectedRouting.Test
|
|||
newTypes = exprs.SpecializeToCommonTypes(out var _);
|
||||
Assert.Single(newTypes);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ParseFunction_InvalidInput_NullOutput()
|
||||
{
|
||||
var f = Funcs.Parse;
|
||||
var c = new Context();
|
||||
var result = f.Evaluate(c, new Constant("abc"));
|
||||
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseFunction_Duration_TotalMinutes()
|
||||
{
|
||||
var f = Funcs.Parse;
|
||||
var c = new Context();
|
||||
var result = f.Evaluate(c, new Constant("01:15"));
|
||||
|
||||
Assert.Equal(75, result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=acd4e5d9_002D8d57_002D4495_002Da7aa_002D38598b9e98e0/@EntryIndexedValue"><SessionState ContinuousTestingIsOn="False" ContinuousTestingMode="0" FrameworkVersion="{x:Null}" IsLocked="False" Name="All tests from &lt;AspectedRouting.Test&gt;" PlatformMonoPreference="{x:Null}" PlatformType="{x:Null}" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=46c4a96e_002D61f1_002D4d55_002Da7ff_002D649a683870dc/@EntryIndexedValue"><SessionState ContinuousTestingIsOn="False" ContinuousTestingMode="0" FrameworkVersion="{x:Null}" IsLocked="False" Name="ParseFunction_Duration_TotalMinutes" PlatformMonoPreference="{x:Null}" PlatformType="{x:Null}" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Project Location="/home/pietervdvn/werk/AspectedRouting/AspectedRouting.Test" Presentation="&lt;AspectedRouting.Test&gt;" />
|
||||
</SessionState></s:String></wpf:ResourceDictionary>
|
||||
</SessionState></s:String>
|
||||
</wpf:ResourceDictionary>
|
|
@ -22,6 +22,7 @@
|
|||
"$min": [
|
||||
"$legal_maxspeed_be",
|
||||
"#maxspeed",
|
||||
"$ferry_speed",
|
||||
{
|
||||
"$multiply": [
|
||||
"#defaultSpeed",
|
||||
|
|
35
Profiles/general/ferry_speed.json
Normal file
35
Profiles/general/ferry_speed.json
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "ferry_speed",
|
||||
"description": "Gives the expected speed for a ferry. This includes the time needed to board and the expected waiting time (if duration is present). This uses the tag '_length', which is expected to be added by the preprocessing-step.",
|
||||
"unit": "km/h",
|
||||
"value": {
|
||||
"$ifDotted": {
|
||||
"route": {
|
||||
"ferry": "yes"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"#": "(length (m) / (duration (minutes) + 5 minutes slack)) * 0.06 minutes/kilometer",
|
||||
"$multiply": [
|
||||
{
|
||||
"#": "The default value is chosen so that it defaults to 1km/h",
|
||||
"$default": 83.33333333333333,
|
||||
"value": {
|
||||
"_length": "$parse"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$inv": {
|
||||
"$sum": [
|
||||
{
|
||||
"duration": "$parse"
|
||||
},
|
||||
5
|
||||
]
|
||||
}
|
||||
},
|
||||
0.06
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
5
Profiles/general/ferry_speed.test.csv
Normal file
5
Profiles/general/ferry_speed.test.csv
Normal file
|
@ -0,0 +1,5 @@
|
|||
expected,route,duration,interval,_length,comment
|
||||
1,ferry,,,
|
||||
2,ferry,25,,1000,25 minutes duration + 5 minutes to get on is 30 minutes total for one kilometer -> 2 km/h
|
||||
4,ferry,10,,1000,10 minutes duration + 5 minutes to get on is 15 minutes total for one kilometer -> 4km/h
|
||||
null,,,,Ferry is not set
|
|
|
@ -7,8 +7,7 @@
|
|||
"$firstMatchOf": [
|
||||
"maxspeed",
|
||||
"designation",
|
||||
"highway",
|
||||
"route"
|
||||
"highway"
|
||||
],
|
||||
"value": {
|
||||
"maxspeed": "$parse",
|
||||
|
@ -37,10 +36,6 @@
|
|||
},
|
||||
"designation": {
|
||||
"towpath": 30
|
||||
},
|
||||
"route": {
|
||||
"#": "A ferry often goes once every half-an-hour, to cross like 100m; in other words: 0.2km/h",
|
||||
"ferry": 0.2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue