I am trying to implement a search of nearest features in ArcObjects.NET
(don't suggest existing tools like Near) and I use IProximityOperator.ReturnDistance
to get distances between features and to select the nearest one.
However, I've found that sometimes this method returns incorrect results.
Here is test map with one point layer (in general type of geometry is arbitrary):
Look at the feature with OID = 18. You can see that the nearest point is a feature with OID = 40 but the result of IProximityOperator.ReturnDistance
for this feature is greater than for feature with OID = 22.
What am I doing wrong?
Test code:
var f18 = featureClass.GetFeature(18);
var f22 = featureClass.GetFeature(22);
var f40 = featureClass.GetFeature(40);
var f18AsProximityOp = (IProximityOperator)f18.Shape;
var d18_22 = f18AsProximityOp.ReturnDistance(f22.Shape);
var d18_40 = f18AsProximityOp.ReturnDistance(f40.Shape);
But d18_22 < d18_40. I use ArcGIS 10.2, .NET 3.5, Windows 7.