Groovy & Funky

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
Max Beermann
Posts: 68
Joined: Tue Oct 30, 2018 7:36 am

Groovy & Funky

Post by Max Beermann »

Hey Bernd,

maybe this is the wrong topic (if so > sorry), but I do not know where to put better:

I want to manipulate our common routing-behavior by using Groovy.
http://xserver.ptvgroup.com/fileadmin/f ... ght=groovy


My first aim is to avoid switzerland by using the function "EXCLUDE_COUNTRIES" :

Code: Select all

<ArrayOfRoutingOption_3>
  <ns6:RoutingOption xmlns:ns6=”http://xroute.xserver.ptvag.com” parameter=”EXCLUDE_COUNTRIES“ value=”41“ />
</ArrayOfRoutingOption_3>
Is there any chance to convert/translate the code into groovy?
Or is there any solution/example where anybody had a similar aim?

PS: I already have the folder (scripts) with the appropriate file (xroute.groovy).


Many thanks for any feedback
Max
Max Beermann
Development Manager
WHEELS Logistics
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Groovy & Funky

Post by Bernd Welter »

Hello Max,

if you apply GROOVY in this scenario each and every routing will ignore Switzerland and you can't override it via request anymore. How about changing the profiles on server side which would create a new standard behaviour but also enable you to override it?

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
Max Beermann
Posts: 68
Joined: Tue Oct 30, 2018 7:36 am

Re: Groovy & Funky

Post by Max Beermann »

Hello Bernd,

that sounds nice.
But (i think) I can not change these settings, because they have been configurated by an external service provider.
That is why I came across with Groovy.

My intended main-logic is the following:

Code: Select all

If [b]Start-Country[/b]  <> "CH" (iuCode: 41) and  [b]End-Country[/b] is <> "CH" (iuCode: 41) then 
<ArrayOfRoutingOption_3>
  <ns6:RoutingOption xmlns:ns6=”http://xroute.xserver.ptvag.com” parameter=”EXCLUDE_COUNTRIES“ value=”41“ />
</ArrayOfRoutingOption_3>
End If
Is such an if-then condition makeable on profile/server-side?

Thanks very much!
Max
Max Beermann
Development Manager
WHEELS Logistics
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Groovy & Funky

Post by Bernd Welter »

I'll forward this to Lars.
He knows Groovy much better than me.

But I still don't get the point.
Especially because Groovy would also require to reconfigure the server.

Not only would Groovy bypass the providers settings (there must be a reason for this). It is also more restrictive compared to my approach.

Furthermore the overloading of the function as described would not consider routes with more than 2 stops.
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:
LNM_PTV
Posts: 14
Joined: Mon Apr 18, 2016 12:25 pm

Re: Groovy & Funky

Post by LNM_PTV »

Hi Max,

you can do such a if-else decision in a groovy script.
But you pass only coordinates into the request.

For the determination of the country codes of start and end points you need a reverse geocoding inside the script, or you have to pass that information via CallerContext.

Which way do you want to go?

Best regards,
Lars
Lars Moritz
Technical Consultant
PTV GROUP, Germany
User avatar
Max Beermann
Posts: 68
Joined: Tue Oct 30, 2018 7:36 am

Re: Groovy & Funky

Post by Max Beermann »

Hey there,

first of all > thanks for your feedback.

@Bernd:
I am using a Standard-TransportManagementSystem which is based on xServer.
I do not have the permission to manipulate the code.

To achieve some individual routings (ExcludeCountries, AvoidFerries, etc.) > Groovy seems to be a good alternative(?).

@Lars: I do not really know because I do not have an actual "feeling" for Groovy.
It is new to me.
But I thing I am gonna use the reverse-geocoding. That´s what I used to do with codes I have written before.

_ _ _ _ _


At the moment > I do not know how to start/get in touch with Groovy.
I think I have to read some more instructions.

If you have any idea sometime > please let me know ;)

Best regards+Thanks
Max
Max Beermann
Development Manager
WHEELS Logistics
User avatar
Max Beermann
Posts: 68
Joined: Tue Oct 30, 2018 7:36 am

Re: Groovy & Funky

Post by Max Beermann »

Hey Bernd,

I hope you all are doing fine :)
There is one topic.

On xServer1 - a Grooy-Script works really fine (for EXCLUDE_COUNTRIES).

Now I want to use xServer2.
Can I use the same Groovy-Script (maybe just adjust something here and there)?
Or do I need to solve EXCLUDE_COUNTRIES for xServer2 in a very different way?

Many Thanks!
Max
Max Beermann
Development Manager
WHEELS Logistics
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Groovy & Funky

Post by Bernd Welter »

Hello Max,
the xserver 2 modules have been redesigned from scratch so the methods, signatures and parameters have changed. Nevertheless also the xroute 2 offers mechanisms that allow you to specify which countries are allowed or forbidden.
Check both the routing options and the request profile (bit tricky to find)

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
Max Beermann
Posts: 68
Joined: Tue Oct 30, 2018 7:36 am

Re: Groovy & Funky

Post by Max Beermann »

Hey Bernd,

thanks for your reply!
I will inform you - hopefully because I could do it on my own ;)

Best regards
Max
Max Beermann
Development Manager
WHEELS Logistics
Post Reply