阅读:2835回复:8
angine有没办法计算面积
刚开始学习angine,做了点东西,都是抄这抄那,这个计算面的面积或者是线的长度等,好像找不到,希望大侠可以指点一下,最好能奉献出源码,感激!!
|
|
1楼#
发布于:2005-08-08 15:33
<P>.length</P>
<P>.area</P> <P>在帮助里查看下</P> |
|
|
2楼#
发布于:2005-08-08 15:46
多谢大侠!
|
|
3楼#
发布于:2005-08-16 22:19
area函数还要注意正负
|
|
4楼#
发布于:2005-08-18 22:10
<P>已经调试成功!刚脆把代码贴出来一起分享.</P>
<P>Public Sub SelectMouseDown(x As Long, y As Long)<BR> Dim pFeatureLayer As IFeatureLayer<BR> Dim pFeatureClass As IFeatureClass<BR> Dim pSpatialFilter As ISpatialFilter<BR> Dim pFilter As IQueryFilter<BR> Dim pActiveView As IActiveView<BR> Dim pGeometry As IGeometry<BR> Dim pPoint As IPoint<BR> <BR> <BR> <BR> On Error GoTo SelectMouseDown_err<BR> <BR> If m_pCurrentLayer Is Nothing Then Exit Sub<BR> If Not TypeOf m_pCurrentLayer Is IGeoFeatureLayer Then Exit Sub<BR> <BR> ' Get the feature layer and class of the current layer<BR> Set pFeatureLayer = m_pCurrentLayer<BR> Set pFeatureClass = pFeatureLayer.FeatureClass<BR> <BR> If pFeatureClass Is Nothing Then Exit Sub<BR> <BR> ' Get the mouse down position in map coordinates<BR> Set pActiveView = m_pMap<BR> Set pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y)<BR> Set pGeometry = pPoint<BR> <BR> ' Use a four pixel buffer around the cursor for feature search<BR> Dim length As Double<BR> length = ConvertPixelsToMapUnits(m_pMap, 4)<BR> Dim pTopo As ITopologicalOperator<BR> Set pTopo = pGeometry<BR> Dim pBuffer As IGeometry<BR> Set pBuffer = pTopo.Buffer(length)<BR> Set pGeometry = pBuffer.Envelope<BR> <BR> ' Set up a Filter specific to this layer<BR> Set pSpatialFilter = New SpatialFilter<BR> Set pSpatialFilter.Geometry = pGeometry<BR> Select Case pFeatureClass.ShapeType<BR> Case esriGeometryPoint<BR> pSpatialFilter.SpatialRel = esriSpatialRelContains<BR> Case esriGeometryPolyline<BR> pSpatialFilter.SpatialRel = esriSpatialRelCrosses<BR> Case esriGeometryPolygon<BR> pSpatialFilter.SpatialRel = esriSpatialRelIntersects<BR> <BR> End Select<BR> pSpatialFilter.GeometryField = pFeatureClass.ShapeFieldName<BR> Set pFilter = pSpatialFilter<BR> <BR> ' Do the search<BR> Dim pCursor As IFeatureCursor<BR> Set pCursor = pFeatureLayer.Search(pFilter, False)<BR> <BR> ' and select the features on the map<BR> Dim pFeature As iFeature<BR> Set pFeature = pCursor.NextFeature<BR> <BR> Dim pArea As IArea '面积<BR> Dim pCurve As ICurve '周长<BR> Dim pCenter As IPoint<BR> Dim pLabel As IPoint<BR> Dim Pstr As String<BR> Set pCenter = New Point<BR> Set pLabel = New Point<BR> <BR> <BR> <BR> While Not pFeature Is Nothing<BR> Select Case pFeature.Shape.GeometryType '计算面积<BR> Case esriGeometryPolygon<BR> Set pArea = pFeature.Shape<BR> Set pCurve = pFeature.Shape<BR> Pstr = "长度:" + CStr(Abs(Round(pCurve.length, 3))) + " 面积:" + CStr(Abs(Round(pArea.Area, 3)))<BR> Case esriGeometryPolyline<BR> Set pCurve = pFeature.Shape<BR> Pstr = "长度:" + CStr(Abs(Round(pCurve.length, 3)))<BR> Case Else<BR> Pstr = ""<BR> End Select<BR> <BR> m_pMap.SelectFeature m_pCurrentLayer, pFeature<BR> Set pFeature = pCursor.NextFeature<BR> Wend<BR> pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing<BR> <BR> frmMain.StatusBar1.Panels(2).Text = Pstr<BR> <BR> ClearSelect<BR> Exit Sub<BR>SelectMouseDown_err:<BR> MsgBox Err.Description<BR>End Sub</P> <img src="images/post/smile/dvbbs/em04.gif" /> |
|
5楼#
发布于:2005-08-20 14:22
<img src="images/post/smile/dvbbs/em01.gif" />好同志。<img src="images/post/smile/dvbbs/em08.gif" />
|
|
6楼#
发布于:2005-10-13 09:27
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em05.gif" /><img src="images/post/smile/dvbbs/em07.gif" /><img src="images/post/smile/dvbbs/em08.gif" />
|
|
7楼#
发布于:2007-06-24 17:13
xiexie
|
|
8楼#
发布于:2008-02-16 20:33
xiexie,i love you
|
|