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


  • 相关阅读:
    Supervisord管理进程实践
    centos7优化启动项,关闭一些不必要开启的服务
    centos彻底删除文件夹、文件命令(centos 新建、删除、移动、复制等命令)讲解
    CentOS 7 vi编辑命令
    C# 23种设计模式汇总
    设计模式——速记口诀
    CentOS 7.x设置自定义开机启动,添加自定义系统服务
    T-SQL 之 事务
    T-SQL 之 触发器
    T-SQL 之 表变量和临时表
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1394852.html
Copyright © 2011-2022 走看看