我有一条折线和一个Point FeatureClass。 我在Point层上为IPolyline5的FromPoint和ToPoint创建了一个点特征,类似于下面的内容:
IFeature pointFeature1 = pointFeatureClass.CreateFeature ();
pointFeature1.Shape = polyline.FromPoint;
IFeature pointFeature2 = pointFeatureClass.CreateFeature ();
pointFeature2.Shape = polyline.ToPoint;
稍后,我通过下面的方法运行从点和点几何,以找到折线要素类中的所有相交折线要素。
ISpatialFilter filter = new SpatialFilter ();
filter.Geometry = pointGeometry;
filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
IFeatureCursor cursor = lineFeatureClass.FeatureClass.Search (filter, false);
至少,相交滤波器应该找到我得到2点的折线。奇怪的是,它适用于FromPoint,但不适用于ToPoint。
两个要素类都使用相同的地理坐标系和投影坐标系。
我希望我做的事情很愚蠢,但却无法弄清楚是什么。
答案 0 :(得分:0)
我通过将点数缓冲0.001来使其与esriSpatialRelIntersects保持一致。
答案 1 :(得分:0)
从现有功能创建新功能时,不应使用直接引用,而应使用ShapeCopy。尝试将第一个块更改为:
pointFeature1.Shape = polyline.FromPoint.ShapeCopy;
pointFeature2.Shape = polyline.ToPoint.ShapeCopy;
答案 2 :(得分:0)
而不是
pointFeature1.Shape = polyline.FromPoint;
使用
PointFeature1.Shape = ((polyline.FromPoint as IPoint) as IFeature).ShapeCopy;
和
pointFeature2.Shape = polyline.ToPoint;
使用
PointFeature1.Shape = ((polyline.ToPoint as IPoint) as IFeature).ShapeCopy;