阅读:2473回复:6
[求助]请教大家:如何查询共享边界的面?
<STRONG><BR></STRONG>VB+AO开发中用属性查询在一个Poylgon图层中找到属性相同的几个面,再用空间查询找到其中相触(SpatialRel = esriSpatialRelTouches)的面。可只有一个共同点的面也是相触,而我只想找到那些有共同边界的面,我该怎么办呢?请知道的朋友点拨下,谢谢了
|
|
1楼#
发布于:2006-09-25 11:32
高难度啊,支持一下
|
|
|
2楼#
发布于:2006-09-25 15:32
<P>可以看看这个例子,</P>
<P>http://edndoc.esri.com/arcobjects/8.3/Samples/Editing/Edit%20Tasks/Zipper%20Task/ZipperTask.zip</P> <P>使用方法如下:</P> <P>How to use: </P>Register the dll on your machine. <br>Use Categories to add the dll to the 'ESRI Edit Tasks' component category. <br>Start an edit session and select the Zipper Task as the current task. <br>Create a sketch and finish it. <br>Select the layers whose features you want to adjust, specify a search tolerance, then click on the OK button <P>Description:<br><br>This sample allows features within a user specified tolerance to be snapped to the edit sketch. Using the sketch tool a polyline sketch is created. When the sketch is finished, a dialog appears asking for a tolerance and the layers to be adjusted. Features from the specified layers that fall within the tolerance are then aligned to the geometry of the sketch. </P><br> <P>A common scenario for using this tool is when you have one feature that you want to align the features from other feature classes to. The Trace tool (or the Replace Sketch context menu choice) is used to create a sketch of the geometry in the feature, and the Zipper Task will then use this geometry to align the other features. </P> <P> <P>When you have a sketch that loops back on itself, the task may not work as you expect. In these cases, it is best to run the task twice. The first time for the first half of the loop, and the second time for the rest. <br></P> [此贴子已经被作者于2006-9-25 15:32:51编辑过]
|
|
|
3楼#
发布于:2006-09-25 15:36
<P>Private Sub SnapFeatures() <BR>Dim pMx As IMxDocument <BR>Dim pEnum As IEnumFeature <BR>Dim pFeat As IFeature <BR>Dim pPointColl As IPointCollection <BR>Dim pPoint As IPoint <BR>Dim pTPoint As IPoint <BR>Dim pGeom As IGeometry <BR>Dim pSr As Double, pDist As Double, pInx As Long, pSeg As Long <BR>Dim pHit As IHitTest <BR>pSr = 1 <BR><BR>Set pMx = ThisDocument <BR>Set pEnum = pMx.FocusMap.FeatureSelection <BR>Set pFeat = pEnum.Next <BR>Set pPoint = New point <BR>If Not pFeat Is Nothing Then <BR>Set pPointColl = pFeat.Shape <BR>Dim pTopo As ITopologicalOperator <BR>Dim pSF As ISpatialFilter <BR>Dim pFeatCls As IFeatureClass <BR>Dim pFeatcur As IFeatureCursor <BR>Dim pEnv As IEnvelope <BR>Dim pFeature As IFeature <BR><BR>Set pFeatCls = pFeat.Class <BR>Set pSF = New SpatialFilter <BR>Set pEnv = pFeat.Shape.Envelope <BR>pEnv.Expand 3, 3, False <BR>Set pSF.Geometry = pEnv <BR>pSF.GeometryField = "Shape" <BR>pSF.SpatialRel = esriSpatialRelEnvelopeIntersects <BR><BR>Set pFeatcur = pFeatCls.Search(pSF, False) <BR>Set pFeature = pFeatcur.NextFeature <BR>Do While Not pFeature Is Nothing <BR>Set pHit = pFeature.Shape <BR>If pFeature.oid <> pFeat.oid Then <BR>For i = 0 To pPointColl.PointCount - 1 <BR>Set pTPoint = pPointColl.point(i) <BR>bFlag = pHit.HitTest(pPointColl.point(i), pSr, esriGeometryPartVertex, pPoint, pDist, pInx, pSeg, False) <BR>If bFlag = True Then <BR>pPointColl.UpdatePoint i, pPoint <BR>Debug.Print "Vertex Moved to Vertex" <BR>Else <BR>bFlag = pHit.HitTest(pPointColl.point(i), pSr, esriGeometryPartBoundary, pPoint, pDist, pInx, pSeg, False) <BR>If bFlag = True Then <BR>pPointColl.UpdatePoint i, pPoint <BR>Debug.Print "Vertex moved to Edge" <BR>End If <BR>End If <BR>Next i <BR>End If <BR>Set pFeature = pFeatcur.NextFeature <BR>Loop <BR>End If <BR><BR>Dim ppoly As IPolygon <BR>Set ppoly = New Polygon <BR>Set ppoly = pPointColl <BR>Set pFeat.Shape = ppoly <BR>pFeat.Store <BR><BR>End Sub </P>
<P>图如下,扑捉到附近的边界,然后自动完成"边界匹配"</P> <P><BR> </P> |
|
|
4楼#
发布于:2006-09-25 21:30
<P>刚刚看到GIS的解答,先谢谢你,再慢慢学习中......</P>
|
|
5楼#
发布于:2006-09-26 09:30
<P>学习!</P>
|
|
|
6楼#
发布于:2006-10-04 22:11
学习。
|
|