Via points sorting

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
User avatar
krzysiek mbis
Posts: 37
Joined: Thu Aug 11, 2016 9:41 am

Via points sorting

Post by krzysiek mbis »

Hi,
PTV Map & Guide Internet has some nice functionality.
When user adds new via point map calculates its index (for optimization reasons I suppose).
How can I do it using api ?

Best Regards,
Krzysiek
Krzysiek Paziewski
.Net Developer/Team Leader at Marcos Bis
Katowice, Silesian District, Poland
User avatar
krzysiek mbis
Posts: 37
Joined: Thu Aug 11, 2016 9:41 am

Re: Via points sorting

Post by krzysiek mbis »

Hi,
Is there a way to achieve this functionality using xRouteServer ?

Best Regards,
Krzysztof Paziewski
Krzysiek Paziewski
.Net Developer/Team Leader at Marcos Bis
Katowice, Silesian District, Poland
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Via points sorting

Post by Bernd Welter »

Hello Krzysztof,

what exactly do you mean by "it's index"?

Imagine your current waypointlist contains the elements W[0],...W[n-1] and you want to add another point.
The task you refer to is then a question of user handling and probably not a question of a specific API usage.
I assume that you want to add the new waypoint W in the list based on one of the following approaches:
  • Add as start: W - W[0] - ... W[n-1]
  • Add as destination: W[0] - ... W[n-1] - W
  • Add before current selection ...
  • Add after current selection ...
Or what do you mean?

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:
User avatar
krzysiek mbis
Posts: 37
Joined: Thu Aug 11, 2016 9:41 am

Re: Via points sorting

Post by krzysiek mbis »

Ptv Map&Guide internet adds via points like that:
First we have:
1.PNG
Start point has index 1.
Via point has index 2.
End point has index 3.
Now I want to add another via point somewhere near Frankfurt.
(This will be the second via point)
Now I have:
2.PNG
Route will be like that : Start point -> Second Added via point -> First added via point -> End point.
So, my second via point has index 2, not 3.
But, if I add via point not in Frankfurt, but somewhere close to end point Łódź, situation will be different:
3.PNG
Now, new via point has index 3.
Route will be like that : Start point -> First added via point -> Second Added via point -> End point.
There is some optimization going on there.
In my app (Windows app based on xRouteServer). Whereever i put my second via point i will always have:
Start point -> First added via point -> Second Added via point -> End point.
And I would like for my app to bahave like Map&Guide internet.
Is it possible ?

Best Regards,
Krzysiek.
Krzysiek Paziewski
.Net Developer/Team Leader at Marcos Bis
Katowice, Silesian District, Poland
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Via points sorting

Post by Bernd Welter »

I still don't get the point:
it is the business logic that decides where to add the new waypoint in the xRoute servers input waypoint list.
The server then get's an array of waypoints and keeps the sequence for the route.
What exactly do you expect from the server? The task seems to be raletd to "how to manupulate an array?" but nothing more.

Maybe you should keep in mind that there is always a context of the last station to be added. And depending on the event handling you add the new waypoint:

Code: Select all

List<WaypointDesc> lstWPD = new List<WaypointDesc>();
...
WaypointDesc newWPD = new WaypointDesc(){...};
lstWpd.add(newWPD); // add at the end
lstWpd.insert(0,newWPD); // add at the beginning...
//and so on
Let's say you have a current list of Waypoints in the grid (0, 1, ...8) and you selected line 3. That is the context.

Code: Select all

lstWpd.insert(3,newWPD); // add new point right before current context
lstWpd.insert(4,newWPD); // add new point right after current context
//and so on
Got me?

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:
User avatar
krzysiek mbis
Posts: 37
Joined: Thu Aug 11, 2016 9:41 am

Re: Via points sorting

Post by krzysiek mbis »

Screen was made on Map&Guide internet.
Now, user adds next via Point anywhere.
Map&Guide internet decides about its index.
Sometimes it will be in the end of via points list, sometimes it will be somewhere in the middle.
I suppose that It tries to resolve travelling salesman problem.
Am I right ?
Krzysiek Paziewski
.Net Developer/Team Leader at Marcos Bis
Katowice, Silesian District, Poland
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Via points sorting

Post by Bernd Welter »

Hello Krzysiek,

I forwarded this post to someone of the MAP&GUIDE team.
As soon as Oliver returns we'll reply here ;-)

Best regards,
Bernd

PS: if the approach used in MG Internet is based on sequencing you need xTour to solve it.
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:
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Via points sorting

Post by Bernd Welter »

Now I've been talking to Oliver.
The business logic within MAP&GUDIE Internet is simple:

We identify the index that causes the lowest detour via airline :
(improvised code ;-) )

Code: Select all

public int getInsertionIndex(WaypointDesc[] currentStationList, WaypointDesc wpd)
{
    int index = -1, opt_detour = int.MaxValue;
    for (int insertion = 0; insertion < currentStationList.Length - 1; insertion++)
    {
        int detour = airline(currentStationList[insertion], wpd);
        detour += airline(wpd, currentStationList[insertion + 1]);
        if (detour < opt_detour)
        {   opt_detour = detour;
            index = insertion;
        }
    }
    return index;
}
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:
User avatar
krzysiek mbis
Posts: 37
Joined: Thu Aug 11, 2016 9:41 am

Re: Via points sorting

Post by krzysiek mbis »

Thanks you very much for the answer.

Best Regards,
Krzysiek
Krzysiek Paziewski
.Net Developer/Team Leader at Marcos Bis
Katowice, Silesian District, Poland
Post Reply