Tuned down the profiles to only be examples, add the examples in testing

This commit is contained in:
Pieter Vander Vennet 2020-10-21 16:31:01 +02:00
parent 3f3940a7b3
commit 1b67267add
46 changed files with 155 additions and 452 deletions

View file

@ -0,0 +1,16 @@
using Xunit;
namespace AspectedRouting.Test
{
public class ExamplesTest
{
[Fact]
public void Integration_TestExamples()
{
var input = "./Examples/";
var output = "./output/";
var err = Program.MainWithError(new[] {input, output, "--no-repl"});
Assert.Null(err);
}
}
}

View file

@ -1,5 +1,10 @@
<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/=46c4a96e_002D61f1_002D4d55_002Da7ff_002D649a683870dc/@EntryIndexedValue">&lt;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"&gt;
&lt;Project Location="/home/pietervdvn/werk/AspectedRouting/AspectedRouting.Test" Presentation="&amp;lt;AspectedRouting.Test&amp;gt;" /&gt;
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=a6a74f48_002D8456_002D43c7_002Dbbee_002Dd3da33a8a4be/@EntryIndexedValue">&lt;SessionState ContinuousTestingIsOn="False" ContinuousTestingMode="0" FrameworkVersion="{x:Null}" IsLocked="False" Name="Integration_TestExamples" PlatformMonoPreference="{x:Null}" PlatformType="{x:Null}" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
&lt;TestAncestor&gt;
&lt;TestId&gt;xUnit::A1309041-8AAE-42D7-A886-94C9FFC6A28C::.NETCoreApp,Version=v3.1::AspectedRouting.Test.ExamplesTest.Integration_TestExamples&lt;/TestId&gt;
&lt;/TestAncestor&gt;
&lt;/SessionState&gt;</s:String>
</wpf:ResourceDictionary>

View file

@ -12,10 +12,7 @@
<None Update="IO\lua\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="IO\lua\unitTestProfile2.lua">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="IO\lua\if_then_else_dotted.lua">
<None Update="Examples\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

View file

@ -0,0 +1,2 @@
<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:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=examples/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View file

@ -37,6 +37,7 @@
"pedestrian": "dismount",
"corridor": "dismount",
"construction": "dismount",
"steps": "dismount",
"path": "yes",
"primary": "yes",
"primary_link": "yes",

View file

@ -12,9 +12,14 @@
"#": "an unmaintained track (in Belgium: tractor path) is slower as well",
"track": 0.7,
"#": "A road under construction slows one down, despite (normally) already being dismount",
"construction": 0.5
"construction": 0.5,
"steps": 0.1
},
"surface": {
"ramp:bicycle": {
"#": "These are stairs (highway=steps), but there is a bicycle ramp, so we go a little bit faster",
"yes": 3
},
"surface": {
"paved": 0.99,
"asphalt": 1,
"concrete": 1,

View file

@ -0,0 +1,95 @@
{
"name": "bicycle",
"description": "Profile for a normal bicycle",
"vehicletypes": [
"vehicle",
"bicycle"
],
"metadata": [
"name",
"bridge",
"tunnel",
"colour",
"cycle_network_colour",
"cycle_network_ref",
"ref",
"status",
"network"
],
"access": "$bicycle.legal_access",
"oneway": "$bicycle.oneway",
"speed": {
"$max": [
"$ferry_speed",
{
"$min": [
"$legal_maxspeed_be",
"#maxspeed",
{
"$multiply": [
"#defaultSpeed",
"$bicycle.speed_factor"
]
}
]
}
]
},
"priority": {
"#comfort": "$bicycle.comfort",
"#safety": "$bicycle.safety",
"#nodeNetworkScore": "$bicycle.network_is_nodenetwork",
"#timeNeeded": "$speed",
"#distance": "$distance",
"#trespassingPenalty": "$clean_permission_score",
"#leastSafetyPenalty": {
"$multiply": [
"$speed",
{
"$atleast": "#leastSafetyRequired",
"f": "$bicycle.safety",
"then": 0,
"else": -1
}
]
}
},
"defaults": {
"#defaultSpeed": 15,
"#maxspeed": 30,
"#timeNeeded": 0,
"#distance": 0,
"#comfort": 0,
"#safety": 0,
"#operatorNetworkScore": 0,
"#networkOperator": [],
"#cycleHighwayNetworkScore": 0,
"#nodeNetworkScore": 0,
"#bicycleNetworkScore": 0,
"#trespassingPenalty": 15,
"#": "This isn't a weight, but is used as cut-off in 'leastSafetyPenalty'",
"#leastSafetyRequired": 0.11,
"#leastSafetyPenalty": 2
},
"behaviours": {
"fastest": {
"description": "The fastest route to your destination",
"#timeNeeded": 1,
"#leastSafetyPenalty": 2
},
"shortest": {
"description": "The shortest route, independent of of speed",
"#distance": 1,
"#leastSafetyPenalty": 2
},
"comfort": {
"description": "A comfortable route preferring well-paved roads, smaller roads and a bit of scenery at the cost of speed",
"#comfort": 1
},
"node_network": {
"description": "A route following the recreational node network. Might make detours",
"#nodeNetworkScore": 10,
"#safety": 1
}
}
}

View file

@ -20,7 +20,6 @@
"priority": {
"#timeNeeded": "$speed",
"#distance": "$distance",
"#slow_road_preference": "$pedestrian.slow_road_preference",
"#trespassingPenalty": "$clean_permission_score"
},
"defaults": {
@ -36,10 +35,6 @@
"description": "The shortest route, independent of of speed",
"#distance": 1,
"#leastSafetyPenalty": 2
},
"slow_roads": {
"description": "A route prefering pedestrian-oriented infrastructure",
"#slow_road_preference": 1
}
}
}

