public IEnumerable <IPolyline> ConvertLinesToEsriPolypile(ISpatialReference spatialReference, int lineId = -1) { Func <ProfileLine, IPolyline> converter = (l) => { var pointFrom = new Point { X = l.PointFrom.X, Y = l.PointFrom.Y, SpatialReference = EsriTools.Wgs84Spatialreference }; var pointTo = new Point { X = l.PointTo.X, Y = l.PointTo.Y, SpatialReference = EsriTools.Wgs84Spatialreference }; pointFrom.Project(spatialReference); pointTo.Project(spatialReference); var result = EsriTools.CreatePolylineFromPoints(pointFrom, pointTo); if (l.Line == null) { l.Line = result; } return(result); }; if (lineId < 0 || lineId >= ProfileLines.Length) { return(ProfileLines.Select(l => converter(l)).ToArray()); } return(new IPolyline[] { converter(ProfileLines[lineId]) }); }
public static List <IntersectionLine> ConvertEsriPolylineToIntersectionLines(List <IPolyline> polylines, ProfilePoint pointFrom, LayersEnum layer, double distance) { var id = 0; var fromPoint = new Point { X = pointFrom.X, Y = pointFrom.Y, SpatialReference = EsriTools.Wgs84Spatialreference }; return(polylines.Select(line => { id++; fromPoint.Project(line.SpatialReference); var fromLength = EsriTools.CreatePolylineFromPoints(fromPoint, line.FromPoint).Length; var toLength = EsriTools.CreatePolylineFromPoints(fromPoint, line.ToPoint).Length; double startDistance = (fromLength < toLength) ? fromLength : toLength; double endDistance = (fromLength > toLength) ? fromLength : toLength; return new IntersectionLine() { PointFromDistance = startDistance + distance, PointToDistance = endDistance + distance, LayerType = layer }; } ).ToList()); }
private void SetSettings(ProfileSettingsTypeEnum profileType, int profileIdValue) { List <IPolyline> profileLines = new List <IPolyline>(); var profileSetting = profileSettings[profileType]; if (profileSetting == null) { profileSetting = new ProfileSettings(); } //Check if the View.DemLayerName if Layer name profileSetting.DemLayerName = View.DemLayerName; if (profileType == ProfileSettingsTypeEnum.Points) { var line = EsriTools.CreatePolylineFromPoints(pointsToShow[ProfileSettingsPointButtonEnum.PointsFist], pointsToShow[ProfileSettingsPointButtonEnum.PointsSecond]); if (line != null) { profileLines.Add(line); } } if (View.SelectedProfileSettingsType == ProfileSettingsTypeEnum.Fun) { try { var lines = EsriTools.CreatePolylinesFromPointAndAzimuths(pointsToShow[ProfileSettingsPointButtonEnum.CenterFun], View.FunLength, View.FunLinesCount, View.FunAzimuth1, View.FunAzimuth2); if (lines != null) { profileLines.AddRange(lines); } } catch (MilSpaceProfileLackOfParameterException ex) { //TODO: Wtite log MessageBox.Show(ex.Message, "MilSpace", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { //TODO: Wtite log } } profileSetting.ProfileLines = profileLines.ToArray(); profileSettings[profileType] = profileSetting; InvokeOnProfileSettingsChanged(); GraphicsLayerManager.UpdateCalculatingGraphic(profileSetting.ProfileLines, profileIdValue, (int)profileType); }
internal IEnumerable <IPolyline> GetProfileLines() { if (View.SelectedProfileSettingsType == ProfileSettingsTypeEnum.Points) { return(new IPolyline[] { EsriTools.CreatePolylineFromPoints(pointsToShow[ProfileSettingsPointButtonEnum.PointsFist], pointsToShow[ProfileSettingsPointButtonEnum.PointsSecond]) }); } if (View.SelectedProfileSettingsType == ProfileSettingsTypeEnum.Fun) { return(EsriTools.CreatePolylinesFromPointAndAzimuths(pointsToShow[ProfileSettingsPointButtonEnum.CenterFun], View.FunLength, View.FunLinesCount, View.FunAzimuth1, View.FunAzimuth2)); } return(null); }
public void AddLineSegmentToMap(IPoint pointFrom, IPoint pointTo, string name, string fromPointGuid) { var color = (IRgbColor) new RgbColorClass() { Green = 255 }; var polyline = EsriTools.CreatePolylineFromPoints(pointFrom, pointTo); var segmentName = name + "_" + fromPointGuid + geoCalcPointsSuffix; var ge = new GraphicElement() { Source = polyline, Name = segmentName }; AddPolyline(ge, MilSpaceGraphicsTypeEnum.GeoCalculator, color, LineType.Line, true, true); }
public static List <IPolyline> ConvertLineToEsriPolyline(List <ProfileLine> profileLines, ISpatialReference spatialReference) { return(profileLines.Select(l => { var pointFrom = new Point { X = l.PointFrom.X, Y = l.PointFrom.Y, SpatialReference = EsriTools.Wgs84Spatialreference }; var pointTo = new Point { X = l.PointTo.X, Y = l.PointTo.Y, SpatialReference = EsriTools.Wgs84Spatialreference }; pointFrom.Project(spatialReference); pointTo.Project(spatialReference); return EsriTools.CreatePolylineFromPoints(pointFrom, pointTo); } ).ToList()); }
public IEnumerable <IPolyline> ConvertLinesToEsriPolypile(ISpatialReference spatialReference) { return(ProfileLines.Select(l => { var pointFrom = new Point { X = l.PointFrom.X, Y = l.PointFrom.Y, SpatialReference = EsriTools.Wgs84Spatialreference }; var pointTo = new Point { X = l.PointTo.X, Y = l.PointTo.Y, SpatialReference = EsriTools.Wgs84Spatialreference }; pointFrom.Project(spatialReference); pointTo.Project(spatialReference); return EsriTools.CreatePolylineFromPoints(pointFrom, pointTo); } ).ToArray()); }
public IEnumerable <IPolyline> ConvertLinesToEsriPolypile(ISpatialReference spatialReference, int lineId = -1) { Func <ProfileLine, IPolyline> converter = (l) => { var surface = ProfileSurfaces.FirstOrDefault(s => l.Id == s.LineId); IPolyline result; if (DefinitionType == ProfileSettingsTypeEnum.Primitives && surface != null) { var vertices = surface.ProfileSurfacePoints.Where(point => point.isVertex).Select(p => new Point { X = p.X, Y = p.Y, Z = p.Z, SpatialReference = EsriTools.Wgs84Spatialreference }); result = EsriTools.CreatePolylineFromPointsArray(vertices.ToArray(), spatialReference).First(); } else { var pointFrom = new Point { X = l.PointFrom.X, Y = l.PointFrom.Y, SpatialReference = EsriTools.Wgs84Spatialreference }; var pointTo = new Point { X = l.PointTo.X, Y = l.PointTo.Y, SpatialReference = EsriTools.Wgs84Spatialreference }; pointFrom.Project(spatialReference); pointTo.Project(spatialReference); result = EsriTools.CreatePolylineFromPoints(pointFrom, pointTo); } if (l.Line == null) { l.Line = result; } return(result); }; if (lineId <= 0 || lineId > ProfileLines.Length) { return(ProfileLines.Select(l => converter(l)).ToArray()); } return(new IPolyline[] { converter(ProfileLines.First(l => l.Id == lineId)) }); }
private static List <IPolyline> SeparatePrimitives(IEnumerable <ProfileSurfacePoint> vertices, ISpatialReference spatialReference) { var verticesArray = vertices.ToArray(); var polylines = new List <IPolyline>(); for (int i = 0; i < vertices.Count() - 1; i++) { var pointFrom = new Point { X = verticesArray[i].X, Y = verticesArray[i].Y, Z = verticesArray[i].Z, SpatialReference = EsriTools.Wgs84Spatialreference }; var pointTo = new Point { X = verticesArray[i + 1].X, Y = verticesArray[i + 1].Y, Z = verticesArray[i + 1].Z, SpatialReference = EsriTools.Wgs84Spatialreference }; pointFrom.Project(spatialReference); pointTo.Project(spatialReference); polylines.Add(EsriTools.CreatePolylineFromPoints(pointFrom, pointTo)); } return(polylines); }
public void AddCrossPointerToPoint(IPoint point, int length, string name) { int segmentLength; int segmentCount = 5; var color = grapchucsTypeColors[MilSpaceGraphicsTypeEnum.Visibility](); var delta = EsriTools.GetNorthDirrection(point) - 90; var angels = new double[] { delta, 90 + delta, 180 + delta, 270 + delta }; var fromPoints = new IPoint[] { point, point, point, point, }; decimal segments; if (length % 5 != 0) { segments = length / 4; } else { segments = length / 5; } segmentLength = Convert.ToInt32(Math.Round(segments, 0)); if (segmentLength >= 100) { segmentLength = segmentLength / 100 * 100; } else if (segmentLength >= 10) { segmentLength = segmentLength / 10 * 10; } for (int i = 1; i <= segmentCount; i++) { double segEndPointDistance = segmentLength * i; int j = 0; foreach (var angel in angels) { double radian = (90 + angel) * (Math.PI / 180); var toPoint = EsriTools.GetPointFromAngelAndDistance(point, radian, segEndPointDistance); var line = EsriTools.CreatePolylineFromPoints(fromPoints[j], toPoint); var segmentName = name + "_" + j + "_" + i; var ge = new GraphicElement() { Source = line, Name = segmentName }; if (j == 0 && i == segmentCount) { AddPolyline(ge, MilSpaceGraphicsTypeEnum.Visibility, color, LineType.Arrow, true, true, 1); } else { AddPolyline(ge, MilSpaceGraphicsTypeEnum.Visibility, color, LineType.Cross, true, true, 1); } fromPoints[j++] = toPoint.Clone(); } } var markPoint = EsriTools.GetPointFromAngelAndDistance(point, 0, segmentLength); DrawText(markPoint, segmentLength.ToString(), $"text_{name}", MilSpaceGraphicsTypeEnum.Visibility, color, 9, 1); }
private void CalcIntesectionsWithLayers(ProfileLine selectedLine, ProfileSession profileSession) { var allIntersectionLines = new List <IntersectionsInLayer>(); var layers = View.GetLayers(); var spatialReference = ArcMap.Document.FocusMap.SpatialReference; List <IPolyline> polylines; List <ProfilePoint> pointsFrom; profileSession.Layers = new List <string>(); if (selectedLine == null) { return; } if (selectedLine.Line.SpatialReference != spatialReference) { selectedLine.Line.Project(spatialReference); } var lineSurface = profileSession.ProfileSurfaces.First(surface => surface.LineId == selectedLine.Id); var profileSegment = profileSession.Segments.First(segment => segment.LineId == selectedLine.Id); var distance = 0.0; if (profileSegment.IsPrimitive) { polylines = ProfileLinesConverter.ConvertLineToPrimitivePolylines(lineSurface, selectedLine.Line.SpatialReference); pointsFrom = profileSegment.Vertices; } else { polylines = new List <IPolyline> { selectedLine.Line }; pointsFrom = new List <ProfilePoint> { selectedLine.PointFrom }; } int j = 0; for (int n = 0; n < polylines.Count; n++) { var intersectionLines = new List <IntersectionsInLayer>(); for (int i = 0; i < layers.Count; i++) { if (!string.IsNullOrEmpty(layers[i])) { var layer = EsriTools.GetLayer(layers[i], ArcMap.Document.FocusMap); var lines = EsriTools.GetIntersections(polylines[n], layer); var layerFullName = $"Path/{layer.Name}"; if (!profileSession.Layers.Exists(sessionLayer => sessionLayer == layerFullName)) { profileSession.Layers.Add(layerFullName); } if (lines != null && lines.Count() > 0) { var layerType = (LayersEnum)Enum.GetValues(typeof(LayersEnum)).GetValue(i); var intersectionLine = new IntersectionsInLayer { Lines = ProfileLinesConverter.ConvertEsriPolylineToIntersectionLines(lines, pointsFrom[j], layerType, distance), Type = layerType, }; intersectionLine.SetDefaultColor(); intersectionLines.Add(intersectionLine); SetLayersForPoints(intersectionLine, lineSurface); } } } allIntersectionLines.AddRange(intersectionLines); if (polylines.Count > 1) { j++; if (n < polylines.Count - 1) { distance += EsriTools.CreatePolylineFromPoints(polylines[n].FromPoint, polylines[n + 1].FromPoint).Length; } } } graphsController.SetIntersections(allIntersectionLines, selectedLine.Id); }