zoukankan      html  css  js  c++  java
  • 多个点连成多边形

    Description:

    This sample illustrates how to create a GeoPolygon object and display it as a graphic in ArcMap using a GeoPolygonElement. A GeoPolygon is a spheroid-aware polygon, the line segments of which are composed of GeoPolylines. A GeoPolygonElement is a spheroid-aware IElement object that dynamically updates its shape when the underlying geometry changes or is moved from one geographic location to another.
    Products: ArcView Minimum ArcGIS Release: 9.3

    How to use:
    1. Make sure to add a reference to the ESRI DefenseSolutions Object Library.
    2. Paste the code into VBA.
    3. Run the function from the Macros dialog.
    4. Select the GeoPolygonElement graphic and drag it to another location in the map and note how it changes.
    Public Sub MakeGeoPolygon()

    'get the MxDocument and ActiveView
    Dim pDoc As IMxDocument
    Set pDoc = ThisDocument
    Dim pView As IActiveView
    Set pView = pDoc.ActiveView
    Dim pMap As IMap
    Set pMap = pView.FocusMap

    'Create the base polygon geometry.
    Dim pColl As IPointCollection4
    Set pColl = New Polygon

    Dim pPoint As IPoint
    Set pPoint = New Point

    pPoint.PutCoords 0, 63
    pColl.AddPoint pPoint
    pPoint.PutCoords 7, 51
    pColl.AddPoint pPoint
    pPoint.PutCoords 14, 63
    pColl.AddPoint pPoint
    pPoint.PutCoords 24, 56
    pColl.AddPoint pPoint
    pPoint.PutCoords 33, 74
    pColl.AddPoint pPoint
    pPoint.PutCoords 17, 68
    pColl.AddPoint pPoint

    Dim pPoly As IPolygon4
    Set pPoly = pColl
    pPoly.Close

    'Set the spatial reference to that of the map
    Dim pSRMap As ISpatialReference
    Set pSRMap = pMap.SpatialReference
    Set pPoly.SpatialReference = pSRMap

    'Create the GeoPolygon object and set its base geometry to the original polygon
    Dim pGeoPoly As IGeoPolygon
    Set pGeoPoly = New GeoPolygon
    pGeoPoly.Polygon = pPoly

    'Set the properties of the GeoPolygon.
    '
    'Base spatial reference
    Set pGeoPoly.BaseSpatialReference = pMap.SpatialReference

    'geodesy geometry type for the line segments comprising the GeoPolygon.
    pGeoPoly.SpecialGeolineType = cjmtkSGTGeodesic

    'Create a GeoPolygonElement graphic element and set its geometry using the GeoPolygon.

    Dim pElement As IElement
    Set pElement = New GeoPolygonElement
    pElement.Geometry = pGeoPoly

    'Add the graphic to the map.
    Dim pGraph As IGraphicsContainer
    Set pGraph = pView.GraphicsContainer
    pGraph.AddElement pElement, 0

    pView.Refresh

    End Sub


  • 相关阅读:
    跟初学者学习IbatisNet第三篇
    跟初学者学习IbatisNet第二篇
    跟初学者学习IbatisNet第一篇
    读书时如何做读书笔记
    CCNET+MSBuild+SVN实现每日构建
    WebApi 通过类名获取类并实例化
    HttpClient设置代理
    dotnet core命令行启动如何支持如何找到进程
    redis 在Windows下的安装及基本操作(更新中~~~)
    Spring实现IoC的多种方式
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1394852.html
Copyright © 2011-2022 走看看