View file

@ -12,7 +12,7 @@ using AspectedRouting.Tests;
namespace AspectedRouting
{
static class Program
public static class Program
{
public static List<(AspectMetadata aspect, AspectTestSuite tests)> ParseAspects(
this IEnumerable<string> jsonFileNames, List<string> testFileNames, Context context)
@ -104,7 +104,6 @@ namespace AspectedRouting
private static void Repl(Context c, Dictionary<string, ProfileMetaData> profiles)
{
var profile = profiles["bicycle"];
var behaviour = profile.Behaviours.Keys.First();
do
@ -126,7 +125,7 @@ namespace AspectedRouting
{
return;
}
if (read.Equals("clear"))
{
for (int i = 0; i < 80; i++)
@ -150,9 +149,9 @@ namespace AspectedRouting
continue;
}
beh = beh.Substring(beh.IndexOf(".")+1);
beh = beh.Substring(beh.IndexOf(".") + 1);
}
if (profile.Behaviours.ContainsKey(beh))
{
behaviour = beh;
@ -225,17 +224,27 @@ namespace AspectedRouting
Console.WriteLine("\n\n\n------------------------");
}
public static void Main(string[] args)
static void Main(string[] args)
{
if (args.Length < 2)
var errMessage = MainWithError(args);
if (errMessage != null)
{
Console.WriteLine("Usage: <directory where all aspects and profiles can be found> <outputdirectory>");
return;
Console.WriteLine(errMessage);
}
}
public static string MainWithError(string[] args){
if (args.Length < 2)
{
return "Usage: <directory where all aspects and profiles can be found> <outputdirectory>";
}
var inputDir = args[0];
var outputDir = args[1];
if (!Directory.Exists(outputDir))
{
Directory.CreateDirectory(outputDir);
}
MdPrinter.GenerateHelpText(outputDir + "helpText.md");
@ -294,8 +303,7 @@ namespace AspectedRouting
if (!testsOk)
{
Console.WriteLine("Some tests failed, quitting now without generating output");
return;
return "Some tests failed, quitting now without generating output";
}
foreach (var (profile, profileTests) in profiles)
@ -318,7 +326,13 @@ namespace AspectedRouting
aspectTests,
profileTests.Where(testsSuite => testsSuite.BehaviourName == behaviourName)
).ToLua();
File.WriteAllText($"{outputDir}/itinero2/{profile.Name}.{behaviourName}.lua", lua2behaviour);
if(!Directory.Exists($"{outputDir}/itinero2/"))
{
Directory.CreateDirectory($"{outputDir}/itinero2/");
}
File.WriteAllText(
$"{outputDir}/itinero2/{profile.Name}.{behaviourName}.lua",
lua2behaviour);
}
}
@ -336,6 +350,7 @@ namespace AspectedRouting
{
Console.WriteLine("Not starting REPL as --no-repl is specified");
}
return null;
}
}
}
}

View file

@ -1,20 +0,0 @@
{
"name": "bicycle.network_by_operator",
"description": "The 'bicycle.network_score' returns true if the way is part of a cycling network of a certain (group of) operators",
"$memberOf": {
"$mustMatch": {
"type": "route",
"route": "bicycle",
"operator": {
"$containedIn": "#networkOperator"
},
"#": {
"note": "This block is commented out. A lot of networks we want to perform route planning on, are still proposed",
"state": {
"$not": "proposed"
}
}
}
}
}

