-
Notifications
You must be signed in to change notification settings - Fork 179
faq 302383134
by Gregory Macfarlane on 2018-07-13 14:59:04
I want to ensure that the facilities in my simulation are associated with nodes and links that are not limited-access facilities like freeways, etc. So when I pick the starting location for a trip, it does not "appear" in the middle of a freeway.
When I generate my demand I have the coordinates of facilities, so it would be trivial to instead look up the nearest permissible link to that facility. But I don't see a mechanism to add custom link fields to the network, so I can't filter the network on that value. Is there a mechanism to add custom link fields? Is there another solution to this issue?
by Davi Bicudo on 2018-07-13 15:08:59
Network implements Attributable (as many other objects in MATSim), so you may use link.getAttributes().putAttribute(String attribute, Object value).
You might find helpful the the pt2matsim contrib (https://github.com/matsim-org/pt2matsim). It allows you to convert an OSM network to MATSim and optionally include OSM tags as attributes in the links.
Finally to assign the links to your facilities you may use NetworkUtils.getNearestLink(network, coord) from MATSim core distribution.
by Thibaut Dubernet on 2018-07-13 15:10:46
Dear Gregory,
Links, as most data structures now, implement the Attributable interface. Thus, they have a getAttributes() method, that returns an object where you can store arbitrary String-Object pairs. Those mappings are written to the XML file as well. It is the case since release 0.9.
Hope that it corresponds to what you were searching for!
You are viewing an archive of the previous MATSim Q&A site. The real site is now at https://matsim.org/faq