question

Lars Christian J2 avatar image
0 Likes"
Lars Christian J2 asked Jason Lightfoot commented

How to connect GIS to a SeaRoute server?

I would like to use searoutes.com for making sailing routes in the GIS. I am not sure how to set it up. Can anyone help?

1685612024836.png


1685612054730.png



https://developer.searoutes.com/reference/getsearoute

SeaRoutes.fsm

FlexSim 23.1.2
gis
1685612024836.png (78.6 KiB)
1685612054730.png (131.0 KiB)
searoutes.fsm (45.8 KiB)
· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·
Is is an OpenStreetMap (OSRM) server?
0 Likes 0 ·
Lars Christian J2 avatar image Lars Christian J2 Jason Lightfoot ♦ commented ·
I do not know. It is a service you have to pay for. You can get a 7 day free test license on their web page
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Lars Christian J2 commented ·

I've got an x-api-key and have tried to use the http.request to get data - hope to see what's possible.

0 Likes 0 ·
Show more comments

1 Answer

·
Jordan Johnson avatar image
1 Like"
Jordan Johnson answered Jason Lightfoot commented

The GIS navigator was designed to be extendable. It does this through how function_s() works. If you call function_s(someObject, "someFunction"), then FlexSim searches for someFunction in the object first, then in the object's library definition.

Step 1: I added the following subnodes to the GIS navigator:
1685731520406.png

Step 2: I copied the code for downloadRoute and downloadRouteSuccess from MAIN:/project/library/GIS/GISNavigator>behaviour/eventfunctions

Step 3: I updated the code for downloadRoute. Basically, I check to see if the url has the term "searoutes.com" in it. If so, I add the x-api-key to the header, and specify the new callbacks for success and failure.

Step 4: In the new success callback, I extract the necessary data from the response by parsing it as a Map. Then I make a new Map the way the GIS Navigator expects in the default applyResponseToRoute function.

The general approach was "copy/paste/modify" so it's not too difficult. Consider using a diff tool to see the changes I made to the code, compared to what's in the library.

The model is attached. You'll need to update the api key in the downloadRoute function to the API key for your account with searoutes.com.

searoutes_working.fsm

Using this approach, I was able to get the desired route working:
1685732027162.png


1685731520406.png (29.5 KiB)
1685732027162.png (84.4 KiB)
· 11
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Lars Christian J2 avatar image Lars Christian J2 commented ·
Thanks a lot!!!
0 Likes 0 ·
NEEDHELP avatar image NEEDHELP commented ·

Hello do you have sample searoutes work for flexsim 22.2 version? thank you

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ NEEDHELP commented ·
You've asked this question here. Please avoid creating duplicate questions.
0 Likes 0 ·
NEEDHELP avatar image NEEDHELP commented ·
Hello do you have youtube video about this? on how to do this? thank you
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ NEEDHELP commented ·
With which of Jordan's steps are you having trouble?
0 Likes 0 ·
NEEDHELP avatar image NEEDHELP Jason Lightfoot ♦ commented ·
from the start huhuh sorry im not a techy person. :< im a newbie
0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.