2

I have to keep found location on GIS map as the search result in my model for further use. To get a location on GIS map I use:

GISRegion gisRegion = null;
gisRegion = map.searchFirstRegion(cityName);

How to convert gisRegion to be cached and saved in the Model? I have to execute this command as in the anylogic help, but with java:

enter image description here

Thanks a lot.

dkdelta
  • 53
  • 4

1 Answers1

1

You already do it. Just store it in a separate variable:

  1. create a variable "myGISRegion" on Main, make its type to GISRegion
  2. on startup of Main, call the code myGISRegion = map.searchFirstRegion(cityName);
  3. now, your variable can be used during the model run forever, it is also cached automatically (test this offline, it should still work)
Benjamin
  • 10,603
  • 3
  • 16
  • 28
  • Thanks Benjamin, but if I have 10000 "cityNames" my Model will get 10000 values of `gisRegion` on each startup. It will take much more time I think and I don't understand how I can search the region that I need in this list of region in this case? My idea was to get 10000 values of `gisRegion` and save them in the Model one time and work with. – dkdelta Aug 03 '22 at 12:35
  • that is how caching works. Try it once online, then turn off internet and rerun the model. The code should get the regions from the cache – Benjamin Aug 03 '22 at 17:01