arcengine 中怎么把IFeatureLayer或者IFeatureClass转成IGeometry类型
arcengine中怎么把IFeatureLayer或者IFeatureClass转成IGeometry类型,我的目的是用一个polyline叠置查询一个线图层里面的线。...
arcengine 中怎么把IFeatureLayer或者IFeatureClass转成IGeometry类型,我的目的是用一个polyline叠置查询一个线图层里面的线。用到ITopologicalOperator的Intersect方法。有朋友知道怎么实现吗?谢谢了~(最好用C#语言)
展开
1个回答
展开全部
可以不用ITopologicalOperator,直接用空间查询就可以实现
//spatial query
ISpatialFilter pSpatialFilter = new SpatialFilterClass();
pSpatialFilter.Geometry = (IGeometry)pPolyline;//用于查询的polyline
SpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;//Intersect
IFeatureCursor pFeatureCursor = pFeatureClass.Search(pSpatialFilter, false);//query
IFeature pFeature = pFeatureCursor.NextFeature();
while (pFeature != null)
{
IPolyline pQueryPolyline = (IPolyline)pFeature.Shape ; //查询出来的polyline
pFeature = pFeatureCursor.NextFeature();
}
//release com resource
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
//spatial query
ISpatialFilter pSpatialFilter = new SpatialFilterClass();
pSpatialFilter.Geometry = (IGeometry)pPolyline;//用于查询的polyline
SpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;//Intersect
IFeatureCursor pFeatureCursor = pFeatureClass.Search(pSpatialFilter, false);//query
IFeature pFeature = pFeatureCursor.NextFeature();
while (pFeature != null)
{
IPolyline pQueryPolyline = (IPolyline)pFeature.Shape ; //查询出来的polyline
pFeature = pFeatureCursor.NextFeature();
}
//release com resource
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
追问
这个可以用,但可能会找出交叉但不重合的线,我在循环里加了叠置分析,再用线长判断就可以找出了,可能方法有点笨拙,不知道有没有好方法~(*^__^*) 嘻嘻……~
pTopo = pPolyline as ITopologicalOperator;
pBuffer = pTopo.Intersect(pQueryPolyline, esriGeometryDimension.esriGeometry1Dimension);pPolylineResult = pBuffer as IPolyline;if (pPolylineResult.Length != 0.0){i++;}
追答
那你可以试试IRelationalOperator里面的Overlaps 方法,可能有用
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询