Hey guys,
I would like to calculate a route with the XRouteServiceReference calculate Route in VB.Net.
I have multiple X and Y coordinates and would like to get all of them into one single route.
I thought it would work if I load all of my coordinates into a PointCollection and then :
route = XRouteClient.calculateRoute(PointCollection,Nothing, Nothing, New ResultListOptions() With {.polygon = True}, New XRouteServiceReference.CallerContext() With {.wrappedProperties = New XRouteServiceReference.CallerContextProperty() {New XRouteServiceReference.CallerContextProperty() With {.key = "CoordFormat",.value = "OG_GEODECIMAL"}})
but it cant convert the PointCollection into WaypointDesc.
The Example on github doesnt help me anything, cause I have a variable amount of Points.
Could anyone help me?
Many thanks,
Benedikt Luz
Xroute calculate a route
Re: Xroute calculate a route
I now tried to just calculate a Route for every 2 waypoints. But now the problem is I have points with this error: cannot calculate route (concerning leg 1)...
Private Function CalcRoute(lat1, lon1, lat2, lon2)
Dim xRouteClient = New XRouteWSClient()
Dim RoutOption As RoutingOption() = New RoutingOption(7) {}
RoutOption(0) = New RoutingOption
RoutOption(0).parameter = RoutingParameter.ALLOW_SEGMENT_VIOLATIONS
RoutOption(0).value = True
RoutOption(1) = New RoutingOption
RoutOption(1).parameter = RoutingParameter.COST_OF_SEGMENT_VIOLATIONS
RoutOption(1).value = 0
xRouteClient.ClientCredentials.UserName.UserName = "xtok"
xRouteClient.ClientCredentials.UserName.Password = token
' just need the distance
Return xRouteClient.calculateRoute(New WaypointDesc() {New WaypointDesc() With {
.wrappedCoords = New FormsMapVB.XRouteServiceReference.Point() {New FormsMapVB.XRouteServiceReference.Point() With {
.point = New PlainPoint() With {
.x = lon1,
.y = lat1
}
}}
}, New WaypointDesc() With {
.wrappedCoords = New FormsMapVB.XRouteServiceReference.Point() {New FormsMapVB.XRouteServiceReference.Point() With {
.point = New PlainPoint() With {
.x = lon2,
.y = lat2
}
}}
}}, RoutOption, Nothing, New ResultListOptions() With {.polygon = True}, New CallerContext() With {
.wrappedProperties = New CallerContextProperty() {New CallerContextProperty() With {
.key = "CoordFormat",
.value = "OG_GEODECIMAL"
}}
})
End Function
Private Function CalcRoute(lat1, lon1, lat2, lon2)
Dim xRouteClient = New XRouteWSClient()
Dim RoutOption As RoutingOption() = New RoutingOption(7) {}
RoutOption(0) = New RoutingOption
RoutOption(0).parameter = RoutingParameter.ALLOW_SEGMENT_VIOLATIONS
RoutOption(0).value = True
RoutOption(1) = New RoutingOption
RoutOption(1).parameter = RoutingParameter.COST_OF_SEGMENT_VIOLATIONS
RoutOption(1).value = 0
xRouteClient.ClientCredentials.UserName.UserName = "xtok"
xRouteClient.ClientCredentials.UserName.Password = token
' just need the distance
Return xRouteClient.calculateRoute(New WaypointDesc() {New WaypointDesc() With {
.wrappedCoords = New FormsMapVB.XRouteServiceReference.Point() {New FormsMapVB.XRouteServiceReference.Point() With {
.point = New PlainPoint() With {
.x = lon1,
.y = lat1
}
}}
}, New WaypointDesc() With {
.wrappedCoords = New FormsMapVB.XRouteServiceReference.Point() {New FormsMapVB.XRouteServiceReference.Point() With {
.point = New PlainPoint() With {
.x = lon2,
.y = lat2
}
}}
}}, RoutOption, Nothing, New ResultListOptions() With {.polygon = True}, New CallerContext() With {
.wrappedProperties = New CallerContextProperty() {New CallerContextProperty() With {
.key = "CoordFormat",
.value = "OG_GEODECIMAL"
}}
})
End Function
- Bernd Welter
- Site Admin
- Posts: 2703
- Joined: Mon Apr 14, 2014 10:28 am
- Contact:
Re: Xroute calculate a route
I'll get in touch with you 1:1...
C u,
Bernd
C u,
Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany
Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning...
Technical Partner Manager Developer Components
PTV Logistics - Germany
Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning...