using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
namespace yanShi
{
public partial class frmIdentify : Form
{
IActiveView mActiveView = null;
ISpatialFilter mSpatialFilter = new SpatialFilterClass();
public frmIdentify()
{
InitializeComponent();
}
public frmIdentify(IActiveView fActiveView, IPoint fPoint)
{
InitializeComponent();
mActiveView = fActiveView;
IFeatureLayer pFeatureLayer = mActiveView.FocusMap.get_Layer(0) as IFeatureLayer;
mSpatialFilter.Geometry = fPoint as IGeometry;
mSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin;
IdentifyFirstFeatureFromPointSearchInFeatureLayer(pFeatureLayer, mSpatialFilter);
}
private void cbxTuCeng_DropDown(object sender, EventArgs e)
{
IMap pMap = mActiveView.FocusMap;
cbxTuCeng.Items.Clear();
for (int i = 0; i < pMap.LayerCount; i++)
{
cbxTuCeng.Items.Add(pMap.get_Layer(i).Name);
}
}
private void cbxTuCeng_SelectedIndexChanged(object sender, EventArgs e)
{
string layerName = cbxTuCeng.SelectedItem.ToString();
SnippetLayer sl = new SnippetLayer();
int layerIndex = sl.GetIndexNumberFromLayerName(mActiveView, layerName);
IFeatureLayer pFeatureLayer = sl.GetFeatureLayerFromLayerIndexNumber(mActiveView, layerIndex);
IdentifyFirstFeatureFromPointSearchInFeatureLayer(pFeatureLayer, mSpatialFilter);
}
private void IdentifyFirstFeatureFromPointSearchInFeatureLayer(IFeatureLayer fFeatureLayer, ISpatialFilter fSpatialFilter)
{
IFeatureClass pFeatureClass = fFeatureLayer.FeatureClass;
IFeatureCursor pFeatureCursor = pFeatureClass.Search(fSpatialFilter, false);
DataTable pDataTable = new DataTable();
pDataTable.Columns.Add("字段");
pDataTable.Columns.Add("值");
IFields pFields = pFeatureClass.Fields;
IFeature pFeature = pFeatureCursor.NextFeature();
if (pFeature != null)
{
for (int i = 0; i < pFields.FieldCount; i++)
{
DataRow row = pDataTable.NewRow();
IField pField = pFields.get_Field(i);
row["字段"] = pField.Name;
row["值"] = pFeature.get_Value(i);
pDataTable.Rows.Add(row);
}
}
dgvInfo.DataSource = pDataTable;
}
private string ShapeToChinese(esriGeometryType fesriGeometryType)
{
string shapeCh = "";
switch (fesriGeometryType)
{
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
shapeCh="点";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint:
shapeCh = "多点";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryLine:
shapeCh="线段";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryCircularArc:
shapeCh="圆弧";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryEllipticArc:
shapeCh="椭圆弧";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryBezier3Curve:
shapeCh="三次贝塞尔曲线";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPath:
shapeCh="路径";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
shapeCh ="折线";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryRing:
shapeCh="环";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
shapeCh="多边形";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryEnvelope:
shapeCh="矩形范围";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryAny:
shapeCh="任意几何体";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryBag:
shapeCh="几何体集合";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultiPatch:
shapeCh="表面面片集合";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryTriangleStrip:
shapeCh="三角形带";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryTriangleFan:
shapeCh="三角形扇";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryRay:
shapeCh="射线";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometrySphere:
shapeCh="球体";
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryTriangles:
shapeCh = "三角形面片";
break;
default:
shapeCh = "未知类型几何体";
break;
}
return shapeCh;
}
}
}
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/Chckx/article/details/139812810