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


  • 相关阅读:
    大话设计模式-——简答工厂模式
    大话设计——-单例模式
    首先,编写一个类ChongZai,该类中有3个重载的方法void print();其次, 再编写一个主类来测试ChongZai类的功能
    创建一个Point类,有成员变量x,y,方法getX(),setX(),还有一个构造方 法初始化x和y。创建类主类A来测试它
    正则表达式
    struts(一)
    servlet容器开发要点
    Http协议
    TCP的四次挥手
    建立TCP连接的三次握手
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1394852.html
Copyright © 2011-2022 走看看