dear sir,
if i have route (r) between p1 and p2, and i have another point p3 outside the route and i want to know how far is this point form nearset point of route. how can i do this ?
thanks,
dear sir,
if i have route (r) between p1 and p2, and i have another point p3 outside the route and i want to know how far is this point form nearset point of route. how can i do this ?
thanks,
Ahmed,
MapSuite Routing is based on MapSuite Core, so you can use the code blow to calculate the shortest distance:
MultilineShape router = routingEngine.GetRoute(point1, point2).Route;
PointShape point3 = new PointShape(-97.739599613769542, 30.277963047607429);
MultilineShape shortestLine = point3.GetShortestLineTo(router, GeographyUnit.DecimalDegree);
double shortestDistance = shortestLine.GetLength(GeographyUnit.DecimalDegree,DistanceUnit.Kilometer);
Another way is that you can generate the nearest point of route from p3, and then calculate the distance between them:
PointShape closestPoint = router.GetClosestPointTo(point3, GeographyUnit.DecimalDegree);
double shortestDistance = closestPoint.GetDistanceTo(point3, GeographyUnit.DecimalDegree,DistanceUnit.Kilometer);
Any questions or comments please let us know!
Thanks!
Johnny
it is working now, thanks.
You are so welcome!
Thanks!
Johnny