happydust
路人甲
路人甲
  • 注册日期2004-12-31
  • 发帖数25
  • QQ
  • 铜币122枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1718回复:3

AO如何实现几何体边界的光滑???

楼主#
更多 发布于:2005-08-04 03:05
<P><STRONG><FONT color=#000066>我想通过AO对POLYGON的边界进行光滑处理,只能找到Smooth 方法这个方法对Polygon和Ring的边界的光滑处理会出现重叠的现象 ,有没有那位仁兄做过相关的程序,或者能不能给点思路,谢谢!!!</FONT></STRONG></P>
[此贴子已经被作者于2005-8-5 0:00:34编辑过]
喜欢0 评分0
happydust
路人甲
路人甲
  • 注册日期2004-12-31
  • 发帖数25
  • QQ
  • 铜币122枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2005-08-05 00:06
Beg  for your help!
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
2楼#
发布于:2005-08-05 17:30
<P>看看下面</P>
<P>Option Explicit<BR>Private Sub UIButtonControl1_Click()<BR>    '<BR>    ' smooth each ring of each selected polygon<BR>    '<BR>    Dim pUID As New UID<BR>    pUID.Value = "esriCore.Editor"<BR>    <BR>    Dim pEditor As IEditor<BR>    Set pEditor = Application.FindExtensionByCLSID(pUID)<BR>    <BR>    If pEditor.EditState <> esriStateEditing Then<BR>        MsgBox "not editing"<BR>        Exit Sub<BR>    End If<BR>    <BR>    Dim pEL As IEditLayers<BR>    Set pEL = pEditor<BR>    <BR>    If pEL.CurrentLayer.FeatureClass.ShapeType <> esriGeometryPolygon Then<BR>        Debug.Print "not a polygon layer"<BR>        Exit Sub<BR>    End If<BR>    <BR>    Dim pFSel As IFeatureSelection<BR>    Set pFSel = pEL.CurrentLayer<BR>    If pFSel.SelectionSet.Count = 0 Then<BR>        Debug.Print "nothing selected"<BR>        Exit Sub<BR>    End If<BR>    Dim pFCur As IFeatureCursor<BR>    pFSel.SelectionSet.Search Nothing, False, pFCur<BR>    <BR>    Dim pMxDoc As IMxDocument<BR>    Set pMxDoc = ThisDocument<BR>    Dim pAV As IActiveView<BR>    Set pAV = pMxDoc.FocusMap<BR>    Dim dMaxOffset  As Double<BR>    dMaxOffset = GetMaxOffset(pAV)<BR>    <BR>    pEditor.StartOperation<BR>    Dim pFeat As IFeature<BR>    Set pFeat = pFCur.NextFeature<BR>    Do While Not pFeat Is Nothing<BR>        SmoothPolygon pFeat, dMaxOffset<BR>        Set pFeat = pFCur.NextFeature<BR>    Loop<BR>    pEditor.StopOperation "SmoothPolygon"<BR>    <BR>    Dim lCacheID As Long<BR>    lCacheID = pAV.ScreenCacheID(esriViewGeoSelection, Nothing)<BR>    pAV.ScreenDisplay.Invalidate Nothing, True, lCacheID<BR>End Sub<BR><BR>Function GetMaxOffset(pAV As IActiveView) As Double<BR>    Dim pNDlg As INumberDialog<BR>    Set pNDlg = New NumberDialog<BR>    Dim dDefault As Double<BR>    dDefault = pAV.ScreenDisplay.DisplayTransformation.FittedBounds.Width / 100#<BR>    If pNDlg.DoModal("Smooth", dDefault, 2, 0) Then<BR>        GetMaxOffset = Abs(pNDlg.Value)<BR>    Else<BR>        GetMaxOffset = dDefault<BR>    End If<BR>End Function<BR><BR>Sub SmoothPolygon(pFeat As IFeature, dMaxOffset As Double)<BR>    Dim pInGeomColl As IGeometryCollection<BR>    Set pInGeomColl = pFeat.ShapeCopy<BR>    <BR>    Dim pOutGeomColl As IGeometryCollection<BR>    Set pOutGeomColl = New Polygon<BR>    <BR>    ' for each exterior ring (ring implements IPath)<BR>    Dim l As Long<BR>    For l = 0 To pInGeomColl.GeometryCount - 1<BR>        Dim pClone As IClone<BR>        Set pClone = pInGeomColl.Geometry(l)<BR>        Dim pPath As IPath<BR>        Set pPath = pClone.Clone<BR>        On Error Resume Next<BR>        pPath.Smooth 0 ' dMaxOffset<BR>        If Err = 0 Then<BR>            Dim pTopoOp As ITopologicalOperator<BR>            Set pTopoOp = pPath<BR>            pTopoOp.Simplify<BR>            pOutGeomColl.AddGeometry pPath<BR>        Else<BR>            ' I guess the maxoffset is too large for the size of the ring?<BR>            pOutGeomColl.AddGeometry pInGeomColl.Geometry(l)<BR>            Err.Clear<BR>        End If<BR>    Next l<BR>    Set pFeat.Shape = pOutGeomColl<BR>    pFeat.Store<BR><BR>End Sub<BR></P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
happydust
路人甲
路人甲
  • 注册日期2004-12-31
  • 发帖数25
  • QQ
  • 铜币122枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2005-08-06 00:28
<P>Thanks a lot!!!</P>
<P>不过,这个Smooth的平滑就是相邻的边界就是会出错 ,我找了好久都没合适的办法…………不知道有没有更合理方法可以实现的???</P>
<P><IMG src="http://www.mingxu.com/02gis/test1.bmp.jpg" border=0></P>

[此贴子已经被作者于2005-8-6 0:50:32编辑过]
举报 回复(0) 喜欢(0)     评分
游客

返回顶部