locked
Truck route through the city (Why?) RRS feed

  • Question

  • Greetings!

    I have an issue. Truck route API gives me the route through the city.

    Please have a look at this test route and parameters…

    URL:

    https://dev.virtualearth.net/REST/v1/Routes/Truck?key=my_key

    POST data:

    {"avoid":"0","distanceUnit":"miles","vehicleSpec":{"dimensionUnit":"foot","weightUnit":"pound","vehicleHeight":14.5,"vehicleWidth":12,"vehicleLength":100,"vehicleWeight":100000,"vehicleAxles":6,"vehicleTrailers":1,"vehicleSemi":false,"vehicleMaxGradient":45,"vehicleMinTurnRadius":1,"vehicleAvoidCrossWind":false,"vehicleAvoidGroundingRisk":false},"waypoints":[{"latitude":33.46133328876707,"longitude":-84.33079857969057},{"latitude":34.232,"longitude":-84.49964}],"routeAttributes":"routePath","optimize":"time"}

    Why is the route laid through Atlanta? Trucks can’t go through the city. I was expecting a route to bypass Atlanta on I285

    Thanks.

    Thursday, July 9, 2020 2:05 PM

Answers

  • Hi Kamorin_ilya, The truck routing API requires you to include weight and axles in the request to avoid the city roads. Setting those values will get you the correct route around the city, rather than through it.

    Tuesday, March 16, 2021 11:24 PM
    Administrator

