Thomas:
I did a similar process. I have a road network in UTM (MultilineShape). The user clicks a point on the map. I needed to locate the line "clicked" on, and reposition the point exactly along the line.
I used the winformsMap1_MouseDown(object sender, MouseEventArgs e) method to get the click point from the user, and convert to PointShape worldPoint. I used a tolerance of 15 meters and did the following, with worldPoint being the road network file:
Collection<Feature> selectedFeaturesR = roads.QueryTools.GetFeaturesWithinDistanceOf(
(BaseShape)worldPoint, GeographyUnit.Meter, DistanceUnit.Meter,
15, ReturningColumnsType.AllColumns);
I then moved through each of the returned features to find the closest line.
distance = 999999999.99999F;
tmppos = -1;
for (d = 0; d < selectedFeaturesR.Count; d++)
{
MultilineShape lineshape2 = (MultilineShape)(selectedFeaturesR[d].GetShape());
tmpdistance = lineshape2.GetDistanceTo(worldPoint, GeographyUnit.Meter, DistanceUnit.Meter);
if (tmpdistance < distance) { distance = tmpdistance; tmppos = d; }
}
}
d = tmppos;
Using the located closest feature, I then used the code from the snapping examples (Dragged Point Style, Snap To Layer, Snap To Vertex)to reposition the point exactly along the line.
Hopefully this helps.
Elisa