已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Userform1Public name, path As StringPrivate Sub CheckBox1_Click()drawing = pointUserForm1.HideEnd SubPrivate Sub CheckBox2_Click()drawing = findUserForm1.HideEnd SubPrivate Sub CommandButton1_Click()Dim pFeature As IFeatureDim pFeatureLayer As IFeatureLayerDim pMxDocument As IMxDocumentDim pMap As IMapDim pPoint As IPointDim pFeatClass As IFeatureClassDim a, b As Integer, x, y, z As DoubleDim c, name As StringCommonDialog1.Action = 1CommonDialog1.InitDir = d:CommonDialog1.Filter = GPS(*.txt)|*.txt|all files(*.*)|*.*CommonDialog1.FilterIndex = 1TextBox2.Text = CommonDialog1.FileNameOpen CommonDialog1.FileName For Input As #1a = 0Do While Not EOF(1)Line Input #1, inputdatac = inputdataGPS = Split(c, ,)lenth = Len(c)n = InStr(c, ,)name = Left(c, n - 1)r = Right(c, lenth - n)n = InStr(r, ,)y = Val(Left(r, n - 1)lenth = Len(r)r = Right(r, lenth - n)n = InStr(r, ,)x = Val(Left(r, n - 1)r = Right(r, lenth - n)lenth = Len(r)n = InStr(r, ,)r = Right(r, lenth - n)z = Val(r)Set pMxDocument = Application.DocumentSet pMap = pMxDocument.FocusMapSet pFeatureLayer = pMap.Layer(0)Set pFeatClass = pFeatureLayer.FeatureClassSet pFeature = pFeatClass.CreateFeatureSet pPoint = New PointpPoint.PutCoords GPS(2), GPS(1)Set pFeature.Shape = pPointpFeature.Value(2) = GPS(0)pFeature.Value(3) = GPS(2)pFeature.Value(4) = GPS(1)pFeature.Value(5) = GPS(3)pFeature.StoreLoopClose #1UserForm1.HidepMxDocument.ActivatedView.RefreshEnd SubPrivate Sub CommandButton2_Click()Dim pFeatureWorkspace As IFeatureWorkspaceDim pWorkspaceFactory As IWorkspaceFactoryDim pFields As IFieldsDim pFieldsEdit As IFieldsEditDim pField As IFieldDim pFieldEdit As IFieldEditDim pGeometryDef As IGeometryDefDim pGeometryDefEdit As IGeometryDefEditDim pSpatialFilter As ISpatialFilterDim pFeature As IFeatureDim pFeatureLayer As IFeatureLayerDim pMxDocument As IMxDocumentDim pMap As IMapDim pPoint As IPointDim pFeatClass As IFeatureClassDim pActiveView As IActiveViewDim sShapeFieldName As StringDim sNewShapeFileName As StringDim sFilePath As StringDim sFileName As StringDim i As IntegersFilePath = pathsFileName = nameOn Error GoTo ErrorHandler:sNewShapeFileName = Dir(sFilePath & sFileName & .shp)If (sNewShapeFileName ) ThenMsgBox (文件已经存在)Exit SubEnd IfsShapeFieldName = ShapeOpen the folder to contain the shapefile as a workspaceSet pWorkspaceFactory = New ShapefileWorkspaceFactorySet pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(sFilePath, 0)Set up a simple fields collectionSet pFields = New FieldsSet pFieldsEdit = pFieldsMake the shape fieldit will need a geometry definition, with a spatial referenceSet pField = New FieldSet pFieldEdit = pFieldpFieldE = sShapeFieldNamepFieldEdit.Type = esriFieldTypeGeometrySet pGeometryDef = New GeometryDefSet pGeometryDefEdit = pGeometryDefWith pGeometryDefEdit.GeometryType = esriGeometryPointSet .SpatialReference = New UnknownCoordinateSystemEnd WithSet pFieldEdit.GeometryDef = pGeometryDefpFieldsEdit.AddField pFieldAdd others miscellaneous text fieldSet pField = New FieldSet pFieldEdit = pFieldWith pFieldE = Name.Type = esriFieldTypeString.Editable = True.Precision = 2End WithpFieldsEdit.AddField pFieldSet pField = New FieldSet pFieldEdit = pFieldWith pFieldE = x.Type = esriFieldTypeDouble.Editable = TrueEnd WithpFieldsEdit.AddField pFieldSet pField = New FieldSet pFieldEdit = pFieldWith pFieldE = y.Type = esriFieldTypeDouble.Editable = True.Precision = 2End WithpFieldsEdit.AddField pFieldSet pField = New FieldSet pFieldEdit = pFieldWith pFieldE = z.Type = esriFieldTypeDouble.Editable = TrueEnd WithpFieldsEdit.AddField pFieldCreate the shapefile(some parameters apply to geodatabase options and can be defaulted as Nothing)Set pFeatClass = pFeatureWorkspace.CreateFeatureClass _(sFileName, pFields, Nothing, Nothing, _esriFTSimple, sShapeFieldName, )sNewShapeFileName = Dir(sFilePath & MyShapeFile.shp)If (sNewShapeFileName = ) ThenMsgBox (Build Success)ElseMsgBox (Build Fail)End IfExit SubSet pFeatureLayer = New FeatureLayerSet pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass(sFileName)pFeatureL = pFeatureLayer.FeatureClass.AliasNameAdd the FeatureLayer to the focus mapSet pMxDocument = Application.DocumentSet pMap = pMxDocument.FocusMappMap.AddLayer pFeatureLayerSet pMxDocument = Application.DocumentSet pMap = pMxDocument.FocusMapEnd SubPrivate Sub CommandButton3_Click()Dim po As Integer, fname As Stringpo = 0TextBox1.Text = TextBox2.Text = CommonDialog1.Action = 2CommonDialog1.Filter = all files(*.*)|*.*TextBox1.Text = CommonDialog1.FileNamefname = CommonDialog1.FileNameDo While che 1po = po + 1name = Right(fname, po)che = Left(InStr(Right(fname, po), ), 1)Loopname = Right(name, Len(name) - 1)path = Left(fname, InStr(fname, name) - 1)End SubModulesPublic drawing As StringthisdocumentPrivate Sub UIButtonControl1_Click()UserForm1.ShowEnd SubPrivate Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long) If drawing = point Then Dim pMxDoc As IMxDocument Dim pMap As IMap Dim pActiveView As IActiveView Dim pScreenDisplay As IScreenDisplay Dim pPoint As IPoint Dim pFeatureLayer As IFeatureLayer Dim pFeatClass As IFeatureClass Dim pFeature As IFeature Static n As Integer n = n + 1 Set pMxDoc = Application.Document Set pMap = pMxDoc.FocusMap Set pActiveView = pMxDoc.FocusMap Set pScreenDisplay = pActiveView.ScreenDisplay With pScreenDisplay .StartDrawing pScreenDisplay.hDC, esriNoScreenCache .SetSymbol New SimpleMarkerSymbol .DrawPoint pMxDoc.CurrentLocation .FinishDrawing End With Set pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y) Set pFeatureLayer = pMap.Layer(0) Set pFeatClass = pFeatureLayer.FeatureClass Set pFeature = pFeatClass.CreateFeature pPoint.PutCoords pPoint.x, pPoint.y Set pFeature.Shape = pPoint pFeature.Value(2) = GPS & n pFeature.Value(3) = pPoint.x pFeature.Value(4) = pPoint.y pFeature.Store pMxDoc.ActivatedView.Refresh ElseIf drawing = find Then Set pMxDoc = Application.Document Set pActiveView = pMxDoc.FocusMap Create a search point Set pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y) Pass the point to the FindFeature function along with the Map and search tolerance Set pFeature = FindFeature(pMxDoc.SearchTolerance, pPoint, pMxDoc.FocusMap) Message box the feature ID and feature class alias name If Not pFeature Is Nothing Then MsgBox pFeature.OID & & pFeature.Class.AliasNameEnd IfEnd SubPrivate Function FindFeature(SearchTol As Double, pPoint As IPoint, pMap As IMap) As IFeature Dim pEnvelope As IEnvelope Dim pSpatialFilter As ISpatialFilter Dim pEnumLayer As IEnumLayer Dim pFeatureLayer As IFeatureLayer Dim pFeatureClass As IFeatureClass Dim pFeatureCursor As IFeatureCursor Dim pFeature As IFeature Dim pUID As New UID Dim ShapeFieldName As String If pMap.LayerCount = 0 Then Exit Function Expand the points envelope to give better search results Set pEnvelope = pPoint.Envelope pEnvelope.Expand SearchTol, SearchTol, False Create a new spatial filter and use the new envelope as the geometry Set pSpatialFilter = New SpatialFilter Set pSpatialFilter.Geometry = pEnvelope pSpatialFilter.SpatialRel = esriSpatialRelIntersects Search each selectable feature layer for a feature Return the first feature found pUID = 40A
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 执业兽医考试题库大全附答案满分必刷
- 2026年高压电工作业(复审)模拟考试题库试卷及答案
- 2026年办公设备维修绿色认证申请
- 智慧高速公路路网运行联动机制
- 太阳能供暖技术课件
- 学校实验室设备更新方案
- 铁路桥梁建设项目工程勘察方案
- 隧道洞身开挖施工方案
- 尾矿库坝体压实质量评估报告
- 学校新建工程勘察方案
- 2026年保山市腾冲市紧密型医共体招聘编制外合同制人员(108人)考试模拟试题及答案解析
- 2026年南京大学事业编制岗位公开招聘15人备考题库(含答案详解)
- (2026秋新版)统编版道德与法治六年级上册全册教案
- 2026年度中国广电山东网络有限公司市县公司招聘(232个岗位)笔试历年备考题库附带答案详解
- 2026年未成年人保护法知识竞赛题库(含答案)
- 东西文化碰撞中的艺术嬗变交流与传承
- 2026年超星尔雅学习通《大学生国家安全教育》章节题库练习备考题附完整答案详解【必刷】
- 2026年龙江银行招聘笔试题库附答案
- 国网电力安全工作规程(配电部分)13-17章
- 2025年高二语文上册(统编版选择性必修上)期中考试题(1)(后附答案)
- JG/T 461-2014倒T形预应力叠合模板
评论
0/150
提交评论