Xroute calculate a route

Within this forum we want to offer discussions all around our .NET based Map control including all .Net-language specific questions concerning calls of the xServer-API. Attention: xServer-relevant concepts can be found in further forums such as xRoute or xTour.
Post Reply
kemmlit
Posts: 3
Joined: Fri Nov 11, 2016 2:10 pm
Location: Germany, Dusslingen

Xroute calculate a route

Post 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
kemmlit
Posts: 3
Joined: Fri Nov 11, 2016 2:10 pm
Location: Germany, Dusslingen

Re: Xroute calculate a route

Post 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
User avatar
Bernd Welter
Site Admin
Posts: 2703
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Xroute calculate a route

Post by Bernd Welter »

I'll get in touch with you 1:1...

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... :twisted:
Post Reply