XRoute - determine distance for different kind of roads

This forum deals with any kind of routing computation whether it is simple A:B-routing, calculation of isochrones, simple matrix computation or nearest search.
Post Reply
huellif
Posts: 7
Joined: Mon Feb 19, 2018 7:51 am

XRoute - determine distance for different kind of roads

Post by huellif »

Hello there,

I got the following request:
There is a bigger extended route inside of Germany (~8k km) and my boss wants to know the driven distance per road type. E.g. how many kilometers on the autobahn, state roads, country roads or city roads
But I could calculate only the toll and total distance via ExtendedRoute in our Java Enviroment.

Is this possible via XRoute?

Thanks in advance!

BR,
Fabian
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: XRoute - determine distance for different kind of roads

Post by Bernd Welter »

Hello Fabian,

aggregating the distances and periods per NC is simple, just use the property perNCRouteInfo of the CountryInfo and sum them up in the way you like:
Information about distance and time per network class.
Additionally the cost field of the RouteInfo object holds the toll distance. Please note that these distances may differ in some countries (e.g. Germany) from perTypeTollDistance as they are based on the routing calculation and not on the official distance tables provided by the government, which are not available per network class.
This fragment of C# code will give you a list of driving times, distances, ... per NC in all the countries that are passed:

Code: Select all

ExtendedRoute extRoute = svcRoute.calculateExtendedRoute(lstWPD.ToArray(), null, null, rlo, cio, null);
RouteInfo[] arrRouteInfo = new RouteInfo[8];
for (int i = 0; i < 8; i++)
{
    arrRouteInfo[i] = new RouteInfo();
    foreach (CountryInfo ci in extRoute.wrappedCountryInfos)
    {

        RouteInfo curRouteInfo = ci.wrappedPerNCRouteInfo[i];
        arrRouteInfo[i].cost += curRouteInfo.cost;
        arrRouteInfo[i].distance += curRouteInfo.distance;
        arrRouteInfo[i].hasViolations = arrRouteInfo[i].hasViolations || curRouteInfo.hasViolations;
        arrRouteInfo[i].hasViolationsSpecified = arrRouteInfo[i].hasViolationsSpecified && curRouteInfo.hasViolationsSpecified;
        arrRouteInfo[i].time += curRouteInfo.time;
    }
}
Sample output of a route from Gothenburg (Sweden) to Karlsruhe (Germany) via Hamburg (Germany)
Sample output of a route from Gothenburg (Sweden) to Karlsruhe (Germany) via Hamburg (Germany)
SummedNC.PNG (7.22 KiB) Viewed 6752 times
Best regards,
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:
huellif
Posts: 7
Joined: Mon Feb 19, 2018 7:51 am

Re: XRoute - determine distance for different kind of roads

Post by huellif »

Hello Bernd,

much thanks for your reply :)

Best Regards,
Fabian
huellif
Posts: 7
Joined: Mon Feb 19, 2018 7:51 am

Re: XRoute - determine distance for different kind of roads

Post by huellif »

Hello there,

i played a bit and it's working fine so far :)

But there are the network classes 0 - 7 only, I guess it's mapped like that:

//0 - Autobahn
//1 - ?
//2 - Bundesstraße
//3 - ?
//4 - Kreisstraße
//5 - Innerorts
//6 - ?
//7 - ?

Is there any documentation about which class means what? (at least for Germany)

The documentation doesn't really help: http://xserver.ptvgroup.com/fileadmin/f ... _Class.htm

Thanks in advance!

BR,
Fabian
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: XRoute - determine distance for different kind of roads

Post by Bernd Welter »

Helo Fabian,

maybe this thread helps - I simply looked for Autobahn:
https://xserver.ptvgroup.com/forum/view ... bahn#p1195

Best regards,
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:
huellif
Posts: 7
Joined: Mon Feb 19, 2018 7:51 am

Re: XRoute - determine distance for different kind of roads

Post by huellif »

Hello Bernd,

thanks for your quick answer, I can work with that.

Best Regards,
Fabian
Post Reply