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


  • 相关阅读:
    linux 查找最后几条数据
    O(n) 取得数组中每个元素右边最后一个比它大的元素
    O(n) 取得数组中每个元素右边第一个比它大的元素
    位运算实现整数运算
    随手练——P1141 01迷宫
    迷宫寻路问题全解
    N皇后问题 各种优化
    八数码问题(三种解决办法)
    随手练——Uva-11584 划分成回文串(区间DP)
    【2016蓝桥杯省赛】试题C++ B组试题
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1394852.html
Copyright © 2011-2022 走看看