private void OpenSection(Section section) { SectionReadWindow sectionReadWindow = new SectionReadWindow(section, true); sectionReadWindow.ShowDialog(); }
private void DoAnalize(FileButton <Profile> butt) { SectionReadWindow sectionReadWindow = new SectionReadWindow(butt.File.ProfSection, false); sectionReadWindow.ShowDialog(); Kml file = (Kml)butt.File.ProfKmlFile.Root; List <Placemark> lineList = new List <Placemark>(); ExtractPlacemarks(file.Feature, lineList); LineString line = new LineString(); try { line = lineList.Single().Geometry as LineString; } catch { MessageBox.Show("Kml nie spełnia wymogów profilu. Należy wczytać plik zawierający jedną linię."); } List <Coord.Vector> points = new List <Coord.Vector>(); foreach (Coord.Vector j in line.Coordinates) { points.Add(j); } Coord.Vector startCoord = points[0]; Coord.Vector endCoord = points[points.Count - 1]; List <System.Windows.Point> secPoints = sectionReadWindow.Points; List <Coord.Vector> vectors = new List <Coord.Vector>(); int pointsAmount = sectionReadWindow.Points.Count; double profLength = CoordinatesCalculator.CalculateDistance(startCoord.Latitude, startCoord.Longitude, endCoord.Latitude, endCoord.Longitude); double sectionLength = sectionReadWindow.LastPoint.X - sectionReadWindow.ZeroPoint.X; double scale = profLength / sectionLength; double maxDepth = sectionReadWindow.LastPoint.Y - sectionReadWindow.ZeroPoint.Y; double azimuth = CoordinatesCalculator.CalculateBearing(startCoord, endCoord); var pp = from t in secPoints orderby t.X ascending select t; secPoints = pp.ToList <System.Windows.Point>(); List <byte> depths = new List <byte>(); byte depth = new byte(); for (int i = 0; i < pointsAmount; i++) { depth = (byte)(secPoints[i].Y / maxDepth * 255); double dist; if (i == 0) { dist = secPoints[i].X * scale; vectors.Add(startCoord); depths.Add((byte)(sectionReadWindow.ZeroPoint.Y / maxDepth * 255)); } else { dist = (secPoints[i].X - secPoints[i - 1].X) * scale; } Coord.Vector vector = CoordinatesCalculator.CalculatePoint(vectors[vectors.Count - 1], dist, azimuth); vectors.Add(vector); depths.Add(depth); } vectors.RemoveAt(vectors.Count - 1); depths.RemoveAt(depths.Count - 1); vectors.RemoveAt(vectors.Count - 1); depths.RemoveAt(depths.Count - 1); vectors.Add(endCoord); depths.Add(depths[depths.Count - 1]); Document document = new Document(); document.Name = butt.File.Name + ".kml"; for (int i = 1; i < vectors.Count; i++) { AddSingleLineToContainer(vectors[i - 1], vectors[i], (byte)((depths[i] + depths[i - 1]) / 2), document, i); } List <Coord.Vector> markers = new List <Coord.Vector>(); foreach (var point in sectionReadWindow.Markers) { double dist = point.X * scale; Coord.Vector vector = CoordinatesCalculator.CalculatePoint(startCoord, dist, azimuth); markers.Add(vector); } int n = 1; foreach (var coord in markers) { AddMarkerToContainer(coord, document, n); n++; } Kml kml = new Kml(); kml.Feature = document; KmlFile kmlFile = KmlFile.Create(kml, true); AddToList(kmlFile); SaveKmls(kmlFile); FileButton <KmlFile> button = new FileButton <KmlFile>(kmlFile) { Height = 40, Margin = new Thickness(10, 5, 5, 10), Content = document.Name }; button.Click += OnOutFileButtonClick; OutStack.Children.Add(button); }