logo资料库

AE创建各种类型的featureclass代码.pdf

第1页 / 共49页
第2页 / 共49页
第3页 / 共49页
第4页 / 共49页
第5页 / 共49页
第6页 / 共49页
第7页 / 共49页
第8页 / 共49页
资料共49页,剩余部分请下载后查看
AE中新建shapefile,自定义字段
AE中创建各类型的featureclass代码
AE+C#实现鹰眼功能(带鼠标拖动)
FeatureLayer,FeatureDataset,FeatureClass,Feature概念总结
新建shapefile,自定义字段,新加入记录
图层属性操作一
矢量转栅格
AE中的Maps和Layers
AE+C# 实现MERGE
C#基础:ref和out的区别
ArcEngine 中的Spatial Refrence
对象模型图【OMD】阅读指南
Engine许可初始化
SelectByShape实现矩形选择要素
利用 IIdentifyDialog 模拟ArcMap工具里面 Identify功能进行要素查询
ArcEngine中对Feature的编辑
AE 中新建 shapefile,自定义字段 代码由 ESRI 社区 GIScafe 提供 IFields pFields = new FieldsClass(); IFieldsEdit pFieldsEdit = pFields as IFieldsEdit; IField pField = new FieldClass(); IFieldEdit pFieldEdit = pField as IFieldEdit; pFieldEdit.Name_2 = "shape"; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeome try; //set up Geometry Definition IGeometryDef pGeometryDef = new GeometryDefClass(); IGeometryDefEdit pGeometryDefEdit = pGeometryDef a s IGeometryDefEdit; pGeometryDefEdit.GeometryType_2 = esriGeometryType.e sriGeometryPoint; //Point,line,polygon et. pGeometryDefEdit.SpatialReference_2 = axMapControl1. SpatialReference; pFieldEdit.GeometryDef_2 = pGeometryDef; pFieldsEdit.AddField(pField); //新建字段 pField = new FieldClass(); pFieldEdit = pField as IFieldEdit; pFieldEdit.Length_2 = 15; pFieldEdit.Name_2 = "SchoolName";
pFieldEdit.AliasName_2 = "SchoolName"; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeStrin g; pFieldsEdit.AddField(pField); string mappath = @"E:\data"; string layername="school"; IWorkspaceFactory pWorkspaceFactory = new ShapefileW orkspaceFactory(); IFeatureWorkspace pFeatureWorkspace = pWorkspaceFact ory.OpenFromFile(mappath,0) as IFeatureWorkspace; pFeatureWorkspace.CreateFeatureClass(layername+".shp ",pFields,null,null,esriFeatureType.esriFTSimple,"shape",""); axMapControl1.AddShapeFile(mappath,layername+".shp "); 代码中路径名称可以自定义 posted on 2008-07-12 15:28 duckweeds 阅读(137) 评论(0) 编辑 收藏 网摘 所属分类: AE+C# AE 创建各种类型的 featureclass 代码 VB.Net 源码 ''' ''' 创建 Annotation 类型的 featureclass
''' ''' annotation 的工作空间 ''' annotation 的 symbol ''' annotation 的比例 ''' annotation 的名称 ''' 创建的 Annotation Featureclass ''' Private Function CreateAnnoFeatCls(ByVal pWorkspace As IFeatureWorkspace, ByVal pTextSymbol As ITextSymbol, ByVal pRefeScale As Double, ByVal pAnnoFeatName As String, Optional ByVal pSymbolID As Integer = 0) As IFeatureClass Dim pField As IField Dim pFields As IFields Dim pSource As IClone Dim pObjectClassDesc As IObjectClassDescription Dim pFeatClassDesc As IFeatureClassDescription ''创建 Annotation 的 Fields pObjectClassDesc = New AnnotationFeatureClassDescription pFeatClassDesc = pObjectClassDesc pSource = pObjectClassDesc.RequiredFields pFields = pSource.Clone ''创建 Annotation 的 Geometry defintion pField = pFields.Field(pFields.FindField(pFeatClassDesc.ShapeFieldName)) ''创建 Reference scale Dim pGraphicsLayerScale As IGraphicsLayerScale
pGraphicsLayerScale = New GraphicsLayerScale pGraphicsLayerScale.ReferenceScale = pRefeScale pGraphicsLayerScale.Units = esriUnits.esriMeters ''创建 Symbolcollection Dim pSymbolColl As ISymbolCollection2 Dim pSymbolIdent As ISymbolIdentifier2 = New SymbolIdentifier pSymbolColl = New SymbolCollection pSymbolColl.AddSymbol(pTextSymbol, "Default", pSymbolIdent) If pSymbolID = 1 Then pSymbolColl.AddSymbol(pTextSymbol, "Default 1", pSymbolIdent) ''创建 Label 的相关属性 Dim pOverposterProperties As IOverposterProperties Dim pAnnoPropsColl As IAnnotateLayerPropertiesCollection Dim pLabelEngineLP As ILabelEngineLayerProperties Dim pAnnotateLayerProps As IAnnotateLayerProperties pOverposterProperties = New BasicOverposterProperties pAnnoPropsColl = New AnnotateLayerPropertiesCollection pLabelEngineLP = New LabelEngineLayerProperties pAnnotateLayerProps = pLabelEngineLP pAnnotateLayerProps.Class = "Default" pLabelEngineLP.Symbol = pTextSymbol pLabelEngineLP.SymbolID = pSymbolIdent.ID pAnnoPropsColl.Add(pLabelEngineLP)
''创建 Annotation layer Dim pAnnoLayerFactory As IAnnotationLayerFactory Dim pAnnoLayer As IAnnotationLayer pAnnoLayerFactory = New FDOGraphicsLayerFactory pAnnoLayer = pAnnoLayerFactory.CreateAnnotationLayer(pWorkspace, Nothing, pAnnoFeatName, pField.GeometryDef, Nothing, pAnnoPropsColl, pGraphicsLayerScale, pSymbolColl, False, False, False, True, pOverposterProperties, "") Return CType(pAnnoLayer, IFeatureLayer).FeatureClass End Function ''' ''' 创建存于 Shapefile 中的 featureclass ''' ''' ''' ''' ''' ''' ''' ''' ''' ''' Public Shared Function CreateShapefile(ByVal sDir As String, ByVal sName As String, ByVal shapeType As esriGeometryType, _ ByVal hasM As Boolean, ByVal hasZ As Boolean, ByVal pSR As ISpatialReference, ByVal pFields As IFields) As IFeatureClass
Try Dim shapeWorkspaceFactory As IWorkspaceFactory shapeWorkspaceFactory = New ShapefileWorkspaceFactory Dim shapeWorkspace As IFeatureWorkspace shapeWorkspace = shapeWorkspaceFactory.OpenFromFile(sDir, 0) If (Not shapeWorkspace Is Nothing) Then If pFields Is Nothing Then pFields = CreateBasicFields(shapeType, hasM, hasZ, pSR) ' Dim pFClass As IFeatureClass pFClass = shapeWorkspace.CreateFeatureClass(sName, pFields, Nothing, Nothing, esriFeatureType.esriFTSimple, "Shape", "") Return pFClass End If Return Nothing Catch ex As Exception MsgBox(ex.Message) Return Nothing End Try End Function ''' ''' 创建存于内存中的 Featureclass ''' ''' '''
''' ''' Public Shared Function GetSimpleFeatureClass(ByVal pFields As IFields, ByVal featureClassName As String) As IFeatureClass Try Dim pSwf As IWorkspaceFactory = New InMemoryWorkspaceFactory Dim pWorkspaceName As IWorkspaceName = pSwf.Create("", "MyWorkspace", Nothing, 0) Dim pFWS As IFeatureWorkspace = CType(pWorkspaceName, IName).Open() Dim pFC As IFeatureClass = pFWS.CreateFeatureClass(featureClassName, pFields, Nothing, Nothing, esriFeatureType.esriFTSimple, "Shape", Nothing) Return pFC Catch ex As Exception Return Nothing End Try End Function ''' ''' 创建存于 Access 中的 featureclass ''' ''' ''' ''' ''' ''' '''
Public Function CreateAccessFeatureClass(ByVal pFields As IFields, ByVal pAccessPath As String, ByVal pAccessName As String, ByVal featureClassName As String) As IFeatureClass Try Dim pSwf As IWorkspaceFactory = New ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactory Dim pWorkspaceName As IWorkspaceName = pSwf.Create(pAccessPath, pAccessName, Nothing, 0) Dim pFWS As IFeatureWorkspace = CType(pWorkspaceName, IName).Open() pFields = CreateBasicFields(esriGeometryType.esriGeometryPoint, False, False, New UnknownCoordinateSystem) Dim pFC As IFeatureClass = pFWS.CreateFeatureClass(featureClassName, pFields, Nothing, Nothing, esriFeatureType.esriFTSimple, "Shape", Nothing) Return pFC Catch ex As Exception Return Nothing End Try End Function AE+C#实现鹰眼功能——(二)(带鼠标拖动) vs2005+AE9.2 实现,主要功能:鹰眼视图里面鼠标左键画红框,右键拖动 代码中主视图为 Mapcontrol1,鹰眼视图为 MapControl2。 主要利用了 Envelope 进行视图范围传递,从而控制视图同步等。 代码如下: 几个变量声明 : //变量 IMapDocument pMapDocument = new MapDocumentClass(); IEnvelope pEn = new EnvelopeClass(); object oFillobject = new object(); private void CreateOverviewSymbol()
分享到:
收藏