Xroute calculate a route

Within this forum we want to offer discussions all around our .NET based xServer controls.

Xroute calculate a route

Postby kemmlit » Thu Mar 09, 2017 3:48 pm

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

Postby kemmlit » Fri Mar 10, 2017 9:28 am

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

Re: Xroute calculate a route

Postby Asterix » Mon Mar 20, 2017 12:14 pm

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

C u,
Bernd
Bernd Welter
Manager Technical Consulting & Requirement Engineering
Senior Technical Consultant Developer Components
PTV GROUP - Germany

https://www.youtube.com/channel/UCgkUli9yGf0gwTDdxbMZ-Kg
User avatar
Asterix
Site Admin
 
Posts: 743
Joined: Mon Apr 14, 2014 10:28 am


Return to PTV xServer.NET (Admin=OH)

cron