How to use the RouteOptions.Tolerance in the C# BingMapsRestToolkit property? RRS feed

  • Question

  • I'm using the Bing Maps REST service with the intent of getting a linestring for a route. I chose the REST service only because the documentation states that I can some control over the number of coordinates using the Tolerance parameter of RouteOptions.

    I want to maximize, not reduce, the number of Points in a route.

    Using a route that is 94 miles long, I get 212 Points in the linestring using a tolerance of 0.00000344978. I get the same amount of Points when using a looser (.11) or tighter tolerance. I always get 212 Points in the linestring. 

    What am I doing wrong?

            public async Task BlahMethod(string origin, string dest, string sessionId) {
                var startWp     = new SimpleWaypoint() { Address = origin };
                var endWp       = new SimpleWaypoint() { Address = dest };
                var rtAttribs   = new List<RouteAttributeType>();
                var options             = new RouteOptions() { 
                    DistanceUnits       = DistanceUnitType.Kilometers,  
                    RouteAttributes     = rtAttribs,  
                    Tolerances          = new List<double>(new double[]{ 0.00000344978})
                var req = new RouteRequest() {
                    BingMapsKey     = sessionId,
                    Waypoints       = new List<SimpleWaypoint>(new SimpleWaypoint[] { startWp, endWp }),
                    RouteOptions    = options,
                var resp = await req.Execute();

    • Edited by Joel_Z Tuesday, November 5, 2019 12:15 AM
    Tuesday, November 5, 2019 12:15 AM

All replies

  • Hi Joel_Z,

    My assumption would be that the 212 points are actually required within both tolerances given for the 94mile route.  Tolerance will only remove points that are not required as shown in the document you reference.  The points that are redundant on the route are removed but not those that are required to represent a dramatic curve or turn etc.

    The sample at might help as well.



    Friday, December 6, 2019 3:20 PM
  • The tolerance value returns another property in the response that indicates which coordinates to use from the original set to get a reduced set of approximate coordinates. The maximum set of points is always returned. If that's what you want, don't bother using the tolerance property.
    Friday, December 6, 2019 4:13 PM
  • Thanks for the clarification Ricky!
    Friday, December 6, 2019 7:20 PM