Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit a8c8c5ef authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

bugfix: WHTC correction factor

error in testcase: wrong order of arguments
error in parsing declaration data: wrong order of rows (urban/rural/motorway vs. rural/urban/motorway)
fix: corrected parsing declaration data
fix: corrected testcase
additional testcases
...@@ -62,7 +62,7 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -62,7 +62,7 @@ namespace TUGraz.VectoCore.Models.Declaration
NormalizeTable(table); NormalizeTable(table);
foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) { foreach (MissionType mission in Enum.GetValues(typeof(MissionType))) {
var values = table.Columns[mission.ToString().ToLower()].Values<string>().ToDouble().ToArray(); var values = table.Columns[mission.ToString().ToLower()].Values<string>().ToDouble().ToArray();
_data[mission] = new WHTCCorrectionEntry { Rural = values[0], Urban = values[1], Motorway = values[2] }; _data[mission] = new WHTCCorrectionEntry { Urban = values[0], Rural = values[1], Motorway = values[2] };
} }
} }
......
...@@ -124,12 +124,42 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration ...@@ -124,12 +124,42 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration
var urban = r.NextDouble() * 2; var urban = r.NextDouble() * 2;
var rural = r.NextDouble() * 2; var rural = r.NextDouble() * 2;
var motorway = r.NextDouble() * 2; var motorway = r.NextDouble() * 2;
var whtcValue = whtc.Lookup(Missions[i], urban, rural, motorway); var whtcValue = whtc.Lookup(Missions[i], rural: rural, urban: urban, motorway: motorway);
Assert.AreEqual(urban * factors.urban[i] + rural * factors.rural[i] + motorway * factors.motorway[i], Assert.AreEqual(urban * factors.urban[i] + rural * factors.rural[i] + motorway * factors.motorway[i],
whtcValue); whtcValue);
} }
} }
[TestMethod]
public void WHTCLookupTestLongHaul()
{
var expected = 1.015501;
var rural = 1.0265;
var urban = 1.0948;
var motorway = 1.0057;
var lookup = DeclarationData.WHTCCorrection.Lookup(MissionType.LongHaul, rural: rural, urban: urban,
motorway: motorway);
Assert.AreEqual(expected, lookup, 1e-8);
}
[TestMethod]
public void WHTCLookupTestRegionalDelivery()
{
var expected = 1.02708700;
var rural = 1.0265;
var urban = 1.0948;
var motorway = 1.0057;
var lookup = DeclarationData.WHTCCorrection.Lookup(MissionType.RegionalDelivery, rural: rural, urban: urban,
motorway: motorway);
Assert.AreEqual(expected, lookup, 1e-8);
}
[TestMethod] [TestMethod]
public void AirDragTest() public void AirDragTest()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment