question

Miguel_ngel Ra avatar image
0 Likes"
Miguel_ngel Ra asked Walker huang commented

Create automatically points and network in GIS


I have data of many stores across Lima and I need to set them in the map automatically using Flexscript and create the network between them to start to experiment alternatives to delivering products to the stores.

bodegas_sample.xlsx

FlexSim 22.1.0
flexscriptgislogisticsagv routing
bodegas-sample.xlsx (14.4 KiB)
· 1
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 ·

Hi @Miguel_ngel Ra, was one of Phil BoBo's or Alyson P's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·
Phil BoBo avatar image
1 Like"
Phil BoBo answered Phil BoBo edited
· 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.

Miguel_ngel Ra avatar image Miguel_ngel Ra commented ·
i need something that create automatically points and distance between them, not doing 1 per 1.
0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Miguel_ngel Ra commented ·

Put the code you need from the example into a loop using your own code that accesses your data and uses it the way you want.

0 Likes 0 ·
Alyson P avatar image
1 Like"
Alyson P answered Walker huang commented

Hello @Miguel_ngel Ra sure, I'll send you the code and explain what I have done in it.

//create a navigator object
Object navigator = model().find("GISNavigator");

//clear all the previous points in the map
navigator.subnodes.clear();

//reference an existing global table with all the cities and their latitude and longitude 
Table table = reftable("GlobalTable1");

//a for to search all the rows in the global table
for(int i = 1; i <= table.numRows; i++){
        //create a point in the navigator
        Object point1 = createinstance(library().find("/GIS/Point"), navigator);
        
        //set the properties of the points using values from global table
        point1.name = table[i][1];
        point1.setProperty("Latitude", table[i][2]);
        point1.setProperty("Longitude", table[i][3]);
               
        //set the size of the points and their color, nothing really important
        point1.setSize(40, 30, 20);
        point1.color = Color.red;
        
        //store all the points in a vector in case I need them, not really important too
        vetor_pontos[i] = point1;

        //repaint the map to show new points
        repaintall();


In my model I did not connect all the dots when creating them, I am using clusters so when creating teh cluster, I also create the connection

contextdragconnection(point1, point2, "A");


And after the connection is done, you can use the following code to get their distances

double distance = function_s(point1, "getDistance", point2);


It is also worth mention that to fill my global table I created a function that gets all the data from an Excel spreadsheet and only them I referenced it as showed in the first piece of code.


If you have any other question that I can help, feel free to send me another message and sorry for taking a lilttle long to answer you.

· 8
5 |100000

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

Miguel_ngel Ra avatar image Miguel_ngel Ra commented ·

Thanks Alyson


How do you insert the script? inside of some structure of processflow?

0 Likes 0 ·
Alyson P avatar image Alyson P Miguel_ngel Ra commented ·
I created a GUI, because I nedd a user friendly interface, and inserted the code in the buttons.
0 Likes 0 ·
Miguel_ngel Ra avatar image Miguel_ngel Ra Alyson P commented ·
would you share with me your flexsim file to see how create a GUI please
0 Likes 0 ·
Walker huang avatar image Walker huang commented ·
Hi Alyson,

I am modeling something like this. thank you for your great guideline. as for the "getDistance", it is a built-in function for GIS point, right? if yes, but I cannot find it's treeNode. it will be better if you can give some explanation on this. thank you very much!

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Walker huang commented ·

It's a function of the class that doesn't appear under instances in the model tree.

0 Likes 0 ·
Walker huang avatar image Walker huang Jason Lightfoot ♦♦ commented ·

thanks for your answer. additionally, I also can't find the function "getDistance" from user manual.

0 Likes 0 ·
Show more comments