阅读:2088回复:4
[求助]如何判断多边形是自相交多边形?<P>我用issimple的方法判断不出自相交。用下面这个方法又把多块多边形也查出来了,我只想查自相交的多边形,不知道改怎么弄?</P> <P> IGeometry pGeometry = pFeature.Shape;</P> <P>IPolygon pPolygon = pGeometry as IPolygon;<BR> if (pPolygon.ExteriorRingCount != 1)</P> |
|
1楼#
发布于:2007-03-06 15:45
<PRE> </PRE><PRE>下面的代码应该比较容易看出</PRE><PRE>Dim pPoly As IPointCollection
Dim p As IPoint Set pPoly = New Polygon Set p = New Point p.PutCoords 0, 0 pPoly.AddPoint p p.PutCoords 0, 1 pPoly.AddPoint p ' Point 3 p.PutCoords 1, 0 pPoly.AddPoint p ' point 4 p.PutCoords 1, 1 pPoly.AddPoint p p.PutCoords 0, 0 pPoly.AddPoint p Dim pTopo As ITopologicalOperator Dim pGeoCol As IGeometryCollection Dim intBefore As Integer Set pGeoCol = pPoly intBefore = pGeoCol.GeometryCount Set pTopo = pPoly pTopo.Simplify Set pGeoCol = pPoly If intBefore <> pGeoCol.GeometryCount Then MsgBox "self intersect" End If </PRE> |
|
|
2楼#
发布于:2007-03-07 13:09
<P>谢谢楼上的!不过这个方法还是不行,有没有别的办法?</P>
|
|
3楼#
发布于:2007-03-07 13:30
你测试过吗?为什么不行?
|
|
|
4楼#
发布于:2007-03-10 15:30
回复
回楼上的。我测试过的,我也不知道什么原因,但是我得到的前面的count和后面的count总是相等的。 |
|