0
votes

I have an Anylogic model in which vehicles move from point to point on a GIS map. The destination points are loaded from a database (see figure). By using a source block, the order details are mapped into a population of agents (Type Order). This set of orders is used to guide a vehicle over the GISmap. Now, I would like to know the distance that the vehicles traversed. However, I run into some troubles. The locations from the database can only be mapped to a parameter type string. This is annoying because this means that I can't use the "distanceTo" function for example. Is it possible to map the strings from the database to an agent of type location (which is a GISPoint)?

DB snapshot

1
Are you sure your agents are living in the GIS space? Without more information, it is very hard to assist. Maybe check this tutorial in the help section. anylogic.help/tutorials/gis/model.htmlJaco-Ben Vosloo
Hi Jaco-ben, Yes I'm pretty sure that I am in a GIS space. the floating problem is already solved (some locations were placed in the ocean). However, the locations in the DB are still imported as strings. The moveTo and jumpTo functions do work but the distanceTo function doesn't.Bart wolker
The main issue is that the locations are imported as a string and I need to convert it to a location on a GIS map.Bart wolker
Create a new agent which represents those locations and generate them from the DB. For example, all locations that you want to move to can be represented as a separate table in the DB and then you create agents from that table.Jaco-Ben Vosloo
I have created a population of agents placed on those locations. However, the locations are stored in the orders which are used by the vehicles. I have edited the question, I hope that my question is more clear now.Bart wolker

1 Answers

0
votes

What you need is an object that maps the location name (String) to an actual Agent (your location). You can use a LinkedHashMap for this

enter image description here

And then in the On startup: code of your location agent, you simply add it to the map.

enter image description here

Now you can access the actual agent using the location name so you can do

getDistanceTo(mapOfNameAndAgents.get("Boxtel"))