Anylogic GIS 以编程方式搜索给定位置的学校

Anylogic GIS programmatically search for schools in a given location

在不使用 anylogic 的 GIS 地图中的搜索选项的情况下,我希望 Anylogic 获取用户输入的位置名称,然后在该位置放置代理。然后,随着模型的运行,我希望它搜索之前找到的 agent/location 附近的学校。然后我希望将找到的学校制作成一个集合。这对我进一步计算某些方面很重要。我如何在 Java.

中使用 functions/codes 执行此操作

我可以在 anylogic 的 GIS 地图搜索 window 中使用单独搜索来实现所有这些。但我希望它发生,一旦用户在模拟中输入位置作为用户输入 window(使用参数左右),地图会自动将代理放在那里,然后搜索学校,然后将代理放在那里然后这些代理成为一个集合,将在另一个函数中用于计算。我想使用 codes.Please 帮助使其自动化。提前致谢。

您将需要设置大量代理并根据您在自定义代理中创建的参数指定它们的初始位置。

对于这个简单的示例,我创建了字符串类型的变量 location,用户可以在其中输入您要搜索学校的位置。

然后在创建代理按钮中我添加了这段代码

// Find the location we are searching for as a GPS point
GISPoint point = map.searchFirst(location);

// Set the visible map to this location
map.setCenterLatitude(point.getLatitude());
map.setCenterLongitude(point.getLongitude());
map.setMapScale(1/1000000.0);

//Set the search parameters to be within a range from the location we got
map.setSearchBounds(point.getLatitude()-5, point.getLongitude()-5, point.getLatitude()+5, point.getLongitude()+5);

// Search for points within the map serachable area and for each create a new agent.
List<GISPoint> schools = map.search("School");
for (GISPoint gisPoint:schools){
    add_myAgent(gisPoint);
}

它在测试时有效,但是,纽约周围可搜索区域中学校的结果非常小。但即使是手动操作也是如此。