BingRouteCalculatedEventArgs.CalculationResult Property
Returns a result of a route calculation.
Namespace: DevExpress.Xpf.Map
Assembly: DevExpress.Xpf.Map.v24.1.dll
NuGet Package: DevExpress.Wpf.Map
Declaration
Property Value
Type | Description |
---|---|
RouteCalculationResult | A RouteCalculationResult object. |
Example
Private Sub routeDataProvider_RouteCalculated(ByVal sender As Object, ByVal e As BingRouteCalculatedEventArgs)
Dim result As RouteCalculationResult = e.CalculationResult
Dim resultList As New StringBuilder()
resultList.Append(String.Format("Status: {0}" & ControlChars.Lf, result.ResultCode))
resultList.Append(String.Format("Fault reason: {0}" & ControlChars.Lf, result.FaultReason))
resultList.Append(ProcessIntermediatePoints(result.IntermediatePoints))
resultList.Append(ProcessRouteResults(result.RouteResults))
tbResults.Text = resultList.ToString()
End Sub
Private Function ProcessIntermediatePoints(ByVal points As List(Of RouteWaypoint)) As String
If points Is Nothing Then
Return ""
End If
Dim sb As New StringBuilder("Intermediate Points:" & ControlChars.Lf)
sb.Append(String.Format("_________________________" & ControlChars.Lf))
For i As Integer = 0 To points.Count - 1
sb.Append(String.Format("Intermediate point {0}: {1} ({2})" & ControlChars.Lf, i+1, points(i).Description, points(i).Location))
Next i
Return sb.ToString()
End Function
Private Function ProcessRouteResults(ByVal results As List(Of BingRouteResult)) As String
If results Is Nothing Then
Return ""
End If
Dim sb As New StringBuilder("RouteResults:" & ControlChars.Lf)
For i As Integer = 0 To results.Count - 1
sb.Append(String.Format("_________________________" & ControlChars.Lf))
sb.Append(String.Format("Path {0}:" & ControlChars.Lf, i+1))
sb.Append(String.Format("Distance: {0}" & ControlChars.Lf, results(i).Distance))
sb.Append(String.Format("Time: {0}" & ControlChars.Lf, results(i).Time))
sb.Append(ProcessLegs(results(i).Legs))
Next i
Return sb.ToString()
End Function
Private Function ProcessLegs(ByVal legs As List(Of BingRouteLeg)) As String
If legs Is Nothing Then
Return ""
End If
Dim sb As New StringBuilder("Legs:" & ControlChars.Lf)
For i As Integer = 0 To legs.Count - 1
sb.Append(String.Format(ControlChars.Tab & "Leg {0}:" & ControlChars.Lf, i+1))
sb.Append(String.Format(ControlChars.Tab & "Start: {0}" & ControlChars.Lf, legs(i).StartPoint))
sb.Append(String.Format(ControlChars.Tab & "End: {0}" & ControlChars.Lf, legs(i).EndPoint))
sb.Append(String.Format(ControlChars.Tab & "Distance: {0}" & ControlChars.Lf, legs(i).Distance))
sb.Append(String.Format(ControlChars.Tab & "Time: {0}" & ControlChars.Lf, legs(i).Time))
sb.Append(ProcessItinerary(legs(i).Itinerary))
Next i
Return sb.ToString()
End Function
Private Function ProcessWarnings(ByVal warnings As List(Of BingItineraryItemWarning)) As String
If warnings Is Nothing Then
Return ""
End If
Dim sb As New StringBuilder(ControlChars.Tab & ControlChars.Tab & "Warnings:" & ControlChars.Lf)
For i As Integer = 0 To warnings.Count - 1
sb.Append(String.Format(ControlChars.Tab & ControlChars.Tab & ControlChars.Tab & "Warning {0}:" & ControlChars.Lf, i + 1))
sb.Append(String.Format(ControlChars.Tab & ControlChars.Tab & ControlChars.Tab & "Type: {0}" & ControlChars.Lf, warnings(i).Type))
sb.Append(String.Format(ControlChars.Tab & ControlChars.Tab & ControlChars.Tab & "Text: {0}" & ControlChars.Lf, warnings(i).Text))
Next i
Return sb.ToString()
End Function
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CalculationResult property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
See Also