Here’s my scenario:
- The user loads some layers containing line features on the map.
- The user clicks near a line and I want to get the closest vertex contained withing that lineshape feature from where the user clicked.
Here’s the main line of code I’m doing this in:
PointShape vertex = (testLineShape.GetShape() as LineShape).GetClosestPointTo(new PointShape(e.WorldX, e.WorldY), GeographyUnit.DecimalDegree);
testLineShape is a line feature. First I get it’s LineShape and then do the .GetClosestPointTo method passing in the user’s click (e.WorldX and e.WorldY).
The problem is it’s not returning the exact vertex. The values for it just don’t match up and I really need them to.
Example:
Here’s the vertex given back to me from the .GetClosestPointTo method:
And here’s the actual vertex apart of the line:
They are the same up to 4 decimal places, but I need the exact value to match.