//Function: View Data; //2019/3/21 private void miViewLayerData_Click(object sender, EventArgs e) { //Show data board DataBoard frmDB = new DataBoard(axMapControl1.Map, null); frmDB.Show(); }
/* * Show attributes_table */ private void tableToolStripMenuItem_Click(object sender, EventArgs e) { DataBoard dataBoard = new DataBoard(); dataBoard.CurrentMap = axMapControl1.Map; dataBoard.CurrentLayer = m_Layer; dataBoard.Text = "LayerName:" + m_Layer.Name; dataBoard.Show(); }
//Query Filter private void btnOK_Click(object sender, EventArgs e) { m_spatialFilter.WhereClause = tbQuery.Text; IFeatureSelection featureSelection = (IFeatureSelection)m_layer; try { if (cbMethod.Text == "Create a new selection") { featureSelection.SelectFeatures(m_spatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false); } else if (cbMethod.Text == "Add to current selection") { featureSelection.SelectFeatures(m_spatialFilter, esriSelectionResultEnum.esriSelectionResultAdd, false); } else if (cbMethod.Text == "Remove from current selection") { featureSelection.SelectFeatures(m_spatialFilter, esriSelectionResultEnum.esriSelectionResultSubtract, false); } else if (cbMethod.Text == "Select from current selection") { featureSelection.SelectFeatures(m_spatialFilter, esriSelectionResultEnum.esriSelectionResultAnd, false); } } catch { MessageBox.Show("Invalid query!"); this.Close(); } //Show the attributes of the selected features ISelectionSet selectionSet = featureSelection.SelectionSet; ICursor cursor; selectionSet.Search(null, true, out cursor); //Get the cursor m_FeatureCursor = cursor as IFeatureCursor; IFeatureLayer featureLayer = m_layer as IFeatureLayer; DataOperator dataOperator = new DataOperator(m_map); if (selectionSet.Count > 0) { DataTable dataTable = dataOperator.GetDataTable(m_FeatureCursor, featureLayer); selectionSet.Search(null, true, out cursor); //Get the cursor m_FeatureCursor = cursor as IFeatureCursor; DataBoard dataBoard = new DataBoard(m_map, dataTable, m_FeatureCursor, selectionSet); dataBoard.SetSelectedLayer(m_layer.Name); dataBoard.cbEnabledFalse(); dataBoard.Show(); } m_frmMain.ActiveViewPartialRefresh(); MessageBox.Show(selectionSet.Count + " features are selected."); this.Close(); }
public bool QueryIntersect(string srcLayerName, string tgtLayerName, IMap iMap, esriSpatialRelationEnum spatialRel) { DataOperator dataOperator = new DataOperator(iMap); //Get layer by name IFeatureLayer iSrcLayer = (IFeatureLayer)dataOperator.GetLayerByName(srcLayerName); IFeatureLayer iTgtLayer = (IFeatureLayer)dataOperator.GetLayerByName(tgtLayerName); //using query filter to get geom IGeometry geom; IFeature feature; IFeatureCursor featCursor; IFeatureClass srcFeatClass; IQueryFilter queryFilter = new QueryFilter(); queryFilter.WhereClause = "CONTINENT='Asia'"; //set query clause featCursor = iTgtLayer.FeatureClass.Search(queryFilter, false); feature = featCursor.NextFeature(); geom = feature.Shape; //city attributes filter srcFeatClass = iSrcLayer.FeatureClass; ISpatialFilter spatialFilter = new SpatialFilter(); spatialFilter.Geometry = geom; spatialFilter.WhereClause = "POP_RANK>5"; spatialFilter.SpatialRel = (ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum)spatialRel; //select features IFeatureSelection featureSelection = (IFeatureSelection)iSrcLayer; featureSelection.SelectFeatures(spatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false); ISelectionSet selectionSet = featureSelection.SelectionSet; ICursor cursor; selectionSet.Search(null, true, out cursor); IFeatureCursor featureCursor = cursor as IFeatureCursor; if (selectionSet.Count > 0) { DataBoard dataBoard = new DataBoard(iMap, dataOperator.GetDataTable(featureCursor, iSrcLayer)); dataBoard.cbEnabledFalse(); dataBoard.Show(); } return(true); }
public void ShowGeometry(IGeometry geometry) { //强制转换,将Geometry对象转化为pointCollection pointCollection = (Polygon)geometry; DataTable dataTable = new DataTable(); DataColumn dataColumn = new DataColumn(); //===创建一个有三列的表格==================== dataColumn = new DataColumn(); dataColumn.ColumnName = "number"; //设置第一列,表示用户指定的列名 dataColumn.DataType = System.Type.GetType("System.String"); dataColumn.ReadOnly = true; //第一列无法修改 dataTable.Columns.Add(dataColumn); dataColumn = new DataColumn(); dataColumn.ColumnName = "X";//设置第二列为在目标图层类作为分类标准的属性 dataColumn.DataType = System.Type.GetType("System.String"); dataTable.Columns.Add(dataColumn); dataColumn = new DataColumn(); dataColumn.ColumnName = "Y";//设置第三列为在目标图层类作为分类标准的属性 dataColumn.DataType = System.Type.GetType("System.String"); dataTable.Columns.Add(dataColumn); //提供一个图形的容器 pGraphicsContainer = m_map as IGraphicsContainer;//只在本函数 DataRow dataRow; for (int i = 0; i < pointCollection.PointCount; i++) { dataRow = dataTable.NewRow(); dataRow[0] = i + 1; dataRow[1] = Math.Round(pointCollection.Point[i].X, 3); dataRow[2] = Math.Round(pointCollection.Point[i].Y, 3);//将统计结果添加到第三列 dataTable.Rows.Add(dataRow); /*IElement pElement = new MarkerElementClass(); * pElement.Geometry = pointCollection.Point[i]; * pGraphicsContainer.AddElement(pElement, 0);//0 represents z-order */ //确定Element对象,并将对象加载到pGraphicsContainer中 IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass(); //markerSymbol的类型和分辨率 ((ISimpleMarker3DSymbol)markerSymbol).Style = esriSimple3DMarkerStyle.esriS3DMSSphere; ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0; //markerSymbol的颜色和大小 IRgbColor color = new RgbColorClass(); color.Red = 255; color.Green = 0; color.Blue = 0; markerSymbol.Size = 5; markerSymbol.Color = color as IColor; IElement pElement = new MarkerElementClass(); ((IMarkerElement)pElement).Symbol = markerSymbol; pElement.Geometry = pointCollection.Point[i]; pGraphicsContainer.AddElement(pElement, 0); } DataBoard dataBoard = new DataBoard("Position", dataTable, this, pointCollection.PointCount); dataBoard.Show(); m_form.setButton_miShowTime(false); }