zoukankan      html  css  js  c++  java
  • 生成N个点的工具,和生成N个多边形的工具

    //后来发现插入feature,可以不用
        pWorkSpaceEdit.StartEditing True
        pWorkSpaceEdit.StartEditOperation

    *********************************
        pWorkSpaceEdit.StopEditing True
        pWorkSpaceEdit.StopEditOperation

    //编辑的时候才需要
    Private Sub CommandButton1_Click()

    Dim PolyCount As Integer
    PolyCount = Val(TextBox1.Text)
    Dim i As Integer

    Dim pMxDoc As IMxDocument
    Set pMxDoc = Application.Document

    Dim pMap As IMap
    Set pMap = pMxDoc.FocusMap

    Dim pActiveView As IActiveView
    Set pActiveView = pMxDoc.FocusMap

    Dim pFeaturelayer As IFeatureLayer
    Set pFeaturelayer = pMap.Layer(0)

    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeaturelayer.FeatureClass


    Dim pDataSet As IDataset
    Set pDataSet = pFeatureClass

    Dim pWorkSpace As IWorkspace
    Set pWorkSpace = pDataSet.Workspace

    Dim pWorkSpaceEdit As IWorkspaceEdit
    Set pWorkSpaceEdit = pWorkSpace


        pWorkSpaceEdit.StartEditing True
        pWorkSpaceEdit.StartEditOperation

        
        For i = 0 To PolyCount - 1
        
        Dim pFeature As IFeature
        Set pFeature = pFeatureClass.CreateFeature
        Dim pPoint As IPoint
        Set pPoint = New Point
        pPoint.PutCoords 10000000000000# * Rnd, 10000000000000# * Rnd
        Set pFeature.Shape = pPoint
        Dim pFields As IFields
        Set pFields = pFeatureClass.Fields
        Dim idx As Integer
        idx = pFields.FindField("Name")
        pFeature.Value(idx) = "武汉" & i
        pFeature.Store
        
        Next i
        
        pActiveView.Refresh
     
     
    pWorkSpaceEdit.StopEditing True

    End Sub

    ‘=======================================

    Private Sub CommandButton1_Click()

    Dim PolyCount As Integer
    PolyCount = Val(TextBox1.Text)
    Dim i As Integer

    Dim pMxDoc As IMxDocument
    Set pMxDoc = Application.Document

    Dim pMap As IMap
    Set pMap = pMxDoc.FocusMap

    Dim pActiveView As IActiveView
    Set pActiveView = pMxDoc.FocusMap

    Dim pFeaturelayer As IFeatureLayer
    Set pFeaturelayer = pMap.Layer(0)

    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeaturelayer.FeatureClass


    Dim pDataSet As IDataset
    Set pDataSet = pFeatureClass

    Dim pWorkSpace As IWorkspace
    Set pWorkSpace = pDataSet.Workspace

    Dim pWorkSpaceEdit As IWorkspaceEdit
    Set pWorkSpaceEdit = pWorkSpace

        pWorkSpaceEdit.StartEditing True
        pWorkSpaceEdit.StartEditOperation

        
        For i = 0 To PolyCount - 1
        
        Dim pFeature As IFeature
        Set pFeature = pFeatureClass.CreateFeature
        Dim pPointCollection4 As IPointCollection4
        Set pPointCollection4 = New Polygon
        Dim pPolygon As IPolygon
        Set pPolygon = pPointCollection4
        
        Dim pPoint As IPoint
        Set pPoint = New Point
        pPoint.PutCoords 571 * Rnd - 450, 351 * Rnd - 90
        pPointCollection4.AddPoint pPoint
        
     
        Set pPoint = New Point
        pPoint.PutCoords 571 * Rnd - 450, 351 * Rnd - 90
         pPointCollection4.AddPoint pPoint
     
        Set pPoint = New Point
        pPoint.PutCoords 571 * Rnd - 450, 351 * Rnd - 90
        pPointCollection4.AddPoint pPoint
         
         
        Set pFeature.Shape = pPolygon
        Dim pFields As IFields
        Set pFields = pFeatureClass.Fields
        Dim idx As Integer
        idx = pFields.FindField("Name")
        pFeature.Value(idx) = "武汉" & i
        pFeature.Store
        
        Next i
        
        pActiveView.Refresh
     
     
    pWorkSpaceEdit.StopEditing True
    End Sub

     

  • 相关阅读:
    慕课网多物体运动源代码
    慕课网javascript动画特效 多透明度 源代码
    百度地图实时侦听鼠标滚轮获取地图zoom缩放级别
    百度地图自定义地图切片问题
    百度地图之多点步行路径连线问题
    百度地图利用数组实现多个标注点的显示
    理解clear: left/clear: right
    CSS3 Transform属性详解
    setInterval() 方法
    for Share
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1395420.html
Copyright © 2011-2022 走看看