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


  • 相关阅读:
    挑战安全的捉迷藏病毒和木马的隐藏手段
    如何清除局域网中的ARP病毒
    挑战安全的捉迷藏病毒和木马的隐藏手段
    MS07027:Internet Explorer本月累积性安全更新
    对Autorun.inf类U盘病毒的攻防经验总结
    对Autorun.inf类U盘病毒的攻防经验总结
    如何清除局域网中的ARP病毒
    挂马方式和系统判断等代码
    linux下phpMyAdmin泛起1045 Access denied for 的措置
    在ubuntu8.04上用evolution接受163邮件
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1394852.html
Copyright © 2011-2022 走看看