question

Tomi Kosunen avatar image
0 Likes"
Tomi Kosunen asked Jordan Johnson commented

GIS Webresponse

Hi

I need to get the value from webResponses node: I need the string "url: https://maps.flexsim.com/route/v1/driving/24.0712171343953,60.7636176963182;25.126391877717,60.4215668962423?geometries=geojson&overview=full"

How do I get the node values for all webResponses in the model?

webResponse.fsm


FlexSim 23.2.0
gisnode
webresponse.fsm (72.0 KiB)
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
0 Likes"
Jordan Johnson answered Jordan Johnson commented

I think you need code like this:

getsdtvalue(webResponsesNode.subnodes[i], "response")

From there, you could use JSON.parse() to create a Map and extract the data:

treenode navigator = Model.find("GISNavigator");
treenode webResponsesNode = navigator.find(">variables").subnodes["webResponses"];
for (int i=1; i<=webResponsesNode.subnodes.length; i++){
  string response = getsdtvalue(webResponsesNode.subnodes[i], "response");
  Variant object = JSON.parse(response);
  print(object.routes[1].geometry.coordinates);
}
· 2
5 |100000

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

Tomi Kosunen avatar image Tomi Kosunen commented ·

Thanks @Jordan Johnson Now the code is returning the response from the GIS server. What if I need the query, I mean the string "url: https://maps.flexsim.com/route/v1/driving/24.0712171343953,60.7636176963182;25.126391877717,60.4215668962423?geometries=geojson&overview=full"

How do I get that?

I have modified the routing logics quite a lot and I have routing server running on my own computer. For some reason the "function_s(c, "findWebResponse", url);" in downloadRoute is always returning <no path> . In my model I can see that there is a route with exactly same parameters already in the tree, so I'd like to find the webresponse by myself and there I need to know the existing query which I can then compare to new query.

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Tomi Kosunen commented ·

To get the url, use getsdtvalue(), but pass "url" instead of "response":

getsdtvalue(webResponsesNode.subnodes[i], "url")

If I run the following code, the findWebResponse method works correctly in the model you posted:

treenode navigator = Model.find("GISNavigator");
string url = "https://maps.flexsim.com/route/v1/driving/24.0712171343953,60.7636176963182;25.126391877717,60.4215668962423?geometries=geojson&overview=full";
return function_s(navigator, "findWebResponse", url);

However, if you are making custom changes to the GIS navigator, it will be difficult to provide better support.

0 Likes 0 ·