View file

@ -1,12 +0,0 @@
{
"name": "bicycle.network_is_bicycle_network",
"description": "The 'bicycle.network_score' returns true if the way is part of a cycling network",
"$memberOf": {
"$mustMatch": {
"type": "route",
"route": "bicycle",
"state": {"$notEq": "proposed"}
}
}
}

View file

@ -1,13 +0,0 @@
{
"name": "bicycle.network_is_cyclehighway",
"description": "Returns true if the highway is part of a [cycle highway](https://wiki.openstreetmap.org/wiki/Tag:cycle_network%3Dcycle_highway)",
"$memberOf": {
"$mustMatch": {
"type": "route",
"route": "bicycle",
"state": {"$not": "proposed"},
"cycle_network": "cycle_highway"
}
}
}

View file

@ -1,21 +0,0 @@
{
"name":"speedPedelec.access_be",
"description": "Describes where a speedpedelec (moped_p) can and can not go. This is quite different from a normal bike",
"$default":"no",
"value":{
"$firstMatchOf":["access","speed_pedelec","designation"],
"mapping":{
"access":{
"no":"no"
},
"speed_pedelec":{
"no":"no",
"yes":"yes",
"designated":"designated"
},
"designation":{
"towpath":"no"
}
}
}
}

View file

@ -1,173 +0,0 @@
{
"name": "bicycle",
"description": "Profile for a normal bicycle",
"vehicletypes": [
"vehicle",
"bicycle"
],
"metadata": [
"name",
"bridge",
"tunnel",
"colour",
"cycle_network_colour",
"cycle_network_ref",
"ref",
"status",
"network"
],
"access": "$bicycle.legal_access",
"oneway": "$bicycle.oneway",
"speed": {
"$max": [
"$ferry_speed",
{
"$min": [
"$legal_maxspeed_be",
"#maxspeed",
{
"$multiply": [
"#defaultSpeed",
"$bicycle.speed_factor"
]
}
]
}
]
},
"priority": {
"#comfort": "$bicycle.comfort",
"#safety": "$bicycle.safety",
"#operatorNetworkScore": "$bicycle.network_by_operator",
"#cycleHighwayNetworkScore": "$bicycle.network_is_cyclehighway",
"#nodeNetworkScore": "$bicycle.network_is_nodenetwork",
"#bicycleNetworkScore": "$bicycle.network_is_bicycle_network",
"#timeNeeded": "$speed",
"#distance": "$distance",
"#trespassingPenalty": "$clean_permission_score",
"#leastSafetyPenalty": {
"$multiply": [
"$speed",
{
"$atleast": "#leastSafetyRequired",
"f": "$bicycle.safety",
"then": 0,
"else": -1
}
]
}
},
"defaults": {
"#defaultSpeed": 15,
"#maxspeed": 30,
"#timeNeeded": 0,
"#distance": 0,
"#comfort": 0,
"#safety": 0,
"#operatorNetworkScore": 0,
"#networkOperator": [],
"#cycleHighwayNetworkScore": 0,
"#nodeNetworkScore": 0,
"#bicycleNetworkScore": 0,
"#trespassingPenalty": 15,
"#": "This is not a priority weight, but rather a kind of access restriction. If 'leastafety' is not met, a huge penalty is applied, namely #leastSafetyPenalty. Note: 0.1 is the safety level of a primary without cycle highway",
"#leastSafetyRequired": 0.11,
"#leastSafetyPenalty": 0
},
"behaviours": {
"fastest": {
"description": "The fastest route to your destination",
"#timeNeeded": 1,
"#leastSafetyPenalty": 2
},
"shortest": {
"description": "The shortest route, independent of of speed",
"#distance": 1,
"#leastSafetyPenalty": 2
},
"safety": {
"description": "A defensive route shying away from big roads with lots of cars",
"#safety": 1
},
"comfort": {
"description": "A comfortable route preferring well-paved roads, smaller roads and a bit of scenery at the cost of speed",
"#comfort": 1,
"#leastSafetyPenalty": 2
},
"comfort_safety": {
"description": "A route which aims to be both safe and comfortable at the cost of speed",
"#comfort": 1,
"#safety": 1
},
"electrical.fastest": {
"description": "A profile for a bike with an electrical motor where the engine doesn't go faster then 25km/h (thus NOT the speed-pedelec). This is a variation of the normal fastest, but with a faster default speed. As the maxspeed is 30, it'll resemble shortest a bit more on 'normal' streets and will penalize slower roads more",
"#defaultSpeed": 23,
"#maxspeed": 30,
"#timeNeeded": 1,
"#leastSafetyPenalty": 2
},
"networks": {
"description": "A recreative route following any existing cycling network. Might make a few detours",
"#bicycleNetworkScore": 3,
"#safety": 1
},
"brussels": {
"description": "A route preferring the cycling network by operator 'Brussels Mobility'",
"#operatorNetworkScore": 5,
"#networkOperator": [
"Brussels Mobility"
],
"#comfort": 1,
"#safety": 1
},
"genk": {
"description": "A route preferring the cycling network by operator 'Stad Genk'",
"#operatorNetworkScore": 50,
"#networkOperator": [
"Stad Genk"
],
"#safety": 0.1
},
"cycle_highway": {
"description": "A route preferring the 'cycle-highways'. On non-cycleways, fastest is used (with a very low factor) in order to make sure the behaviour there is defined ",
"#cycleHighwayNetworkScore": 20,
"#timeNeeded": 0.1,
"#leastSafetyPenalty": 2
},
"node_network": {
"description": "A route following the recreational node network. Might make detours",
"#nodeNetworkScore": 10,
"#safety": 1
},
"commute": {
"description": "A route for a daily commuter, prefers the 'cycle-highways' or the cycling network by operator 'Brussels Mobility', with a pinch of safety and comfort",
"#operatorNetworkScore": 3,
"#networkOperator": [
"Brussels Mobility"
],
"#cycleHighwayNetworkScore": 3,
"#timeNeeded": 1,
"#comfort": 2,
"#safety": 3
},
"b2w": {
"description": "[Custom][Private] Route specifically for Bike2Work. Same as commute at this moment. A route preferring the 'cycle-highways' or the cycling network by operator 'Brussels Mobility'",
"#operatorNetworkScore": 3,
"#networkOperator": [
"Brussels Mobility"
],
"#cycleHighwayNetworkScore": 3,
"#timeNeeded": 1,
"#comfort": 2,
"#safety": 3
},
"anyways.network": {
"description": "[Private][Internal use] A route using the Anyways branded network; mainly used in ShortCut/Impact",
"#timeNeeded": 1,
"#operatorNetworkScore": 10,
"#networkOperator": [
"Anyways"
]
}
}
}

