|
阅读:1015回复:1
Area Example
<P>Area Example<BR>' The example shows how to get the properties for a selected polygon in<BR>' an ArcMap edit session.</P>
<P>Public Sub t_IArea_polygon()<BR> Dim pID As New UID<BR> pID = "esriEditor.editor"<BR> Dim pEditor As IEditor<BR> Dim pApp As IApplication<BR> Set pApp = Application<BR> Set pEditor = pApp.FindExtensionByCLSID(pID)<BR> <BR> If pEditor.SelectionCount <> 1 Then<BR> MsgBox "select one polygon"<BR> Exit Sub<BR> End If<BR> <BR> Dim pEnumFeat As IEnumFeature<BR> Dim pFeature As IFeature<BR> Dim i As Long</P> <P> Set pEnumFeat = pEditor.EditSelection</P> <P> Dim pArea As IArea<BR> Dim pCenter As IPoint<BR> Dim pLabel As IPoint<BR> Set pCenter = New Point<BR> Set pLabel = New Point</P> <P> Set pFeature = pEnumFeat.Next</P> <P> While Not pFeature Is Nothing<BR> If pFeature.Shape.GeometryType = esriGeometryPolygon Then<BR> Set pArea = pFeature.Shape<BR> MsgBox "+++Polygon::IArea properties..." ; vbCrLf _<BR> ; "Area = " ; pArea.Area ; vbCrLf _<BR> ; "Center.X = " ; pArea.Centroid.X ; vbCrLf _<BR> ; "Center.Y = " ; pArea.Centroid.Y ; vbCrLf _<BR> ; pArea.LabelPoint.X ; vbCrLf _<BR> ; "LabelPoint.Y = " ; pArea.LabelPoint.Y</P> <P> pArea.QueryCentroid pCenter<BR> pArea.QueryLabelPoint pLabel<BR> MsgBox "+++Polygon::IArea Queries..." ; vbCrLf _<BR> ; "Center = " ; pCenter.X ; "," ; pCenter.Y ; vbCrLf _<BR> ; "Label = " ; pLabel.X ; "," ; pLabel.Y ; vbCrLf</P> <P> End If<BR> Set pFeature = pEnumFeat.Next<BR> Wend</P> <P>End Sub</P> |
|
|
1楼#
发布于:2007-05-01 19:01
谢谢!
|
|