question

Lars Jacobsen avatar image
0 Likes"
Lars Jacobsen 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.

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.