FromPoint does not intersect it's own IPolyline5
-
27-04-2021 - |
Question
I have a Polyline and a Point FeatureClass. I create a point feature on the Point layer for both the FromPoint and the ToPoint of the IPolyline5 similar to below:
IFeature pointFeature1 = pointFeatureClass.CreateFeature ();
pointFeature1.Shape = polyline.FromPoint;
IFeature pointFeature2 = pointFeatureClass.CreateFeature ();
pointFeature2.Shape = polyline.ToPoint;
Later, I then run both the from point and to point geometries through a method like the below to find all the intersecting polyline features from the polyline feature class.
ISpatialFilter filter = new SpatialFilter ();
filter.Geometry = pointGeometry;
filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
IFeatureCursor cursor = lineFeatureClass.FeatureClass.Search (filter, false);
At the very least, the intersect filter should find the polyline off which I got the 2 points. The strange thing is, it works for the FromPoint, but not with the ToPoint.
Both feature classes are using the same Geographic Coordinate System and Projected Coordinate System.
I hope I am doing something stupid, but just can't figure out what.
Solution
I got it to work consistently with esriSpatialRelIntersects by just buffering the point by 0.001.
OTHER TIPS
When creating new features from existing features, you should not use the direct reference, but the ShapeCopy. Try to change yout first block to:
pointFeature1.Shape = polyline.FromPoint.ShapeCopy;
pointFeature2.Shape = polyline.ToPoint.ShapeCopy;
instead of
pointFeature1.Shape = polyline.FromPoint;
use
PointFeature1.Shape = ((polyline.FromPoint as IPoint) as IFeature).ShapeCopy;
and for
pointFeature2.Shape = polyline.ToPoint;
use
PointFeature1.Shape = ((polyline.ToPoint as IPoint) as IFeature).ShapeCopy;