none
Bing Maps Waypoints function

    Question

  • Hi,

    I am using Bing maps Waypoints class to calculate the time as well as distance between waypoints. It is working good on my development PC. 

    When i deploy the application on a test server, it does not calculate the distances and time. The max number of Waypoints never exceeded 10.

    My code looks like this:

    waypoints function is called in the inner loop. If the outer loop runs 5 times, i am getting ETA, and miles only for one iteration. This happens only on the test SERVER after deployment.

    On my development PC, it is working good. I do not have any issues on development PC.

    Why am i having problems on  Server?

    for loop
    
    
    for i=0 to dt.row.count -1
    
    processing data
    
    
    mydt = bingmaps.waypoints(dt)
    
    next 
    
    
    next

    Thanks


    Monday, September 16, 2013 7:35 PM

Answers

  • Can you provide a bit more information about what is going on in the "processing data" section? Are you making a call to a server? If so it's possible the call is being made asynchronously which would result in the function continuing on to the next way point if the call has responded or not.

    http://rbrundritt.wordpress.com

    Tuesday, September 17, 2013 8:13 AM
    Owner
  • Yes, it looks like you are using the old legacy Bing Maps SOAP services to do your routing. The two sizes you mentioned are common things that have to be changed when using the routing service as it returns a large amount of data.

    The Bing Maps REST services are the recommended over the SOAP services. The REST services are faster, work on more platforms, and have more features. They also receive new features regularly where as the SOAP service has been updated in 4 years. You can find documentation on how to use the REST services in .NET here: http://msdn.microsoft.com/en-us/library/jj819168.aspx


    http://rbrundritt.wordpress.com

    Wednesday, September 18, 2013 6:28 PM
    Owner

All replies

  • After deploying on server, i am getting time and travel distance when i pass 2-4 waypoints to the function.

    If i have more than 4 waypoints passing to the function, i am not getting the results. 

    It appears as if the function does not wait till it gets the return values from the waypoints function.


    Tuesday, September 17, 2013 4:35 AM
  • Can you provide a bit more information about what is going on in the "processing data" section? Are you making a call to a server? If so it's possible the call is being made asynchronously which would result in the function continuing on to the next way point if the call has responded or not.

    http://rbrundritt.wordpress.com

    Tuesday, September 17, 2013 8:13 AM
    Owner
  • Hi Richard,

    My code for WaypointsBing and my calling method is as follows:

    Public Shared Function WaypointsBing(ByVal tripgeocodes As DataTable) As DataTable
    
            Dim legd As New Transp_Mngr.RouteService.RouteRequest
            Dim key As String = "mykey"
            Dim dist As Double = 0
    
            Try
                legd.Credentials = New Transp_Mngr.RouteService.Credentials
                legd.Credentials.ApplicationId = key
                Dim myrouteoptions As New RouteOptions
                myrouteoptions.Mode = TravelMode.Driving
                legd.Options = myrouteoptions
    
                Dim Routeuser As New Transp_Mngr.RouteService.UserProfile
                Routeuser.DistanceUnit = Transp_Mngr.RouteService.DistanceUnit.Mile
                legd.UserProfile = Routeuser
    
                Dim routeService As New Transp_Mngr.RouteService.RouteServiceClient()
                Dim startloc(1) As RouteService.Location
                Dim waypoints As RouteService.Waypoint() = New RouteService.Waypoint(tripgeocodes.Rows.Count - 1) {}
    
                Dim j As Integer = 0
                Dim n As Integer = 0
                For i = 0 To tripgeocodes.Rows.Count - 1
    
                    waypoints(n) = New RouteService.Waypoint()
                    waypoints(n).Description = "Waypoint" & j
                    waypoints(n).Location = New RouteService.Location()
                    waypoints(n).Location.Latitude = tripgeocodes.Rows(i).Item(1)
                    waypoints(n).Location.Longitude = tripgeocodes.Rows(i).Item(2)
                    j = j + 1
                    n = n + 1
    
                Next
    
                legd.Waypoints = waypoints
    
                Dim RouteServiceInstance As New RouteService.RouteServiceClient("BasicHttpBinding_IRouteService")
                Dim routeResponse = RouteServiceInstance.CalculateRoute(legd)
                Dim legcount As Integer = routeResponse.Result.Legs.Length
                Dim myleg As RouteService.RouteLeg
                Dim legdist As Double
                Dim legtime As Long
    
                Dim k As Integer = 0
                For i = 0 To legcount - 1
                    k = i + 1
                    myleg = routeResponse.Result.Legs(i)
                    legdist = myleg.Summary.Distance
                    legtime = myleg.Summary.TimeInSeconds
                    tripgeocodes.Rows(k).Item("TravelTime") = legtime
                    tripgeocodes.Rows(k).Item("TravelMiles") = legdist
                Next
                
    
            Catch ex As Exception
    
                SendEmail("Error in Web Application", ex.ToString, "me@mymail.com", "Bing Web Developers")
    
            End Try
    
    
            Return tripgeocodes
    
    
        End Function

            public sub mymethod()
            
    	'process data in tripseqdt datatable. then call    'Bing maps waypoints and pass the table
    
    	tripseqdt = BingMaps.WaypointsBing(tripseqdt)
            tripseqdt = UpdateETA(tripseqdt)
    
    	end sub


    • Edited by rowter Tuesday, September 17, 2013 2:27 PM
    Tuesday, September 17, 2013 2:10 PM
  • Richard,

    There are properties called MaxReceivedMessageSize and MaxBufferSize in service binding section of web.config.
    I changed them to MAX values. I am not seeing this issues mentioned above.
          <binding name="BasicHttpBinding_IRouteService"  maxBufferSize="2147483647"maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" >

    Now, i am getting a
    Error: HttpException (0x80004005): Request timed out

    Thanks

    Wednesday, September 18, 2013 3:51 PM
  • Yes, it looks like you are using the old legacy Bing Maps SOAP services to do your routing. The two sizes you mentioned are common things that have to be changed when using the routing service as it returns a large amount of data.

    The Bing Maps REST services are the recommended over the SOAP services. The REST services are faster, work on more platforms, and have more features. They also receive new features regularly where as the SOAP service has been updated in 4 years. You can find documentation on how to use the REST services in .NET here: http://msdn.microsoft.com/en-us/library/jj819168.aspx


    http://rbrundritt.wordpress.com

    Wednesday, September 18, 2013 6:28 PM
    Owner