我是CAD初学者,开发一个有关四至的CAD插件还是有一定困难,前些天我刚写了一个求四至的插件,用C#写的,操作的是SHP数据,我觉得很多数据都可以通过FME转过去处理,在GIS中处理四至非常方便。关键是求几何关系,其核心函数是:
- /// <summary>
- /// 检查几何关系
- /// </summary>
- /// <param name="pPolyline"></param>
- /// <param name="pFeatureClass"></param>
- /// <returns></returns>
- private string CheckTouches(IPolyline pPolyline, IFeatureClass pFeatureClass)
- {
- string strFID = "";
- ISpatialFilter pSpatialFilter = new SpatialFilterClass();
- pSpatialFilter.Geometry = pPolyline;
- pSpatialFilter.GeometryField = "shape";
- pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelTouches;
- IFeatureCursor pFeatureCursor = pFeatureClass.Search(pSpatialFilter, false);
- IFeature pFeature = pFeatureCursor.NextFeature();
- while (pFeature != null)
- {
- strFID=pFeature.get_Value(0).ToString();
- pFeature = pFeatureCursor.NextFeature();
- Application.DoEvents();
- }
- return strFID;
- }
|