internal void LoadFile(int X, int Y) { if (CheckRequirments()) { try { ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = (_application.Document as IMxDocument).ActiveView.ScreenDisplay; ESRI.ArcGIS.Geometry.IPoint point = screenDisplay.DisplayTransformation.ToMapPoint(X, Y); ESRI.ArcGIS.Carto.IFeatureLayer tilefeaturelayer = _utilitiesArcMap.FeatureLayer(cboTileIndex.Text); IFeatureClass tilefeatureclass = tilefeaturelayer.FeatureClass; ISpatialFilter spatialfilter = new SpatialFilter(); spatialfilter.GeometryField = tilefeatureclass.ShapeFieldName; spatialfilter.Geometry = point; spatialfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureCursor tilefeaturecursor = tilefeatureclass.Search(spatialfilter, false); IFeature tilefeature = null; while ((tilefeature = tilefeaturecursor.NextFeature()) != null) { object obj = tilefeature.get_Value(_utilitiesArcMap.FindField(tilefeature, this.cboNameField.Text)); if (obj != DBNull.Value) { string tilename = obj.ToString(); LoadFile(txbFileWorkspace.Text + "\\" + tilename + "."); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// 根据障碍点和经过点求解最短路径 /// </summary> /// <param name="mapControl"></param> /// <param name="featureLayer"></param> /// <param name="dbPath"></param> /// <param name="featureSetName"></param> /// <param name="ndsName"></param> /// <param name="stopPoints"></param> /// <param name="barryPoints"></param> /// <param name="routeLayer"></param> /// <returns></returns> public bool QueryTheRoue(ESRI.ArcGIS.Controls.AxMapControl mapControl, ESRI.ArcGIS.Carto.IFeatureLayer featureLayer, string dbPath, string featureSetName, string ndsName, List<ESRI.ArcGIS.Geometry.IPoint> stopPoints, List<ESRI.ArcGIS.Geometry.IPoint> barryPoints, ref ILayer routeLayer) { // List<IPoint> newStopPoints; // List<IPoint> newBarryPoints; // UpdatePointsToRouteCore(featureLayer, stopPoints, barryPoints, out newStopPoints, out newBarryPoints); //实例化站点和障碍点要素 IFeatureClass stopFeatureClass = FeatureClassUtil.CreateMemorySimpleFeatureClass(esriGeometryType.esriGeometryPoint, mapControl.SpatialReference, "stops"); IFeatureClass barriesFeatureClass = FeatureClassUtil.CreateMemorySimpleFeatureClass(esriGeometryType.esriGeometryPoint, mapControl.SpatialReference, "barries"); //添加站点 foreach (var value in stopPoints) { FeatureClassUtil.InsertSimpleFeature(value, stopFeatureClass); } //添加障碍 foreach (var value in barryPoints) { FeatureClassUtil.InsertSimpleFeature(value, barriesFeatureClass); } //组装站点和障碍点要素 IDictionary<string, DecorateRouteFeatureClass> featureClasses = new Dictionary<string, DecorateRouteFeatureClass>(); featureClasses.Add("Stops", new DecorateRouteFeatureClass(0.2,stopFeatureClass)); featureClasses.Add("Barriers", new DecorateRouteFeatureClass(0.2,barriesFeatureClass)); //最短路径分析 bool result=NormalNetworkUtil.Short_Path(mapControl, dbPath, featureSetName, ndsName, featureClasses, false, false, ref routeLayer); //if (result) // { // showRouteShape(routeLayer as IFeatureLayer, mapControl); // } return result; }
/// <summary> /// Load the A dropdown with selected cables /// </summary> /// <param name="helper">SpliceEditorHelper</param> private void PopulateACables(FiberSpliceHelper helper, SpliceClosureWrapper spliceWrapper) { try { // Clear anything that is dependent on what we are about to load ClearGrid(); cboCableA.Items.Clear(); cboCableB.Items.Clear(); lblAvailableA.Text = ""; lblAvailableB.Text = ""; List <ESRI.ArcGIS.Geodatabase.IFeature> selectedCables = helper.GetConnectedCables(spliceWrapper); ESRI.ArcGIS.Carto.IFeatureLayer ftLayer = _hookHelper.FindFeatureLayer(ConfigUtil.FiberCableFtClassName); int displayIdx = ftLayer.FeatureClass.FindField(ftLayer.DisplayField); for (int i = 0; i < selectedCables.Count; i++) { FiberCableWrapper w = new FiberCableWrapper(selectedCables[i], displayIdx); cboCableA.Items.Add(w); } if (0 < cboCableA.Items.Count) { cboCableA.SelectedItem = cboCableA.Items[0]; } } catch (Exception e) { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Splice Connection Window (PopulateACables): ", e.Message); } }
/// <summary> /// 从图层获取符号类型 /// </summary> /// <param name="pLayer"></param> /// <returns></returns> private ESRI.ArcGIS.Controls.esriSymbologyStyleClass GetSymbolStyle(ESRI.ArcGIS.Carto.IFeatureLayer pLayer) { ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = ESRI.ArcGIS.Controls.esriSymbologyStyleClass.esriStyleClassMarkerSymbols; if (pLayer == null) { return(styleClass); } switch (pLayer.FeatureClass.ShapeType) { case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint: styleClass = ESRI.ArcGIS.Controls.esriSymbologyStyleClass.esriStyleClassMarkerSymbols; break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline: styleClass = ESRI.ArcGIS.Controls.esriSymbologyStyleClass.esriStyleClassLineSymbols; break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon: styleClass = ESRI.ArcGIS.Controls.esriSymbologyStyleClass.esriStyleClassFillSymbols; break; } switch (pLayer.FeatureClass.FeatureType) { case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTAnnotation: styleClass = ESRI.ArcGIS.Controls.esriSymbologyStyleClass.esriStyleClassTextSymbols; break; } return(styleClass); }
public frmSymbology(byte[] rendererValue, string rendererType, ESRI.ArcGIS.Controls.esriSymbologyStyleClass pStyleClass, List <ESRI.ArcGIS.Geodatabase.IField> pFields) { m_FeatureLayer = null; m_StyleClass = pStyleClass; m_RendererObject = new Dictionary <string, IRendererUI>(); m_FeatureRenderer = GetRenderer(rendererValue, rendererType); m_FieldInfo = new List <FieldInfo>(); FieldInfo noneField = new FieldInfo(); noneField.FieldName = "<NONE>"; noneField.FieldDesc = "<NONE>"; noneField.FieldType = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeDate; m_FieldInfo.Add(noneField); if (pFields != null && pFields.Count != 0) { for (int i = 0; i < pFields.Count; i++) { FieldInfo field = new FieldInfo(); //if ((pFields[i].VarType > 1 && pFields[i].VarType < 6 && pFields[i].Type != ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeOID) // || pFields[i].Type == ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeString) if ((int)pFields[i].Type < 5) { field.FieldName = pFields[i].Name; field.FieldDesc = pFields[i].AliasName; field.FieldType = pFields[i].Type; m_FieldInfo.Add(field); } } } InitializeUI(); InitRendererUI(m_FieldInfo); }
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (DoQueryIndex == 1)//点击查询 { ESRI.ArcGIS.Carto.IFeatureLayer pFeatureLayer = axMapControl1.get_Layer(layerComboBox.SelectedIndex) as ESRI.ArcGIS.Carto.IFeatureLayer; ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass(); point.PutCoords(e.mapX, e.mapY); ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilter = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass(); spatialFilter.Geometry = point; spatialFilter.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects; ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = pFeatureLayer.Search(spatialFilter, false); ESRI.ArcGIS.Geodatabase.IFeature pFeature; while ((pFeature = featureCursor.NextFeature()) != null) { axMapControl1.FlashShape(pFeature.Shape); } } else if (DoQueryIndex == 2)//面范围查询 { ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass(); point.PutCoords(e.mapX, e.mapY); pointCollection.AddPoints(1, ref point); if (pointCollection.PointCount > 1) { DrawPolygon(pointCollection, axMapControl1); } } }
private void UploadToGoogleMapsEngine_Load(object sender, EventArgs e) { // establish a reference to the running ArcMap instance ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc = (ESRI.ArcGIS.ArcMapUI.IMxDocument)ArcMap.Application.Document; // retrieve a reference to the selected layer ESRI.ArcGIS.Carto.ILayer selectedLayer = mxDoc.SelectedLayer; // get the data layer of this feature layer ESRI.ArcGIS.Carto.IDataLayer2 dataLayer = (ESRI.ArcGIS.Carto.IDataLayer2)selectedLayer; ESRI.ArcGIS.Geodatabase.IDatasetName datasetName = (ESRI.ArcGIS.Geodatabase.IDatasetName)dataLayer.DataSourceName; // add a script manager to the browser // in order to capture select events webBrowser.ObjectForScripting = new BrowerScriptManager(this); // fetch the upload_dialog_html resource log.Debug("fetch the upload_dialog_html resource"); string uploadhtml = Properties.Resources.upload_dialog_html; // populate the source dataset information uploadhtml = uploadhtml.Replace("{sourcename}", datasetName.Name); uploadhtml = uploadhtml.Replace("{sourceworkspace}", datasetName.WorkspaceName.PathName); // configure raster/vector specific information if (selectedLayer is ESRI.ArcGIS.Carto.IFeatureLayer) { // cast the selected layer into a feature layer ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)selectedLayer; // set the source vector type uploadhtml = uploadhtml.Replace("{sourcetype}", featureLayer.DataSourceType); // set the variable upload type to vector uploadType = "vector"; } else if (selectedLayer is ESRI.ArcGIS.Carto.IRasterLayer) { // cast the selected layer into a raster layer ESRI.ArcGIS.Carto.IRasterLayer rasterLayer = (ESRI.ArcGIS.Carto.IRasterLayer)selectedLayer; // set the source raster type uploadhtml = uploadhtml.Replace("{sourcetype}", "Raster: " + rasterLayer.RowCount + " rows, " + rasterLayer.ColumnCount + " columns, " + rasterLayer.BandCount + " bands"); // set the variable upload type to raster uploadType = "raster"; } // set the upload html log.Debug("Setting the HTML to the web browser on the dialog."); this.webBrowser.DocumentText = uploadhtml; }
/// <summary> /// Finds the first layer on the focus map whose source feature class /// has the given name AND where the workspace matches that of the /// currently selected telecom workspace. /// </summary> /// <param name="ftClassName">Name to look for</param> /// <returns>IFeatureLayer</returns> public ESRI.ArcGIS.Carto.IFeatureLayer FindFeatureLayer(string ftClassName) { ESRI.ArcGIS.Carto.IFeatureLayer result = null; if (1 > ftClassName.Length) { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "FindFeatureLayer: ", "ftClassName not specified"); throw new ArgumentException("ftClassName not specified"); } // Check the cache first for the layer if (_featureLayerCache.ContainsKey(ftClassName)) { _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Found Feature Layer in cache", ftClassName); return(_featureLayerCache[ftClassName]); } ESRI.ArcGIS.esriSystem.UID geoFeatureLayerID = new ESRI.ArcGIS.esriSystem.UIDClass(); geoFeatureLayerID.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}"; ESRI.ArcGIS.Carto.IEnumLayer enumLayer = this.FocusMap.get_Layers(geoFeatureLayerID, true); // Step through each geofeature layer in the map enumLayer.Reset(); ESRI.ArcGIS.Carto.IFeatureLayer ftLayer = enumLayer.Next() as ESRI.ArcGIS.Carto.IFeatureLayer; string testName = ftClassName.ToLower(); // No reason to do this every time in the loop int testDotPosition = testName.LastIndexOf('.'); testName = testName.Substring(testDotPosition + 1); while (ftLayer != null) { if (ftLayer.Valid) { ESRI.ArcGIS.Geodatabase.IDataset dataset = ftLayer.FeatureClass as ESRI.ArcGIS.Geodatabase.IDataset; if (null != dataset && dataset.Workspace == _wkspHelper.CurrentWorkspace) { string tableName = GdbUtils.ParseTableName(dataset); if (tableName.ToLower() == testName) { result = ftLayer; _featureLayerCache.Add(ftClassName, result); break; } } } ftLayer = enumLayer.Next() as ESRI.ArcGIS.Carto.IFeatureLayer; } return(result); }
public string FilePathinRfromLayer(ESRI.ArcGIS.Carto.IFeatureLayer pFLayer) { ESRI.ArcGIS.Geodatabase.IDataset dataset = (ESRI.ArcGIS.Geodatabase.IDataset)(pFLayer); string strfullname = dataset.Workspace.PathName + "\\" + dataset.BrowseName; if (dataset.Category == "Shapefile Feature Class") { strfullname = strfullname + ".shp"; } string strNameR = strfullname.Replace(@"\", @"\\"); return(strNameR); }
public ESRI.ArcGIS.Carto.IFeatureLayer GetSelectedFeatureLayerInContentsView(ESRI.ArcGIS.ArcMapUI.IContentsView currentContentsView) { if (currentContentsView == null) { return(null); } if (currentContentsView.SelectedItem is ESRI.ArcGIS.Carto.IFeatureLayer) { ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)currentContentsView.SelectedItem; // Explicit Cast return(featureLayer); } return(null); }
public ESRI.ArcGIS.Carto.IFeatureLayer GetSelectedFeatureLayerInContentsView() { IContentsView CurrentContentsView = GetContentsViewFromArcMap(ArcMap.Application, 0); ESRI.ArcGIS.Carto.IFeatureLayer fl = GetSelectedFeatureLayerInContentsView(CurrentContentsView); if (fl == null) { CurrentContentsView = GetContentsViewFromArcMap(ArcMap.Application, 1); fl = GetSelectedFeatureLayerInContentsView(CurrentContentsView); } return(fl); }
/// <summary> /// 从图层获取符号方案 /// </summary> /// <param name="pLayer"></param> /// <returns></returns> private ESRI.ArcGIS.Carto.IFeatureRenderer GetRenderer(ESRI.ArcGIS.Carto.IFeatureLayer pLayer) { if (pLayer == null) { return(ModuleCommon.CreateSimpleRenderer(m_StyleClass)); } ESRI.ArcGIS.Carto.IGeoFeatureLayer pGeoLayer = pLayer as ESRI.ArcGIS.Carto.IGeoFeatureLayer; if (pGeoLayer == null || pGeoLayer.Renderer == null) { return(ModuleCommon.CreateSimpleRenderer(m_StyleClass)); } return(pGeoLayer.Renderer); }
// ArcGIS Snippet Title: // Get FeatureClass of Selected Feature Layer in Contents View // // Long Description: // Returns a reference to the currently selected featureclass from the given contents view. // // Add the following references to the project: // ESRI.ArcGIS.ArcMapUI // ESRI.ArcGIS.Carto // ESRI.ArcGIS.Geodatabase // // Intended ArcGIS Products for this snippet: // ArcGIS Desktop (ArcEditor, ArcInfo, ArcView) // // Applicable ArcGIS Product Versions: // 9.2 // 9.3 // 9.3.1 // 10.0 // // Required ArcGIS Extensions: // (NONE) // // Notes: // This snippet is intended to be inserted at the base level of a Class. // It is not intended to be nested within an existing GetIntersection. // ///<summary>Returns a reference to the currently selected featureclass from the given contents view.</summary> /// ///<param name="currentContentsView">An IContentsView interface.</param> /// ///<returns>An IFeatureClass interface or Nothing if not found.</returns> /// ///<remarks></remarks> public ESRI.ArcGIS.Geodatabase.IFeatureClass GetFeatureClassOfSelectedFeatureLayerInContentsView(ESRI.ArcGIS.ArcMapUI.IContentsView currentContentsView) { if (currentContentsView == null) { return(null); } if (currentContentsView.SelectedItem is ESRI.ArcGIS.Carto.IFeatureLayer) { ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)currentContentsView.SelectedItem; // Explicit Cast ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureLayer.FeatureClass; return(featureClass); } return(null); }
public frmSymbology(ESRI.ArcGIS.Carto.IFeatureLayer pFeatureLayer) { InitializeComponent(); m_FeatureLayer = pFeatureLayer; if (m_FeatureLayer == null) { return; } m_StyleClass = GetSymbolStyle(pFeatureLayer); m_RendererObject = new Dictionary <string, IRendererUI>(); m_FeatureRenderer = GetRenderer(m_FeatureLayer); m_FieldInfo = null; InitializeUI(); InitRendererUI(m_FieldInfo); }
public static void ExportLayerToShapefile(string shapePath, string shapeName, ILayer source) { try { // cast the selected/requested layer into a feature layer ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = (IFeatureLayer)source; // create a new feature class to feature class converter utility ESRI.ArcGIS.ConversionTools.FeatureClassToFeatureClass fc2fc = new ESRI.ArcGIS.ConversionTools.FeatureClassToFeatureClass(); // set the input feature layer fc2fc.in_features = featureLayer; // set the output path and Shapefile name fc2fc.out_path = shapePath; fc2fc.out_name = shapeName + ".shp"; // create a new GeoProcessor ESRI.ArcGIS.Geoprocessor.Geoprocessor geoprocessor = new ESRI.ArcGIS.Geoprocessor.Geoprocessor(); geoprocessor.TemporaryMapLayers = true; // execute the FeatureClassToFeatureClass geoprocessor.Execute(fc2fc, null); // export a copy of the layer file definition too for upload/style at a later time ESRI.ArcGIS.DataManagementTools.SaveToLayerFile saveToLayerFile = new ESRI.ArcGIS.DataManagementTools.SaveToLayerFile(); saveToLayerFile.in_layer = source; saveToLayerFile.out_layer = shapePath + "\\" + shapeName + ".lyr"; // execute the FeatureClassToFeatureClass geoprocessor.Execute(saveToLayerFile, null); // remove reference to the tool and geoprocessor fc2fc = null; geoprocessor = null; } catch (Exception ex) { // an error occured System.Windows.Forms.MessageBox.Show("Error: " + ex.Message); } }
/// <summary> /// Load the drop down of selected splice closures /// </summary> /// <param name="helper">SpliceEditorHelper</param> private void PopulateSpliceClosures(FiberSpliceHelper helper) { try { // Clear anything that is dependent on what we are about to load ClearGrid(); cboCableA.Items.Clear(); cboCableB.Items.Clear(); cboSpliceClosure.Items.Clear(); lblAvailableA.Text = ""; lblAvailableB.Text = ""; // Find the layer ESRI.ArcGIS.Carto.IFeatureLayer ftLayer = _hookHelper.FindFeatureLayer(ConfigUtil.SpliceClosureFtClassName); if (ftLayer == null) { ArcMap.Application.StatusBar.set_Message(0, "Telecom Tools error occurred. Check log for details."); _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Could not find Feature Layer:.", ConfigUtil.SpliceClosureFtClassName); return; } int displayIdx = ftLayer.FeatureClass.FindField(ftLayer.DisplayField); // Get the selection on this layer List <ESRI.ArcGIS.Geodatabase.IFeature> selectedSplices = _hookHelper.GetSelectedFeatures(ftLayer); for (int i = 0; i < selectedSplices.Count; i++) { SpliceClosureWrapper w = new SpliceClosureWrapper(selectedSplices[i], displayIdx); cboSpliceClosure.Items.Add(w); } if (0 < cboSpliceClosure.Items.Count) { cboSpliceClosure.SelectedItem = cboSpliceClosure.Items[0]; } } catch (Exception e) { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Splice Connection Window (PopulateSpliceClosures): ", e.Message); } }
public void ClearSelectedMapFeatures(ESRI.ArcGIS.Carto.IActiveView activeView, ESRI.ArcGIS.Carto.IFeatureLayer featureLayer) //dhncho 01.10 { if (activeView == null || featureLayer == null) { return; } ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = featureLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast // Invalidate only the selection cache. Flag the original selection activeView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null); // Clear the selection featureSelection.Clear(); // Flag the new selection activeView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null); }
/// <summary> /// 修正处理函数,参数框架为主窗体,以获得图层(取得待处理的要素)和进度条 /// </summary> /// <param name="AppHook"></param> private void ExcuteCorrect(object hook) { SetCheckState.GeoCor = true;//拓扑修正里用到开启和关闭编辑 Plugin.Application.IAppGISRef AppHook = hook as Plugin.Application.IAppGISRef; #region 取得进度条对象 //取得进度条对象 Plugin.Application.IAppFormRef pAppForm = AppHook as Plugin.Application.IAppFormRef; #endregion Plugin.Application.IAppGISRef appHook = hook as Plugin.Application.IAppGISRef; #region 获得待处理的图层 //判断图层个数是否为0 if (AppHook.MapControl.LayerCount == 0) { return; } IWorkspaceEdit pWorkspaceEdit = null; #region 循环图层进行处理,并控制进度条 for (int i = 0; i < AppHook.MapControl.LayerCount; i++) { ESRI.ArcGIS.Carto.ILayer pLayer = AppHook.MapControl.get_Layer(i); bool isShpFile = false; //操作更新库体下的层 && pLayer.Name == SetCheckState.CheckDataBaseName #region 针对的是IGrouplayer下的层进行拓扑修正 if (pLayer is IGroupLayer) { ICompositeLayer C_layer = pLayer as ICompositeLayer; int count = C_layer.Count;//得到组合图层数 if (count == 0) { return; } for (int c = 0; c < count; c++) { ESRI.ArcGIS.Carto.IFeatureLayer pFeatLayer = C_layer.get_Layer(c) as IFeatureLayer; #region 图形简单化,删除空图形,删除零长度线,删除零面积面,负面积面逆向 if (pFeatLayer == null) { continue; } IFeatureClass pFeatureClass = pFeatLayer.FeatureClass; //开启编辑 wjj 20090921 IDataset pDataset = pFeatureClass as IDataset; pWorkspaceEdit = pDataset.Workspace as IWorkspaceEdit; if (pWorkspaceEdit.IsBeingEdited() == false) { pWorkspaceEdit.StartEditing(false); } //判断图层类型,线或者面才进行处理 if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { IFeatureCursor pFeatCur = pFeatureClass.Search(null, false); if (pFeatCur != null) { IFeature pFeat = pFeatCur.NextFeature(); if (pFeat != null) { do { //删除空几何图形 if (pFeat.Shape.IsEmpty) { pFeat.Delete(); //写状态栏信息 string del = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, del); } else { ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator; if (pTopo != null) { //图形简单化 pTopo.Simplify(); //写状态栏信息 string simplify = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, simplify); } } pFeat = pFeatCur.NextFeature(); } while (pFeat != null); } } #region 除长度为零的线要素 //删除长度为零的要素 IQueryFilter pFilter = new QueryFilterClass(); pFilter.WhereClause = pFeatureClass.LengthField.Name + "=0 or " + pFeatureClass.LengthField.Name + " is null"; pFeatCur = pFeatureClass.Search(pFilter, false); if (pFeatCur != null) { IFeature pFeat = pFeatCur.NextFeature(); if (pFeat != null) { do { pFeat.Delete(); //写状态栏信息 string zero = pFeatureClass.AliasName + ": 删除长度为零的线要素,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, zero); pFeat = pFeatCur.NextFeature(); } while (pFeat != null); } } #endregion //释放cursor System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur); } else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { IFeatureCursor pFeatCur = pFeatureClass.Search(null, false); if (pFeatCur != null) { IFeature pFeat = pFeatCur.NextFeature(); if (pFeat != null) { do { //删除空几何图形 if (pFeat.Shape.IsEmpty) { pFeat.Delete(); //写状态栏信息 string delps = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, delps); } else { ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator; if (pTopo != null) { //图形简单化 pTopo.Simplify(); //写状态栏信息 string simplifyps = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, simplifyps); } } pFeat = pFeatCur.NextFeature(); } while (pFeat != null); } } #region 负面积面点序逆向 IQueryFilter pFilter = new QueryFilterClass(); pFilter.WhereClause = pFeatureClass.AreaField.Name + "<0"; pFeatCur = pFeatureClass.Search(pFilter, false); if (pFeatCur != null) { IFeature pFeat = pFeatCur.NextFeature(); if (pFeat != null) { do { //点序逆向 ICurve pCurv = pFeat.Shape as ICurve; if (pCurv != null) { pCurv.ReverseOrientation(); pFeat.Shape = pCurv; pFeat.Store(); //写状态栏信息 string reverse = pFeatureClass.AliasName + ": 点序逆向,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, reverse); } pFeat = pFeatCur.NextFeature(); } while (pFeat != null); } } #endregion //删除面积为零的要素 pFilter.WhereClause = pFeatureClass.AreaField.Name + "=0 or " + pFeatureClass.AreaField.Name + " is null"; pFeatCur = pFeatureClass.Search(pFilter, false); if (pFeatCur != null) { IFeature pFeat = pFeatCur.NextFeature(); if (pFeat != null) { do { pFeat.Delete(); //写状态栏信息 string delarea = pFeatureClass.AliasName + ": 删除面积为零的要素,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, delarea); pFeat = pFeatCur.NextFeature(); } while (pFeat != null); } } //释放cursor System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur); #endregion } //结束编辑 wjj 20090921 if (pWorkspaceEdit.IsBeingEdited() == true) { pWorkspaceEdit.StopEditing(true); } } SetCheckState.CheckShowTips(pAppForm, "拓扑修正检查完成!"); appHook.CurrentThread = null; SetCheckState.Message(pAppForm, "提示", "拓扑修正检查完成!"); SetCheckState.GeoCor = false;//用完判断是否有编辑操作状态后还原 break; } #endregion else { ESRI.ArcGIS.Carto.IFeatureLayer pFeatLayer = pLayer as IFeatureLayer; #region 图形简单化,删除空图形,删除零长度线,删除零面积面,负面积面逆向 if (pFeatLayer == null) { continue; } IFeatureClass pFeatureClass = pFeatLayer.FeatureClass; //开启编辑 wjj 20090921 IDataset pDataset = pFeatureClass as IDataset; #region 陈胜鹏添加shp文件类型的判断 2010-3-10 if (pFeatLayer.DataSourceType == "Shapefile Feature Class") { isShpFile = true; } #endregion pWorkspaceEdit = pDataset.Workspace as IWorkspaceEdit; if (pWorkspaceEdit.IsBeingEdited() == false) { pWorkspaceEdit.StartEditing(false); } //判断图层类型,线或者面才进行处理 if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { IFeatureCursor pFeatCur = pFeatureClass.Search(null, false); if (pFeatCur != null) { IFeature pFeat = pFeatCur.NextFeature(); if (pFeat != null) { do { //删除空几何图形 if (pFeat.Shape.IsEmpty) { pFeat.Delete(); //写状态栏信息 string del = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, del); } else { ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator; if (pTopo != null) { //图形简单化 pTopo.Simplify(); //写状态栏信息 string simplify = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, simplify); } } pFeat = pFeatCur.NextFeature(); } while (pFeat != null); } } #region 除长度为零的线要素 //删除长度为零的要素 IQueryFilter pFilter = new QueryFilterClass(); if (isShpFile) { pFilter.WhereClause = "SHAPE_Leng" + "=0 or " + "SHAPE_Leng" + " is null"; } else { pFilter.WhereClause = pFeatureClass.LengthField.Name + "=0 or " + pFeatureClass.LengthField.Name + " is null"; } pFeatCur = pFeatureClass.Search(pFilter, false); if (pFeatCur != null) { IFeature pFeat = pFeatCur.NextFeature(); if (pFeat != null) { do { pFeat.Delete(); //写状态栏信息 string zero = pFeatureClass.AliasName + ": 删除长度为零的线要素,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, zero); pFeat = pFeatCur.NextFeature(); } while (pFeat != null); } } #endregion //释放cursor System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur); } else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { IFeatureCursor pFeatCur = pFeatureClass.Search(null, false); if (pFeatCur != null) { IFeature pFeat = pFeatCur.NextFeature(); if (pFeat != null) { do { //删除空几何图形 if (pFeat.Shape.IsEmpty) { pFeat.Delete(); //写状态栏信息 string delps = pFeatureClass.AliasName + ": 删除空几何图形,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, delps); } else { ITopologicalOperator pTopo = pFeat.Shape as ITopologicalOperator; if (pTopo != null) { //图形简单化 pTopo.Simplify(); //写状态栏信息 string simplifyps = pFeatureClass.AliasName + ": 图形简单化,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, simplifyps); } } pFeat = pFeatCur.NextFeature(); } while (pFeat != null); } } #region 负面积面点序逆向 IQueryFilter pFilter = new QueryFilterClass(); if (isShpFile) { pFilter.WhereClause = "SHAPE_Area" + "<0"; } else { pFilter.WhereClause = pFeatureClass.AreaField.Name + "<0"; } pFeatCur = pFeatureClass.Search(pFilter, false); if (pFeatCur != null) { IFeature pFeat = pFeatCur.NextFeature(); if (pFeat != null) { do { //点序逆向 ICurve pCurv = pFeat.Shape as ICurve; if (pCurv != null) { pCurv.ReverseOrientation(); pFeat.Shape = pCurv; pFeat.Store(); //写状态栏信息 string reverse = pFeatureClass.AliasName + ": 点序逆向,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, reverse); } pFeat = pFeatCur.NextFeature(); } while (pFeat != null); } } #endregion //删除面积为零的要素 if (isShpFile) { pFilter.WhereClause = "SHAPE_Area" + "=0 or " + "SHAPE_Area" + " is null"; } else { pFilter.WhereClause = pFeatureClass.AreaField.Name + "=0 or " + pFeatureClass.AreaField.Name + " is null"; } pFeatCur = pFeatureClass.Search(pFilter, false); if (pFeatCur != null) { IFeature pFeat = pFeatCur.NextFeature(); if (pFeat != null) { do { pFeat.Delete(); //写状态栏信息 string delarea = pFeatureClass.AliasName + ": 删除面积为零的要素,OID:" + pFeat.OID; SetCheckState.CheckShowTips(pAppForm, delarea); pFeat = pFeatCur.NextFeature(); } while (pFeat != null); } } //释放cursor System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur); } #endregion } } //结束编辑 wjj 20090921 if (pWorkspaceEdit.IsBeingEdited() == true) { pWorkspaceEdit.StopEditing(true); SetCheckState.CheckShowTips(pAppForm, "拓扑修正检查完成!"); appHook.CurrentThread = null; SetCheckState.Message(pAppForm, "提示", "拓扑修正检查完成!"); SetCheckState.GeoCor = false;//用完判断是否有编辑操作状态后还原 } #endregion #endregion }
public string QueryTheRoute(ESRI.ArcGIS.Geometry.IPoint point, ESRI.ArcGIS.Carto.IFeatureLayer featureLayerref, ref ESRI.ArcGIS.Geometry.IPoint rightPoint) { throw new NotImplementedException(); }
/// <summary> /// 点重复数字化检查主函数 /// </summary> /// <param name="_AppHk"></param> private void ExcutePointDigitalDuplicateCheck(object Hook) { Plugin.Application.IAppGISRef _AppHk = Hook as Plugin.Application.IAppGISRef; #region 取得进度条对象 //取得进度条对象 Plugin.Application.IAppFormRef pAppForm = _AppHk as Plugin.Application.IAppFormRef; #endregion System.Data.DataTable Datatable = new System.Data.DataTable(); //手动建立一个数据表,将得到的数据邦定到检查结果当中显示 Datatable.Columns.Add("重复点", typeof(string)); //创建一列 ///如果检查结果提示内有内容就清除 ClearDataCheckGrid ClearGrid = new ClearDataCheckGrid(); ClearGrid.Operate(pAppForm, _AppHk); //判断图层个数是否为0 if (_AppHk.MapControl.LayerCount == 0) { return; } SetCheckState.CheckShowTips(pAppForm, "重复点检查开始....."); int Count = _AppHk.MapControl.LayerCount; for (int i = 0; i < Count; i++) { ILayer temp_layer = _AppHk.MapControl.get_Layer(i); //判别是不是组,如果是,就从组中取一个层 if (temp_layer is IGroupLayer && temp_layer.Name == SetCheckState.CheckDataBaseName) { ICompositeLayer grouplayer = temp_layer as ICompositeLayer; //把组图层转成组合图层 int C_count = grouplayer.Count; //组合图层数 if (C_count == 0) { return; } #region 遍历组下面的重复点 ArrayList LayerList = new ArrayList();//存要素类 //将所有可用的图层存入动态数组 for (int c = 0; c < C_count; c++) { //图层转换 pAppForm.MainForm.Invoke(new ProcessBar(ControlProcessBar), new object[] { C_count, 0, 1, c, pAppForm }); //给进度条传需要的值 int num = c + 1; //由于层的索引是从0开始的,所以得加1 ESRI.ArcGIS.Carto.ILayer pLayer = grouplayer.get_Layer(c); ESRI.ArcGIS.Carto.IFeatureLayer pFeatLayer = pLayer as ESRI.ArcGIS.Carto.IFeatureLayer; //如果图层不为空,就转成对应的要素类 if (pFeatLayer == null) { continue; } IFeatureClass pFeatureClass = pFeatLayer.FeatureClass; if (pFeatureClass == null) { continue; } //只取点层 if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPoint && pFeatureClass.FeatureType != esriFeatureType.esriFTAnnotation) { LayerList.Add(pFeatureClass);//加入动态数组中 } } SetCheckState.TreeIni_Fun(LayerList, _AppHk);//初始化树 //重复点检查操作 for (int L = 0; L < LayerList.Count; L++) { IFeatureClass pFeatureClass = LayerList[L] as IFeatureClass; RePoint(pFeatureClass, pAppForm, Datatable, L);//开始遍历重复点 if (L == LayerList.Count - 1) { SetCheckState.CheckShowTips(pAppForm, "重复点检查马上完成,请稍后..."); } } #endregion break; } } pAppForm.MainForm.Invoke(new ShowPrcoessBar(Show_processBar), new object[] { false, pAppForm }); //是否显示进度条,加载让它显示 SetCheckState.CheckShowTips(pAppForm, "重复点检查完成!"); _AppHk.CurrentThread = null; //线程使用完置空 pAppForm.MainForm.Invoke(new Update_data(Bind), new object[] { Datatable, _AppHk }); SetCheckState.Message(pAppForm, "提示", "重复点检查完成!"); //选中检查出错列表 ClearGrid.CheckDataGridShow(pAppForm, _AppHk); }
private void button_Import_Click(object sender, System.EventArgs e) { // point to the first selected feature: ESRI.ArcGIS.Animation.IAGImportPathOptions AGImportPathOptionsCls = new ESRI.ArcGIS.Animation.AGImportPathOptionsClass(); // Set properties for AGImportPathOptions AGImportPathOptionsCls.BasicMap = (ESRI.ArcGIS.Carto.IBasicMap)globe; // Explicit Cast AGImportPathOptionsCls.AnimationTracks = (ESRI.ArcGIS.Animation.IAGAnimationTracks)globe; // Explicit Cast AGImportPathOptionsCls.AnimationType = new ESRI.ArcGIS.GlobeCore.AnimationTypeGlobeCameraClass(); AGImportPathOptionsCls.AnimatedObject = globe.GlobeDisplay.ActiveViewer.Camera; if (this.radioButton_flyby.Checked == true) { AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObsAndTarget; AGImportPathOptionsCls.PutAngleCalculationMethods(esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative); AGImportPathOptionsCls.PutAngleCalculationValues(0.0, 0.0, 0.0); } else if (this.radioButton_currentTarget.Checked == true) { AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObserver; } else if (this.radioButton_currentObserver.Checked == true) { AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathTarget; } double pAzimuth, pInclination, pRollVal; AGImportPathOptionsCls.GetAngleCalculationValues(out pAzimuth, out pInclination, out pRollVal); AGImportPathOptionsCls.LookaheadFactor = this.trackBarSimplificationFactor.Value / 100; AGImportPathOptionsCls.TrackName = this.textBox_TrackName.Text; AGImportPathOptionsCls.OverwriteExisting = Convert.ToBoolean(this.checkBox_Overwrite.CheckState); AGImportPathOptionsCls.VerticalOffset = Convert.ToDouble(this.textBox_VertOffset.Text); AGImportPathOptionsCls.ReversePath = Convert.ToBoolean(this.checkBox_ReverseOrder.CheckState); // get the layer selected in the combo box if (this.comboBoxLayers.SelectedIndex == -1) { MessageBox.Show("Please select a layer before you proceed"); } else { //set the layer based on the item selected in the combo box ESRI.ArcGIS.Carto.ILayer layer = (ESRI.ArcGIS.Carto.ILayer)layerArray.get_Element(this.comboBoxLayers.SelectedIndex); // Explicit Cast // Get the line feature selected in the layer ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)layer; // Explicit Cast ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = (ESRI.ArcGIS.Carto.IFeatureSelection)layer; // Explicit Cast ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet = featureSelection.SelectionSet; ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureLayer.FeatureClass; string shapeField = featureClass.ShapeFieldName; ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilterCls = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass(); IScene scene = globe.GlobeDisplay.Scene; ESRI.ArcGIS.Geometry.ISpatialReference spatialReference = scene.SpatialReference; spatialFilterCls.GeometryField = shapeField; spatialFilterCls.set_OutputSpatialReference(shapeField, spatialReference); ESRI.ArcGIS.Geodatabase.ICursor cursor; selectionSet.Search(spatialFilterCls, true, out cursor); ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = (ESRI.ArcGIS.Geodatabase.IFeatureCursor)cursor; // Explicit Cast ESRI.ArcGIS.Geodatabase.IFeature lineFeature; lineFeature = featureCursor.NextFeature(); if (lineFeature == null) { MessageBox.Show("Please select a feature in the feature layer selected"); } else { CreateFlybyFromPathAnimation(globe, lineFeature, AGImportPathOptionsCls); } } this.Close(); }