public override string Process(SrtmDataset dataset, string folder) { var filePath = $@"{folder}\height.png"; try { string[] filePaths = Directory.GetFiles(@"C:\diplom\EMS.net\EMS\Services\CharacterizationService\CharacterizationService\Content"); File.Copy(filePaths.Where(x => x.Contains("heigth_legend.png")).First(), folder + "\\heigth_legend.png"); } catch (Exception e) { Console.WriteLine("Файл уже существует"); } // using (var result = DrawLib.CreateImageWithLegend(dataset.Width, dataset.Heigth, @"..\..\Content\heigth.png")) using (var result = new Bitmap(dataset.Width, dataset.Heigth)) { for (var x = 1; x < dataset.Width - 1; x++) { for (var y = 1; y < dataset.Heigth - 1; y++) { var value = dataset.Values[x, y]; result.SetPixel(x, y, GetColor(value)); } } result.Save(filePath, ImageFormat.Png); } return(filePath); }
public override string[] Process(IGeographicPoint leftUpper, IGeographicPoint rigthLower, string dataFolder, string resultFolder) { var dataset = new SrtmDataset(leftUpper, rigthLower, dataFolder); var filePaths = new List <string>(); foreach (var processor in _processors) { filePaths.Add(processor.Process(dataset, resultFolder)); } return(filePaths.ToArray()); }
public override string Process(SrtmDataset dataset, string folder) { var filePath = $@"{folder}\exposition.png"; try { string[] filePaths = Directory.GetFiles(@"C:\diplom\EMS.net\EMS\Services\CharacterizationService\CharacterizationService\Content"); File.Copy(filePaths.Where(x => x.Contains("exposition_legend.png")).First(), folder + "\\exposition_legend.png"); } catch (Exception e) { Console.WriteLine("Файл уже существует"); } // using (var result = DrawLib.CreateImageWithLegend(dataset.Width, dataset.Heigth, @"..\..\Content\exposition.png")) using (var result = new Bitmap(dataset.Width, dataset.Heigth)) { for (var x = 1; x < dataset.Width - 1; x++) { for (var y = 1; y < dataset.Heigth - 1; y++) { var a = (double?)dataset.Values[x - 1, y - 1]; var b = (double?)dataset.Values[x, y - 1]; var c = (double?)dataset.Values[x + 1, y - 1]; var d = (double?)dataset.Values[x - 1, y]; var f = (double?)dataset.Values[x + 1, y]; var g = (double?)dataset.Values[x - 1, y + 1]; var h = (double?)dataset.Values[x, y + 1]; var i = (double?)dataset.Values[x + 1, y + 1]; Color color; if (a.HasValue && b.HasValue && c.HasValue && d.HasValue && f.HasValue && g.HasValue && h.HasValue && i.HasValue) { var aspect = GetAspect(a.Value, b.Value, c.Value, d.Value, f.Value, g.Value, h.Value, i.Value); color = GetColor(aspect); } else { color = Color.Black; } result.SetPixel(x, y, color); } } result.Save(filePath, ImageFormat.Png); } return(filePath); }
/// <summary> /// Обработка характеристики /// </summary> /// <param name="dataset">Данные</param> /// <param name="folder"></param> public abstract string Process(SrtmDataset dataset, string folder);