gpt4 book ai didi

java - 将 X 和 Y 转换为纬度和经度

转载 作者:行者123 更新时间:2023-12-02 13:09:08 27 4
gpt4 key购买 nike

我目前正在开展一个学校项目,我们必须设置交通模拟。我们决定使用TraaS .

TraaS 有一种方法可以检索给定车辆的当前 X 和 Y 坐标(请参阅 getPosition )。然而,这些 X 和 Y 坐标并不是实际的 map 坐标,而是相对于 SUMO 网络的坐标。

问题是:如何将这些相对坐标转换为地理坐标?

TraaS 有一个名为 convertGeo 的方法将 X 和 Y 坐标转换为地理坐标,但是该方法会引发异常。据我所知,我正在将正确的参数传递给该方法;两个 double 和一个字符串,指示您是将转换为还是地理坐标转换。该方法抛出以下异常:

命令 171 的 SUMO 错误:不支持源位置类型

//Get a random vehicle from the list of current vehicles in the simulation.
String vehicle = getRandomVehicle(); //Retrieves a random ID of an existing vehicle in the simulatio, don't worry about it,

SumoPosition2D pos = (SumoPosition2D) conn.do_job_get(Vehicle.getPosition(vehicle)); //Retrieves the last X and Y coordinates of the vehicle (example -> X: 6997.111901690444, Y: 7564.062169389001)

Object obj = conn.do_job_get(Simulation.convertGeo(pos.x, pos.y, "False")); //Throws an exception -> SUMO error for command 171: Source position type not supported)

最佳答案

查看code我想说该命令尚未在 TraaS 中实现。您可以使用 TraCI4J或者 python 客户端(推荐,因为它是最新的),它已经与 sumo 和 jython 捆绑在一起(如果您需要坚持使用 java)。

关于java - 将 X 和 Y 转换为纬度和经度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44020015/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com