View file

@ -1,46 +0,0 @@
{
"name":"speedPedelec",
"description":"A vehicle specifically for speed pedelec (aka Moped P) with Belgian legislation in mind. A speed pedelec is a kind of electrical bike with a maxspeed of 45km/h. Due to the high speed, this is considered a kind of moped or motorcycle for belgian law. Sources for more information are [speedpedelecVlaanderen.be](https://speedpedelecvlaanderen.be/infrastructuur-en-regelgeving/wegcode/relevante-verkeersborden/), [Fietsersbond](https://www.fietsersbond.be/speedpedelec)",
"defaults":{
"#defaultSpeed": 25,
"#maxspeed":45,
"#distance":0
},
"vehicletypes":["vehicle","motor_vehicle","moped_p"],
"metadata": [
"name",
"bridge",
"tunnel",
"colour",
"cycle_network_colour",
"ref",
"status",
"network"
],
"behaviours":{
"shortest":{
"description":"The shortest path",
"#distance":1
}
},
"speed":{
"$min":
[
"#maxspeed",
"$legal_maxspeed_be",
{
"$multiply": [
"#defaultSpeed",
"$bicycle.speed_factor"
]
}
]
},
"access":"$speedPedelec.access_be",
"oneway":"$bicycle.oneway",
"priority":{
"#distance": 1
}
}

View file

@ -1,5 +0,0 @@
access,oneway,speed,priority,highway,_relation:bicycle.network_by_operator
no,both,0,0,,
yes,both,15,1.9,residential,
yes,both,15,6.9,residential,yes
dismount,both,2.25,0.1995,footway,
1 access oneway speed priority highway _relation:bicycle.network_by_operator
2 no both 0 0
3 yes both 15 1.9 residential
4 yes both 15 6.9 residential yes
5 dismount both 2.25 0.1995 footway

View file

@ -1,6 +0,0 @@
access,oneway,speed,priority,highway,_relation:bicycle.network_by_operator,_relation:bicycle.network_is_cyclehighway
no,,,,,,
yes,both,15,19.7,residential,,
yes,both,15,22.7,residential,yes,
yes,both,15,22.7,residential,,yes
yes,both,15,25.7,residential,yes,yes
1 access oneway speed priority highway _relation:bicycle.network_by_operator _relation:bicycle.network_is_cyclehighway
2 no
3 yes both 15 19.7 residential
4 yes both 15 22.7 residential yes
5 yes both 15 22.7 residential yes
6 yes both 15 25.7 residential yes yes

