将 X 和 Y 转换为纬度和经度
Converting X & Y to Lat & Lon
我目前正在做一个学校项目,我们必须在其中设置交通模拟。我们决定使用 TraaS.
TraaS 有一种方法可以检索给定车辆的当前 X 和 Y 坐标(请参阅 getPosition)。然而,这些 X 和 Y 坐标并不是实际的地图坐标,而是相对于 SUMO 网络的坐标。
问题是:如何将这些相对坐标转换为地理坐标?
TraaS 有一个名为 convertGeo 的方法可以将 X 和 Y 坐标转换为地理坐标,但是该方法会抛出异常。据我所知,我正在将正确的参数传递给该方法;两个双打和一个字符串,指示您是将 转换为 还是从 地理坐标转换为 。该方法抛出以下异常:
命令 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 I would say the command is not yet implemented in TraaS. You could either use TraCI4J 或 python 客户端(推荐,因为它是最新的)已经与 sumo 和 jython 捆绑在一起(如果你需要坚持使用java).
迈克尔,谢谢你的建议。
我已经联系了 TraaS 的创建者,他确实确认这是一个错误。此问题已在 r48 (https://sourceforge.net/p/traas/code/48/) 中修复。 convertGeo的参数也从(double, double, String) 变成了(double, double, boolean)。
我目前正在做一个学校项目,我们必须在其中设置交通模拟。我们决定使用 TraaS.
TraaS 有一种方法可以检索给定车辆的当前 X 和 Y 坐标(请参阅 getPosition)。然而,这些 X 和 Y 坐标并不是实际的地图坐标,而是相对于 SUMO 网络的坐标。
问题是:如何将这些相对坐标转换为地理坐标?
TraaS 有一个名为 convertGeo 的方法可以将 X 和 Y 坐标转换为地理坐标,但是该方法会抛出异常。据我所知,我正在将正确的参数传递给该方法;两个双打和一个字符串,指示您是将 转换为 还是从 地理坐标转换为 。该方法抛出以下异常:
命令 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 I would say the command is not yet implemented in TraaS. You could either use TraCI4J 或 python 客户端(推荐,因为它是最新的)已经与 sumo 和 jython 捆绑在一起(如果你需要坚持使用java).
迈克尔,谢谢你的建议。
我已经联系了 TraaS 的创建者,他确实确认这是一个错误。此问题已在 r48 (https://sourceforge.net/p/traas/code/48/) 中修复。 convertGeo的参数也从(double, double, String) 变成了(double, double, boolean)。