public static void ReadPolugon(this ImportSentinelData importProduct) { if (string.IsNullOrWhiteSpace(importProduct.Footprint)) { return; } string text = importProduct.Footprint; //"<gml:Polygon srsName=\"http://www.opengis.net/gml/srs/epsg.xml#4326\" xmlns:gml=\"http://www.opengis.net/gml\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>45.308281,24.306789 45.711151,21.006590 47.207355,21.359417 46.803715,24.750584 45.308281,24.306789</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>"; var doc = XDocument.Parse(text); var elem = doc.Descendants(XName.Get("coordinates", "http://www.opengis.net/gml")).Select(node => { var pointCollection = new MultipointClass(); node.Value.Split(' ').Select(p => { var coords = p.Split(','); return(new Point { X = coords[1].ParceToDouble(), Y = coords[0].ParceToDouble(), SpatialReference = EsriTools.Wgs84Spatialreference }); }).ToList().ForEach(p => pointCollection.AddPoint(p)); return(EsriTools.GetPolygonByPointCollection(pointCollection)); }); importProduct.FootprintPoly = elem.FirstOrDefault(); }
private static void SetFromMapRendererToFeatureLayer(IFeatureLayer featureLayer, IObjectFactory objFactory, string featureClassName) { MapLayersManager mapLayersManager = new MapLayersManager(_map); var layerName = mapLayersManager.GetLayerAliasByFeatureClass(featureClassName); if (!String.IsNullOrEmpty(layerName)) { var fromMapGeoFeatureLayer = EsriTools.GetLayer(layerName, _map.FocusMap) as IGeoFeatureLayer; if (fromMapGeoFeatureLayer == null) { _layersWithDefaultRenderer.Add(featureLayer.Name); return; } var geoFeatureLayer = featureLayer as IGeoFeatureLayer; try { Type renderType = typeof(SimpleRendererClass); string typeRenderID = renderType.GUID.ToString("B"); var objCopy = (IObjectCopy)objFactory.Create("esriSystem.ObjectCopy"); var rendereCopy = objCopy.Copy(fromMapGeoFeatureLayer.Renderer) as IFeatureRenderer; geoFeatureLayer.Renderer = rendereCopy; } catch (Exception ex) { _layersWithDefaultRenderer.Add(featureLayer.Name); logger.WarnEx($"Cannot set rendrer from map for {featureLayer.Name} layer. Exception: {ex.Message}"); } } }
internal static Dictionary <IPolygon, bool> GetVisibilityPolygons(IPoint observerPoint, Dictionary <IPointCollection, bool> pointCollections) { var visibilityPolygons = new Dictionary <IPolygon, bool>(); foreach (var points in pointCollections) { var polylines = new List <IPolyline>(); if (points.Value) { polylines.Add(EsriTools.Create3DPolylineFromPoints(observerPoint, points.Key.Point[0])); for (int i = 0; i < points.Key.PointCount - 1; i++) { polylines.Add(EsriTools.Create3DPolylineFromPoints(points.Key.Point[i], points.Key.Point[i + 1])); } polylines.Add(EsriTools.Create3DPolylineFromPoints(observerPoint, points.Key.Point[points.Key.PointCount - 1])); } else { for (int i = 0; i < points.Key.PointCount - 1; i++) { polylines.Add(EsriTools.Create3DPolylineFromPoints(points.Key.Point[i], points.Key.Point[i + 1])); } } visibilityPolygons.Add(EsriTools.GetVisilityPolygon(polylines), points.Value); } return(visibilityPolygons); }
internal static void OpenProfilesSetIn3D(ArcSceneArguments layers, IActiveView map) { OpenArcScene(); try { UpdateTemporaryDataStorage(); IObjectFactory objFactory = m_application as IObjectFactory; var document = (IBasicDocument)m_application.Document; _zFactor = layers.ZFactor; _map = map; var baseSurface = AddBaseLayers(layers, objFactory, document); AddVisibilityLayers(layers.VisibilityResultsInfo, objFactory, document, baseSurface); AddExtraLayers(layers.AdditionalLayers, objFactory, document, baseSurface); if (!String.IsNullOrEmpty(layers.DraperyLayer)) { AddDraperyLayer(layers.DraperyLayer, objFactory, baseSurface, document); } var surfaceLayer = EsriTools.GetLayer(_demLayerName, document.ActiveView.FocusMap); if (surfaceLayer != null) { SetSceneView(document, surfaceLayer as IRasterLayer); } } catch (Exception ex) { logger.ErrorEx(ex.Message); } }
private static void SetFromMapRendererToRasterLayer(IRasterLayer rasterLayer, IObjectFactory objFactory, string mapLayerName) { MapLayersManager layersManager = new MapLayersManager(_map); var fromMapRasterLayer = EsriTools.GetLayer(mapLayerName, _map.FocusMap) as IRasterLayer; if (fromMapRasterLayer == null) { _layersWithDefaultRenderer.Add(rasterLayer.Name); return; } try { Type renderType = typeof(SimpleRendererClass); string typeRenderID = renderType.GUID.ToString("B"); var symbol = (ISimpleRenderer)objFactory.Create(typeRenderID); var objCopy = (IObjectCopy)objFactory.Create("esriSystem.ObjectCopy"); var copyS = objCopy.Copy(fromMapRasterLayer.Renderer) as IRasterRenderer; rasterLayer.Renderer = copyS; } catch (Exception ex) { _layersWithDefaultRenderer.Add(rasterLayer.Name); logger.WarnEx($"Cannot set rendrer from map for {rasterLayer.Name} layer. Exception: {ex.Message}"); } }
internal void AddResultsGroupLayer(string id, IActiveView activeView) { var selectedResults = _visibilityResults.First(res => res.Id == id); //It can be used for adding tables var tbls = mapDocument.TableProperties; //var datasets = GdbAccess.Instance.GetDatasetsFromCalcWorkspace(selectedResults.ResultsInfo); //EsriTools.AddVisibilityGroupLayer(datasets, selectedResults.Name, selectedResults.Id, selectedResults.ReferencedGDB, GetLastLayer(activeView), // true, 33, activeView); if (selectedResults.CalculationType == VisibilityCalcTypeEnum.BestObservationParameters) { EsriTools.AddTableToMap(tbls, VisibilityTask.GetResultName(VisibilityCalculationResultsEnum.BestParametersTable, selectedResults.Name), selectedResults.ReferencedGDB, mapDocument, application); } else { ArcMapHelper.AddResultsToMapAsGroupLayer(selectedResults, activeView, null, true, 33, null); EsriTools.AddTableToMap(tbls, VisibilityTask.GetResultName(VisibilityCalculationResultsEnum.CoverageTable, selectedResults.Name), selectedResults.ReferencedGDB, mapDocument, application); } }
private void CalculateVSTotalValues(int pointsCount, string visibilityAreasFCName) { var totalExpectedPolygonData = _coverageAreaData.FirstOrDefault(area => area.PointId == -1); if (totalExpectedPolygonData == null) { AddEmptyAreaRow(_allTitle, -1); return; } try { var visibilityPolygonsFeatureClass = GdbAccess.Instance.GetFeatureClass(_gdb, visibilityAreasFCName); _totalVisibleArea = EsriTools.GetTotalAreaFromFeatureClass(visibilityPolygonsFeatureClass, VisibilityManager.CurrentMap); var totalExpectedArea = GetProjectedPolygonArea(totalExpectedPolygonData.Polygon); AddVSRowModel(_allTitle, -1, -1, totalExpectedArea, _totalVisibleArea, totalExpectedArea); for (int i = 1; i <= pointsCount; i++) { var areaByPointsSee = EsriTools.GetTotalAreaFromFeatureClass(visibilityPolygonsFeatureClass, VisibilityManager.CurrentMap, i); AddVSRowModel(_allTitle, -1, i, totalExpectedArea, areaByPointsSee, totalExpectedArea); } } catch (Exception ex) { _logger.ErrorEx($"> CalculateVSTotalValues Exception:{ex.Message}"); } }
internal void FlashPoint(ProfileSettingsPointButtonEnum pointType) { EsriTools.PanToGeometry(View.ActiveView, pointsToShow[pointType]); EsriTools.FlashGeometry(View.ActiveView.ScreenDisplay, new IGeometry[] { pointsToShow[pointType] }); // View.ActiveView.Refresh(); }
internal void ShowProfileOnMap() { var mapScale = View.ActiveView.FocusMap.MapScale; var profile = GetProfileSessionFromSelectedNode(); if (profile == null) { logger.ErrorEx("Cannot find Selected Profiles set"); return; } var profileLines = profile.ProfileLines.Select(line => line.Line as IGeometry); IEnvelope env = new EnvelopeClass(); foreach (var line in profileLines) { env.Union(line.Envelope); } EsriTools.PanToGeometry(View.ActiveView, env); if (profile.DefinitionType == ProfileSettingsTypeEnum.Primitives) { EsriTools.FlashGeometry(View.ActiveView.ScreenDisplay, profile.Segments.First().Polylines); } else { EsriTools.FlashGeometry(View.ActiveView.ScreenDisplay, profileLines); } }
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 void FlashLineOnWorkingGraphics(int profileId, int lineId) { var curList = allGraphics[MilSpaceGraphicsTypeEnum.Session]; IGeometry flashGeometry = null; if (lineId > 0) { int elementId = lineId; var graphic = curList.FirstOrDefault(g => g.ProfileId == profileId && g.ElementId == elementId); if (graphic != null) { flashGeometry = graphic.Source; } } else { var graphics = curList.Where(g => g.ProfileId == profileId).Select(g => g.Source).ToList(); IGeometryCollection theGeomColl = new GeometryBagClass(); graphics.ForEach(pl => theGeomColl.AddGeometry(pl)); ITopologicalOperator theTopoOp = new PolylineClass(); theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl); flashGeometry = theTopoOp as IGeometry; } if (flashGeometry != null) { EsriTools.FlashGeometry(activeView.ScreenDisplay, flashGeometry); activeView.Refresh(); } }
public static void FlashLine(IEnumerable <IPoint> points) { var activeView = (ArcMap.Application.Document as IMxDocument)?.FocusMap as IActiveView; IGeometryBridge2 pGeoBrg = new GeometryEnvironment() as IGeometryBridge2; IPointCollection4 pPointColl = new PolylineClass(); var aWKSPointBuffer = new IPoint[points.Count()]; var i = 0; foreach (var point in points) { aWKSPointBuffer[i] = point; i++; } pGeoBrg.SetPoints(pPointColl, ref aWKSPointBuffer); var polyline = pPointColl as IPolyline; IGeometryCollection theGeomColl = new GeometryBagClass(); theGeomColl.AddGeometry(polyline); ITopologicalOperator theTopoOp = new PolylineClass(); theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl); IGeometry flashGeometry = theTopoOp as IGeometry; if (flashGeometry != null) { EsriTools.ZoomToGeometry(activeView, polyline); EsriTools.FlashGeometry(activeView.ScreenDisplay, new IGeometry[] { polyline }); } }
protected override void OnMouseDown(MouseEventArgs arg) { UID toolId = new UIDClass(); toolId.Value = ThisAddIn.IDs.PickProfileCoordinates; var mxdDoc = ArcMap.Document; var screenDisplay = mxdDoc.ActiveView.ScreenDisplay; var point = screenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y); var pointToSave = screenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y); point.SpatialReference = mxdDoc.FocusMap.SpatialReference; pointToSave.SpatialReference = mxdDoc.FocusMap.SpatialReference; EsriTools.ProjectToWgs84(point); var winImpl = AddIn.FromID <DockableWindowMilSpaceProfileCalc.AddinImpl>(ThisAddIn.IDs.DockableWindowMilSpaceProfileCalc); if (winImpl.MilSpaceProfileCalsController.View.ActiveButton == ProfileSettingsPointButtonEnum.PointsFist) { winImpl.MilSpaceProfileCalsController.SetFirsPointForLineProfile(point, pointToSave); } if (winImpl.MilSpaceProfileCalsController.View.ActiveButton == ProfileSettingsPointButtonEnum.PointsSecond) { winImpl.MilSpaceProfileCalsController.SetSecondfPointForLineProfile(point, pointToSave); } if (winImpl.MilSpaceProfileCalsController.View.ActiveButton == ProfileSettingsPointButtonEnum.CenterFun) { winImpl.MilSpaceProfileCalsController.SetCenterPointForFunProfile(point, pointToSave); } var settings = winImpl.MilSpaceProfileCalsController.ProfileSettings[ProfileSettingsTypeEnum.Points]; }
public static double GetMetresInMapUnits(double metres) { var focusMap = (ArcMap.Application.Document as IMxDocument)?.FocusMap; var spatialReference = focusMap.SpatialReference; return(EsriTools.GetMetresInMapUnits(metres, spatialReference)); }
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 SetCoverageAreas(string observerPointsFeatureClassName, bool needToRecalcDistance) { _logger.DebugEx("> SetCoverageAreas START"); var observerPointsFeatureClass = GdbAccess.Instance.GetFeatureClass(_gdb, observerPointsFeatureClassName); var observationPoints = GetObservationPoints(observerPointsFeatureClassName); if (observationPoints == null || observationPoints.Count() == 0) { _logger.ErrorEx($"> SetCoverageAreas END. Observation points are not found"); return; } var observObjPolygons = new Dictionary <int, IPolygon>(); foreach (var pointModel in observationPoints) { var point = observerPointsFeatureClass.GetFeature(pointModel.Objectid); IPoint pointGeom = point.Shape as IPoint; pointGeom.Project(VisibilityManager.CurrentMap.SpatialReference); var realMaxDistance = needToRecalcDistance ? EsriTools.GetMaxDistance(pointModel.OuterRadius.Value, pointModel.AngelMaxH.Value, pointModel.RelativeHeight.Value) : pointModel.OuterRadius.Value; var realMinDistance = needToRecalcDistance ? EsriTools.GetMinDistance(pointModel.InnerRadius.Value, pointModel.AngelMinH.Value, pointModel.RelativeHeight.Value) : pointModel.InnerRadius.Value; IPolygon visibilityPolygon = null; if (realMaxDistance < realMinDistance) { _logger.WarnEx("> SetCoverageAreas END. Observation point doesn`t has a coverage area"); } else { visibilityPolygon = EsriTools.GetCoverageArea( pointGeom, pointModel.AzimuthStart.Value, pointModel.AzimuthEnd.Value, realMinDistance, realMaxDistance); } _coverageAreaData.Add(new CoverageAreaData { ObjId = -1, PointId = pointModel.Objectid, Polygon = visibilityPolygon }); } var totalArea = EsriTools.GetTotalPolygon(_coverageAreaData.Select(area => { return(area.Polygon); }).ToList()); _coverageAreaData.Add(new CoverageAreaData { ObjId = -1, PointId = -1, Polygon = totalArea }); _logger.DebugEx("> SetCoverageAreas END"); }
public static void ClearTemporaryData(string taskId, string gdb = null) { if (String.IsNullOrEmpty(gdb)) { gdb = MilSpaceConfiguration.ConnectionProperty.TemporaryGDBConnection; } EsriTools.RemoveDataSet(gdb, $"{taskId}{_temporaryObservationStationFeatureClassSuffix}"); }
internal static IPoint GetObserverPoint(double observerHeight, ProfileSurfacePoint firstPoint) { IPoint geoPoint = new Point() { X = firstPoint.X, Y = firstPoint.Y, Z = firstPoint.Z, SpatialReference = EsriTools.Wgs84Spatialreference }; return(EsriTools.GetObserverPoint(geoPoint, observerHeight, ArcMap.Document.FocusMap.SpatialReference)); }
public string[] GetRasterInfo(string rasterName) { if (String.IsNullOrEmpty(rasterName)) { return(null); } var mapLayerManager = new MapLayersManager(ArcMap.Document.ActiveView); var rasterInfo = new string[5]; IRasterFunctionHelper functionHelper = new RasterFunctionHelper(); var rasterLayer = mapLayerManager.RasterLayers.First(layer => layer.Name.Equals(rasterName)); var filePath = rasterLayer.FilePath; var rasterProps = rasterLayer.Raster as IRasterProps; var defaultRasterProps = rasterLayer.Raster as IRasterDefaultProps; var pixelSize = EsriTools.GetPixelSize(ArcMap.Document.ActiveView); var spatialResolution = pixelSize / rasterProps.MeanCellSize().X; var heightInPixels = rasterProps.Height; var widthInPixels = rasterProps.Width; var heightInKilometres = rasterProps.Extent.Height / EsriTools.GetMetresInMapUnits(1000, ArcMap.Document.FocusMap.SpatialReference); var widthInKilometres = rasterProps.Extent.Width / EsriTools.GetMetresInMapUnits(1000, ArcMap.Document.FocusMap.SpatialReference); var area = heightInKilometres * widthInKilometres; rasterInfo[0] = String.Format(LocalizationContext.Instance .FindLocalizedElement("SolutionSettingsWindow_lbRasterInfoLocationText", "розташування: {0}"), filePath); rasterInfo[1] = String.Format(LocalizationContext.Instance .FindLocalizedElement("SolutionSettingsWindow_lbRasterInfoSpatialResolutionText", "просторова роздільна здатність: {0}"), spatialResolution); rasterInfo[2] = String.Format(LocalizationContext.Instance .FindLocalizedElement("SolutionSettingsWindow_lbRasterInfoAreaText", "площа: {0}"), area); rasterInfo[3] = String.Format(LocalizationContext.Instance .FindLocalizedElement("SolutionSettingsWindow_lbRasterInfoSizeInKilometresText", "розмір (км): висота {0} ширина {1}"), heightInKilometres, widthInKilometres); rasterInfo[4] = String.Format(LocalizationContext.Instance .FindLocalizedElement("SolutionSettingsWindow_lbRasterInfoSizeInPixelsText", "розмір (пікс.): висота {0} ширина {1}"), heightInPixels, widthInPixels); return(rasterInfo); }
/// <summary> /// Adds a graphic element to the map graphics container /// Returns GUID /// </summary> /// <param name="geom">IGeometry</param> /// public static void FlashGeometry( ESRI.ArcGIS.Geometry.IGeometry geometry, System.Int32 delay) { if (!EsriTools.IsPointOnExtent(ArcMap.Document.ActivatedView.Extent, geometry as IPoint)) { EsriTools.PanToGeometry(ArcMap.Document.ActiveView, geometry, true); } EsriTools.FlashGeometry(geometry, delay, ArcMap.Application); }
public static IPoint GetCenterPoint(List <IGeometry> geometries) { var envelope = EsriTools.GetEnvelopeOfGeometriesList(geometries); var x = envelope.XMin + (envelope.XMax - envelope.XMin) / 2; var y = envelope.YMin + (envelope.YMax - envelope.YMin) / 2; return(new Point { X = x, Y = y, SpatialReference = envelope.SpatialReference }); }
internal bool IsResultsLayerExist(string resultsId, IActiveView activeView) { try { var selectedResults = _visibilityResults.First(res => res.Id == resultsId).Name; var layer = EsriTools.GetLayer(selectedResults, activeView.FocusMap); return(layer != null); } catch { return(false); } }
internal void RemoveResultsFromSession(string id, bool removeLayers, IActiveView activeView) { var selectedResults = _visibilityResults.First(res => res.Id == id); if (removeLayers) { EsriTools.RemoveLayer(selectedResults.Name, activeView.FocusMap); } _visibilityResults.Remove(selectedResults); }
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 void FlashPoint(ProfileSettingsPointButtonEnum pointType) { IEnvelope env = new EnvelopeClass(); env = View.ActiveView.Extent; env.CenterAt(pointsToShow[pointType]); View.ActiveView.Extent = env; View.ActiveView.Refresh(); EsriTools.FlashGeometry(View.ActiveView.ScreenDisplay, pointsToShow[pointType]); View.ActiveView.Refresh(); }
internal void ShowProfileOnMap(int profileId = -1, ProfileLine line = null) { var mapScale = View.ActiveView.FocusMap.MapScale; ProfileSession profile; if (profileId == -1) { profile = GetProfileSessionFromSelectedNode(); } else { profile = GetProfileSessionById(profileId); } if (profile == null) { logger.ErrorEx("Cannot find Selected Profiles set"); return; } IEnumerable <IGeometry> profileLines; if (line == null) { profileLines = profile.ProfileLines.Select(profileLine => profileLine.Line as IGeometry); } else { profileLines = new List <IGeometry> { line.Line }; } IEnvelope env = new EnvelopeClass(); foreach (var profileLine in profileLines) { env.Union(profileLine.Envelope); } EsriTools.PanToGeometry(View.ActiveView, env); if (profile.DefinitionType == ProfileSettingsTypeEnum.Primitives) { EsriTools.FlashGeometry(View.ActiveView.ScreenDisplay, profile.Segments.First().Polylines); } else { logger.InfoEx("Flashing geomerty"); EsriTools.FlashGeometry(View.ActiveView.ScreenDisplay, profileLines); logger.InfoEx("Geomerty flashed"); } }
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); }
protected override void OnMouseDown(MouseEventArgs arg) { UID toolId = new UIDClass(); toolId.Value = ThisAddIn.IDs.PickProfileCoordinates; var mxdDoc = ArcMap.Document; var screenDisplay = mxdDoc.ActiveView.ScreenDisplay; var point = screenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y); var pointToSave = screenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y); point.SpatialReference = pointToSave.SpatialReference = mxdDoc.FocusMap.SpatialReference; EsriTools.ProjectToWgs84(point); var winImpl = AddIn.FromID <DockableWindowMilSpaceProfileCalc.AddinImpl>(ThisAddIn.IDs.DockableWindowMilSpaceProfileCalc); var dem = winImpl.MilSpaceProfileCalsController.View.DemLayerName; MapLayersManager mngr = new MapLayersManager(mxdDoc.ActiveView); //Set Z value using selected DEM var rl = mngr.RasterLayers.FirstOrDefault(l => l.Name == dem); if (rl != null) { point.AddZCoordinate(rl.Raster); pointToSave.AddZCoordinate(rl.Raster); } else { MessageBox.Show(LocalizationContext.Instance.DemLayerNotChosenText, LocalizationContext.Instance.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (winImpl.MilSpaceProfileCalsController.View.ActiveButton == ProfileSettingsPointButtonEnum.PointsFist) { winImpl.MilSpaceProfileCalsController.SetFirsPointForLineProfile(point, pointToSave); } if (winImpl.MilSpaceProfileCalsController.View.ActiveButton == ProfileSettingsPointButtonEnum.PointsSecond) { winImpl.MilSpaceProfileCalsController.SetSecondfPointForLineProfile(point, pointToSave); } if (winImpl.MilSpaceProfileCalsController.View.ActiveButton == ProfileSettingsPointButtonEnum.CenterFun) { winImpl.MilSpaceProfileCalsController.SetCenterPointForFunProfile(point, pointToSave); } var settings = winImpl.MilSpaceProfileCalsController.ProfileSettings[ProfileSettingsTypeEnum.Points]; }
private void OnProfileGraphClicked(GraphProfileClickedArgs e) { IPoint point = new Point() { X = e.ProfilePoint.X, Y = e.ProfilePoint.Y, SpatialReference = e.ProfilePoint.SpatialReference }; IEnvelope env = new EnvelopeClass(); var av = ArcMap.Document.ActivatedView; point.Project(av.FocusMap.SpatialReference); EsriTools.PanToGeometry(ArcMap.Document.ActivatedView, point); EsriTools.FlashGeometry(av.ScreenDisplay, new IGeometry[] { point }); }
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); }