View file

@ -1,4 +0,0 @@
access,oneway,speed,priority,highway,_relation:bicycle.network_score
no,,,,,
designated,both,15,2,cycleway,
designated,both,15,22,cycleway,yes
1 access oneway speed priority highway _relation:bicycle.network_score
2 no
3 designated both 15 2 cycleway
4 designated both 15 22 cycleway yes

View file

@ -1,6 +0,0 @@
access,oneway,speed,priority,highway,_relation:bicycle.is_cycle_highway
no,,,,,
designated,both,15,1.5,cycleway,
designated,both,15,22,cycleway,yes
yes,both,15,1.5,tertiary,
,,, ,,
1 access oneway speed priority highway _relation:bicycle.is_cycle_highway
2 no
3 designated both 15 1.5 cycleway
4 designated both 15 22 cycleway yes
5 yes both 15 1.5 tertiary
6

View file

@ -1,9 +0,0 @@
access,oneway,speed,priority,highway,_relation:bicycle.network_by_operator
no,both,0,0,,
yes,both,15,0.09,residential,
yes,both,15,50.09,residential,yes
dismount,both,2.25,0.019,footway,
yes,both,15,50.09,residential,yes
designated,both,15,50.15,cycleway,yes
yes,both,15,0.09,residential,no
designated,both,15,0.15,cycleway,no
1 access oneway speed priority highway _relation:bicycle.network_by_operator
2 no both 0 0
3 yes both 15 0.09 residential
4 yes both 15 50.09 residential yes
5 dismount both 2.25 0.019 footway
6 yes both 15 50.09 residential yes
7 designated both 15 50.15 cycleway yes
8 yes both 15 0.09 residential no
9 designated both 15 0.15 cycleway no

View file

@ -1,24 +0,0 @@
{
"name": "pedestrian.slow_road_preference",
"description": "Gives a value between 0 and 2, indicating how lovely a path or track is to walk over. It'll prefer roads with less car-pressure",
"unit": "0: absolutely horrible to walk, 2: absolutely lovely",
"$default": 1,
"value": {
"$multiply": [
{
"highway": {
"pedestrian": 2,
"living_street": 1.5,
"footway": 1.8,
"path": 1.2
}
},
{
"access": {
"destination": 1.5,
"no": 1.5
}
}
]
}
}

View file

@ -1,19 +0,0 @@
{
"name": "rollerskate.can_access",
"description": "Determines if it is possible to skate (or at least pass) over a certain way",
"$default": "no",
"value": {
"highway": {
"residential": "yes",
"service": "yes",
"tertiary": "yes",
"tertiary_link": "yes",
"secondary": "yes",
"secondary_link": "yes",
"cycleway": "yes",
"footway": "yes",
"unclassified": "yes",
"living_street":"yes"
}
}
}

View file

@ -1,38 +0,0 @@
{
"name": "rollerskate.comfort",
"description": "How smooth is this road, on a factor 0 (horrible) to 1 (excellent)?",
"$default": 0.3,
"value": {
"$firstMatchOf": [
"highway",
"smoothness",
"surface",
"sidewalk:surface"
],
"value": {
"highway": {
"primary": 0.2,
"secondary": 0.2
},
"smoothness": {
"excellent": 1,
"very_good": 0.95,
"good": 0.75,
"intermediate": 0.5,
"bad": 0.1
},
"surface": {
"asphalt": 0.7,
"concrete": 0.7,
"paving_stones": 0.65,
"sett": 0.01
},
"sidewalk:surface": {
"asphalt": 0.7,
"concrete": 0.7,
"paving_stones": 0.65,
"sett": 0.01
}
}
}
}

View file

@ -1,32 +0,0 @@
{
"name": "rollerskate",
"description": "Tries to find a suitable way to rollerskate somewhere. Uses mostly smoothness and surface to determine where to go",
"access": "$rollerskate.can_access",
"oneway": "both",
"speed": {
"$multiply": [
"#defaultSpeed",
"$rollerskate.comfort"
]
},
"priority": {
"#speedFactor": "$speed"
},
"behaviours": {
"fastest": {
"description": "The fastest (and thus smoothest) route",
"#speedFactor": 1
}
},
"defaults": {
"#defaultSpeed": 20,
"#speedFactor": 0
},
"vehicletypes": [
"vehicle",
"rollerskate"
],
"metadata": [
"name"
]
}