All replies

  • Hi Kamorin_ilya,

    I have tried your points and the route does seem to go around downtown ... although I have never been to Atlanta. Please try the following code in our iSDK https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/directionscreatetruckroute then press the green arrow to run

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        /* No need to set credentials if already passed in URL */
        center: new Microsoft.Maps.Location(33.800481, -84.459324),
        zoom: 16
    });
    Microsoft.Maps.loadModule('Microsoft.Maps.Directions', function () {
        var directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);
        directionsManager.setRenderOptions({ itineraryContainer: document.getElementById('printoutPanel') });
        directionsManager.setRequestOptions({
            routeMode: Microsoft.Maps.Directions.RouteMode.truck,
            vehicleSpec: {
                dimensionUnit: 'ft',
                weightUnit: 'lb',
                vehicleHeight: 5,
                vehicleWidth: 3.5,
                vehicleLength: 30,
                vehicleWeight: 30000,
                vehicleAxles: 3,
                vehicleTrailers: 2,
                vehicleSemi: true,
                vehicleMaxGradient: 10,
                vehicleMinTurnRadius: 15,
                vehicleAvoidCrossWind: true,
                vehicleAvoidGroundingRisk: true,
                vehicleHazardousMaterials: 'F',
                vehicleHazardousPermits: 'F'
            }
        });
        var wp1 = new Microsoft.Maps.Directions.Waypoint({
            address: 'North Atlanta',
            location: new Microsoft.Maps.Location(33.4613, -84.3308)
        });
        var wp2 = new Microsoft.Maps.Directions.Waypoint({
            address: 'South Atlanta',
            location: new Microsoft.Maps.Location(34.232, -84.49964)
        });
        directionsManager.addWaypoint(wp1);
        directionsManager.addWaypoint(wp2);
        directionsManager.calculateDirections();
    });

    Sincerely,

    IoTGirl

    Friday, July 10, 2020 2:05 AM
  • Here are shots of the route for Truck from the iSDK code above(Good for visualizing)

    Truck Route


    Friday, July 10, 2020 2:15 AM
  • Thanks for help! 
    I see it works with directionsManager. But I can’t get the route from it (big array of route points to draw them on the map). That’s why I started to use the direct API. I can save its result and reuse it later.
    Why is Truck API working differently than directionsManager?
    Friday, July 10, 2020 4:15 AM
  • Hi Kamorin,

    It is the same call behind the scene.  My suspicion is that you have not set a value that blocks access through the city. Note that my call has Vehicle Semi set to true, for example while yours says false.  A number of other values such as hazardous materials can also factor into the routing.  So I would ask about your values. You have a 100ft vehicle that is not a semi so likely this is being interpreted as something like an articulated bus without dangerous cargo which is likely allowed within the city.

    Sincerely,

    IoTGirl

    Friday, July 10, 2020 4:38 PM
  • Good day!
    I’ve set the route parameters like yours. And it doesn’t work. The route is made through the city. I can do nothing with this.

    I can send you simple project to demonstrate this issue.

    Details: 

    Project type: Net Core 3.1 (backend) + Angular 8.2.14 (frontend with map)

    My code example:

    JSON:

    {

      "waypoints": [

        {

          "latitude": 33.4613,

          "longitude": -84.3308

        },

        {

          "latitude": 34.232,

          "longitude": -84.49964

        }

      ],

      "avoid": "0",

      "distanceUnit": "mi",

      "optimize": "time",

      "routeAttributes": "routePath",

      "vehicleSpec": {

        "dimensionUnit": "ft",

        "weightUnit": "lb",

        "vehicleHeight": 5,

        "vehicleWidth": 3.5,

        "vehicleLength": 30,

        "vehicleWeight": 30000,

        "vehicleAxles": 3,

        "vehicleTrailers": 2,

        "vehicleSemi": true,

        "vehicleMaxGradient": 10,

        "vehicleMinTurnRadius": 15,

        "vehicleAvoidCrossWind": true,

        "vehicleAvoidGroundingRisk": true,

        "vehicleHazardousMaterials": "F",

        "vehicleHazardousPermits": "F"

      }

    }

    Request Method:

    [HttpGet(“bingMapsRouteRequest")]

    public async Task<ActionResult<string>> BingMapsRouteRequest()

    {

        try

        {

            using (var httpClient = new HttpClient())

            {

                var url = "https://dev.virtualearth.net/REST/v1/Routes/Truck?key=MyKey”;

                var data = GetHardcodedRequest();// here I create a model to get the json you can see above

                //var json = Newtonsoft.Json.JsonConvert.SerializeObject(data); // it doesn't work!!! Truck API returns error 400 (Json input could not be parsed)

                var json = System.Text.Json.JsonSerializer.Serialize(data); // it works. Magic!

                var httpContent = new StringContent(json, Encoding.UTF8, "application/json");

                var response = await httpClient.PostAsync(url, httpContent);

                var content = await response.Content.ReadAsStringAsync();

                return Ok(content);

            }

        }

        catch (Exception ex)

        {

            return Ok($"Request Exception: {ex.Message}");

        }

    }

    Monday, July 13, 2020 9:06 AM
  • Hi Kamorin,

    Can you explain your settings?  I see the following: avoid=0 but I don't see that as a valid option.

    Examples:
    avoid=highways
    avoid=highways,tolls
    avoid=borderCrossing

    Sincerely,

    IoTGirl

    Monday, July 13, 2020 4:53 PM
  • Hi, IoTGirl

    1) Avoid it's flag enum. From Microsoft code:

    /** Defines features to avoid when calculating the route. */

        export enum RouteAvoidance {

            /** Calculate the best route using any travel option available. */

            none = 0,

            /** Reduce the use of limited access highways when calculating the route. */

            minimizeHighways = 1,

            /** Reduce the use of roads with tolls when calculating the route. */

            minimizeToll = 2,

            /** Avoid using limited access highways when calculating the route. */

            avoidHighways = 4,

            /** Avoid using roads with tolls when calculating the route. */

            avoidToll = 8,

            /** Avoid using express trains when calculating the route. This option only affects routes with a transitRouteMode that have the culture set to ja-jp. */

            avoidExpressTrain = 16,

            /** Avoid using airlines when calculating the route. This option only affects routes with a transitRouteMode that have the culture set to ja-jp. */

            avoidAirline = 32,

            /** Avoid using bullet trains when calculating the route. This option only affects routes with a transitRouteMode that have the culture set to ja-jp. */

            avoidBulletTrain = 64

        }

    2) It doesn't matter. Nothing changes when I remove “avoid” from my JSON

    Tuesday, July 14, 2020 3:59 AM
  • Hi, IoTGirl.

    What does MS support say about this? Can I write to a support specialist? I need a contact...

    Tuesday, July 21, 2020 4:29 AM
  • Hi Kamorin,

    I have escalated this MSDN thread to the routing team and they are reviewing it. I will let you know when they get back to me. (Issue Tracking #2907762)

    Sincerely,

    IoTGirl



    Tuesday, July 21, 2020 5:25 AM
  • I have same problem. Try to use Basic key and it show wrong direction for trucks with Flammable Hazardous materials. Looks like service return only directions for cars, not for trucks. Azure bing map return correct direction but it only good for server to server scenario because access key security.

    T-6000 BIO

    Tuesday, July 21, 2020 7:05 PM
  • Hello,

    My apology for the long turn around time here. The team has reviewed this issue and reported this issue to our data provider Tomtom. We received a fixed notification from them as of September 25th. Andriyko1, are you looking at the same city or a different one?

    NOTE: The issue seems to be that I-75 should not be a Truck route through Atlanta, as trucks are not permitted to go through the city. We have have reported the concern to our data provider to correct.

    Sincerely,

    IoTGirl



    Thursday, October 8, 2020 8:43 PM
  • Hi Kamorin_ilya, The truck routing API requires you to include weight and axles in the request to avoid the city roads. Setting those values will get you the correct route around the city, rather than through it.

    Tuesday, March 16, 2021 11:24 PM
    Administrator