LeafGasComparison extract single curve for optimization
This commit is contained in:
@@ -32,9 +32,7 @@ namespace LeafWeb.Web.Controllers
|
||||
|
||||
try
|
||||
{
|
||||
var curveData = GetCurveData(leafOutputFile.Contents);
|
||||
|
||||
var curveIds = curveData.Select(c => c.CurveId).ToList();
|
||||
var curveIds = GetCurveIds(leafOutputFile.Contents);
|
||||
|
||||
var viewModel = new ChartViewModel
|
||||
{
|
||||
@@ -64,14 +62,12 @@ namespace LeafWeb.Web.Controllers
|
||||
if (leafOutputFile == null)
|
||||
throw new ArgumentOutOfRangeException(); // TODO: break
|
||||
|
||||
var curveData = GetCurveData(leafOutputFile.Contents);
|
||||
var curveData = GetCurveData(leafOutputFile.Contents, curveId);
|
||||
|
||||
var curveIdData = curveData.FirstOrDefault(c => c.CurveId == curveId);
|
||||
|
||||
if (curveIdData == null)
|
||||
if (curveData == null)
|
||||
return File("/Content/favicon/apple-icon-57x57.png", "image/png"); // TODO: different image ?
|
||||
|
||||
var charts = GetChartBitmaps(curveIdData).ToList();
|
||||
var charts = GetChartBitmaps(curveData).ToList();
|
||||
|
||||
var combinedChart = CombineBitmaps(charts);
|
||||
|
||||
@@ -85,13 +81,19 @@ namespace LeafWeb.Web.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
private CurveData[] GetCurveData(byte[] fileContents)
|
||||
private CurveData GetCurveData(byte[] fileContents, string curveId)
|
||||
{
|
||||
LeafGasComparison[] leafGasComparisons;
|
||||
using (var parser = new LeafGasComparisonParser(fileContents))
|
||||
leafGasComparisons = parser.Parse();
|
||||
leafGasComparisons = parser.Parse(curveId);
|
||||
|
||||
return CurveDataConverter.Convert(leafGasComparisons).ToArray();
|
||||
return CurveDataConverter.Convert(leafGasComparisons).First();
|
||||
}
|
||||
|
||||
private string[] GetCurveIds(byte[] fileContents)
|
||||
{
|
||||
using (var parser = new LeafGasComparisonParser(fileContents))
|
||||
return parser.ExtractCurveIds();
|
||||
}
|
||||
|
||||
private IEnumerable<Bitmap> GetChartBitmaps(CurveData curveData)
|
||||
|
||||
Reference in New Issue
Block a user