ArcGIS接口详细说明(10)

2019-08-31 17:37

Dim pField As IField Dim pFields As IFields Dim pFieldEdit As IFieldEdit Dim pFieldsEdit As IFieldsEdit Dim pGeometryDef As IGeometryDef Dim pGeometryDefEdit As IGeometryDefEdit

Set pFields = New Fields Set pFieldsEdit = pFields pFieldsEdit.FieldCount = 35

Set pField = New Field Set pFieldEdit = pField With pFieldEdit .Name = \ .AliasName = \ .Type = esriFieldTypeOID End With

Set pFieldsEdit.Field(0)= pField

Set pField = New Field Set pFieldEdit = pField pFieldEdit.Name = \

pFieldEdit.Type = esriFieldTypeGeometry

Set pGeometryDef = New GeometryDef Set pGeometryDefEdit = pGeometryDef With pGeometryDefEdit

.GeometryType = esriGeometryPolygon

Set .SpatialReference = New UnknownCoordinateSystem End With

Set pFieldEdit.GeometryDef= pGeometryDef

Set pFieldsEdit.Field(1)= pField

个人觉得,在创建shp文件时,运用上面的方法就可以创建,但是当在GDB中创建featureclass的时候就会出现问题,有可能是空间参考的问题。所以个人觉得当在GDB中创建时,还是将已有的Ifields传进来比较保险

=============================== 怎样实现翻折Flip方法: ===============================

(这个过程主要运用了IPolyline和IPolygon的ReverseOrientation方法,使其翻折)

Private Sub FlipFeature(pFeature As IFeature) Dim pGeom As IGeometry

If pFeature.Shape.GeometryType = esriGeometryPolyline Then Dim pPolyline As IPolyline Set pPolyline = pFeature.Shape pPolyline.ReverseOrientation Set pGeom = pPolyline

ElseIf pFeature.Shape.GeometryType = esriGeometryPolygon Then Dim pPolygon As IPolygon Set pPolygon = pFeature.Shape pPolygon.ReverseOrientation Set pGeom = pPolygon End If

Set pFeature.Shape = pGeom pFeature.Store

End Sub

好的,没问题,这是我随便写的,希望对你有用

Dim pTopoO As ITopologicalOperator Set pTopoO = pFeature.Shape Dim pEnv As IEnvelope Set pEnv = New Envelope pEnv.XMax = 100 pEnv.XMin = 90 pEnv.YMax = 100 pEnv.YMin = 90 pTopoO.Clip epnv pFeature.Store

===============================

回答机器猫FJJ关于ISpatialFilter接口方法的问题

===============================

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.Carto;

namespace Solutions {

public partial class Form1 : Form {

public Form1() {

InitializeComponent(); ILayer pLayer;

IFeatureLayer pFeatureLayer; IFeatureClass pFeatureClass; IFeatureCursor pFeatureCursor; IFeature pFeature; ISpatialFilter pSpatialFilter;

pSpatialFilter = new SpatialFilterClass();

pSpatialFilter.Geometry = pGeom; ///这个pGeom就是传进来的参数,就是你所谓的那个“选择了地图上的一块区域”

pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;

int layerCount = axMapControl1.LayerCount; for (int i = 0; i < layerCount; i++) {

pLayer = axMapControl1.get_Layer(i); pFeatureLayer = (IFeatureLayer)pLayer;

pFeatureClass = pFeatureLayer.FeatureClass; pFeatureCursor = pFeatureClass.Search((IQueryFilter)pSpatialFilter,false); pFeature = pFeatureCursor.NextFeature();

while (pFeature != null) {

listView1.Items.Add(pLayer.Name); } } } }

}

=============================== 回答网友韶华响当当关于更改符号的代码 ===============================

private void axTOC1_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e) {

esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone; IBasicMap basicMap = null; ILayer layer = null; object unk = null; object data = null;

axTOC1.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref unk, refdata);

if (e.button == 1) { if (itemType == esriTOCControlItem.esriTOCControlItemLegendClass) { //取得图例

ILegendClass pLegendClass =((ILegendGroup)unk).get_Class((int)data);

//创建符号选择器SymbolSelector实例

FormSymbolControl SymbolSelectorFrm= newFormSymbolControl(pLegendClass, layer);

if (SymbolSelectorFrm.ShowDialog()== DialogResult.OK) { //局部更新主Map控件

//m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

axMap1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

//设置新的符号

pLegendClass.Symbol = SymbolSelectorFrm.pSymbol; //更新主Map控件和图层控件 this.axMap1.ActiveView.Refresh(); this.axTOC1.Refresh(); } } } }

=============================== 回答网友韶华响当当关于显示属性的代码 ===============================

///

/// 填充DataTable中的数据 /// /// /// ///

public static DataTable CreateDataTable(ILayer pLayer, string tableName) {

//创建空DataTable DataTable pDataTable = CreateDataTableByLayer(pLayer, tableName); //创建DataTable的行对象 DataRow pDataRow = null;

//取得图层类型

string shapeType = getShapeType(pLayer);


ArcGIS接口详细说明(10).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2016民事诉讼法简答题汇总

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: