internal void AddProfileToList(ProfileSession profile) { bool isAddToGraphics = false; isAddToGraphics = View.AddNodeToTreeView(profile); //Add Profile to the working list _workingProfiles.Add(profile); //Add graphics if (isAddToGraphics) { var spatialReference = ArcMap.Document.FocusMap.SpatialReference; if (profile.DefinitionType == ProfileSettingsTypeEnum.Primitives) { profile.Segments = ProfileLinesConverter.GetSegmentsFromProfileLine(profile.ProfileSurfaces, spatialReference); GraphicsLayerManager.AddLinesToWorkingGraphics(ProfileLinesConverter.ConvertLineToPrimitivePolylines(profile.ProfileSurfaces[0], spatialReference), profile.SessionId, profile.Segments.First()); } else { profile.SetSegments(spatialReference); GraphicsLayerManager.AddLinesToWorkingGraphics(ProfileLinesConverter.ConvertSolidGroupedLinesToEsriPolylines(profile.Segments, spatialReference), profile.SessionId); } } GraphicsLayerManager.EmptyProfileGraphics(MilSpaceGraphicsTypeEnum.Calculating); }
/// <summary> /// Do Actions to generate profile(s), save them and set properties to default values /// </summary> /// <returns>Profile Session data</returns> internal ProfileSession GenerateProfile() { string errorMessage; try { ProfileManager manager = new ProfileManager(); var profileSetting = profileSettings[View.SelectedProfileSettingsType]; var newProfileId = GenerateProfileId(); logger.InfoEx($"Profile {newProfileId}. Generation started"); var newProfileName = GenerateProfileName(newProfileId); var session = manager.GenerateProfile(profileSetting.DemLayerName, profileSetting.ProfileLines, View.SelectedProfileSettingsType, newProfileId, newProfileName, View.ObserveHeight, profileSetting.AzimuthToStore); logger.InfoEx($"Profile {newProfileId}. Generated"); if (session.DefinitionType == ProfileSettingsTypeEnum.Primitives) { session.Segments = ProfileLinesConverter.GetSegmentsFromProfileLine(session.ProfileSurfaces, ArcMap.Document.FocusMap.SpatialReference); } else { session.SetSegments(ArcMap.Document.FocusMap.SpatialReference); } SetPeofileId(); SetProfileName(); return(session); } catch (MilSpaceCanotDeletePrifileCalcTable ex) { //TODO Localize error message errorMessage = ex.Message; } catch (MilSpaceDataException ex) { //TODO Localize error message errorMessage = ex.Message; } catch (Exception ex) { //TODO log error //TODO Localize error message errorMessage = ex.Message; } MessageBox.Show(errorMessage); return(null); }
internal void CallGraphsHandle(int profileSessionId) { var profileSession = GetProfileSessionById(profileSessionId); if (profileSession != null) { if (_workingProfiles.FirstOrDefault(profile => profile.SessionId == profileSession.SessionId) != null) { _workingProfiles.Remove(_workingProfiles.FirstOrDefault(profile => profile.SessionId == profileSession.SessionId)); } _workingProfiles.Add(profileSession); if (profileSession.DefinitionType == ProfileSettingsTypeEnum.Primitives) { profileSession.Segments = ProfileLinesConverter.GetSegmentsFromProfileLine(profileSession.ProfileSurfaces, ArcMap.Document.FocusMap.SpatialReference); } else { profileSession.SetSegments(ArcMap.Document.FocusMap.SpatialReference); } CallGraphsHandle(profileSession); } }
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); }