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.

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.

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.

  1. //create a navigator object
  2. Object navigator = model().find("GISNavigator");
  3.  
  4. //clear all the previous points in the map
  5. navigator.subnodes.clear();
  6.  
  7. //reference an existing global table with all the cities and their latitude and longitude
  8. Table table = reftable("GlobalTable1");
  9.  
  10. //a for to search all the rows in the global table
  11. for(int i = 1; i <= table.numRows; i++){
  12. //create a point in the navigator
  13.         Object point1 = createinstance(library().find("/GIS/Point"), navigator);
  14.         
  15. //set the properties of the points using values from global table
  16.         point1.name = table[i][1];
  17.         point1.setProperty("Latitude", table[i][2]);
  18.         point1.setProperty("Longitude", table[i][3]);
  19.                
  20.         //set the size of the points and their color, nothing really important
  21.         point1.setSize(40, 30, 20);
  22.         point1.color = Color.red;
  23.         
  24.         //store all the points in a vector in case I need them, not really important too
  25.         vetor_pontos[i] = point1;
  26.  
  27. //repaint the map to show new points
  28. 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

  1. contextdragconnection(point1, point2, "A");


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

  1. 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.