Barathon
Barathon

Reputation: 45

Converting X & Y to Lat & Lon

I'm currently working on a school project where we have to set up a traffic simulation. We decided to use TraaS.

TraaS has a method to retrieve the current X and Y coordinates of a given vehicle (see getPosition). However these X and Y coordinates are not the actual map coordinates, but they are relative to the SUMO net.

The question is: How to convert these relative coordinates to geo coordinates?

TraaS has a method named convertGeo to convert X and Y coordinates to geo coordinates, however the method throws an exception. As far as I can tell I'm passing the correct arguments to the method; two doubles and a string which indicates whether you are converting to or from geo coordinates. The method throws the following exception:

SUMO error for command 171: Source position type not supported

//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) 

Upvotes: 0

Views: 313

Answers (2)

Barathon
Barathon

Reputation: 45

Thank you for the suggestion, Michael.

I have contacted the creator of TraaS and he did confirm it was a bug. The issue has been fixed in r48 (https://sourceforge.net/p/traas/code/48/). The parameters of convertGeo have also changed from (double, double, String) to (double, double, boolean).

Upvotes: 0

Michael
Michael

Reputation: 3680

From looking at the code I would say the command is not yet implemented in TraaS. You could either use TraCI4J or the python client (recommended because it is the most up to date one) which is already bundled with sumo together with jython (if you need to stick with java).

Upvotes: 1

Related Questions