Page 1 of 1

Xroute calculate a route

Posted: Thu Mar 09, 2017 3:48 pm
by kemmlit
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

Re: Xroute calculate a route

Posted: Fri Mar 10, 2017 9:28 am
by kemmlit
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

Re: Xroute calculate a route

Posted: Mon Mar 20, 2017 12:14 pm
by Bernd Welter
I'll get in touch with you 1:1...

C u,
Bernd