Page 1 of 1

Via points sorting

Posted: Wed May 17, 2017 12:18 pm
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

Re: Via points sorting

Posted: Mon Jun 05, 2017 4:11 pm
by krzysiek mbis
Hi,
Is there a way to achieve this functionality using xRouteServer ?

Best Regards,
Krzysztof Paziewski

Re: Via points sorting

Posted: Wed Jun 07, 2017 6:39 am
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

Re: Via points sorting

Posted: Thu Jun 08, 2017 8:45 am
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.

Re: Via points sorting

Posted: Thu Jun 08, 2017 9:04 am
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

Re: Via points sorting

Posted: Thu Jun 08, 2017 9:19 am
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 ?

Re: Via points sorting

Posted: Thu Jun 08, 2017 9:44 am
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.

Re: Via points sorting

Posted: Thu Jun 08, 2017 12:03 pm
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;
}

Re: Via points sorting

Posted: Fri Jun 09, 2017 5:55 am
by krzysiek mbis
Thanks you very much for the answer.

Best Regards,
Krzysiek