1

I am using realistic street networks imported from OpenStreetMap for simulations with Veins, for example the Luxembourg scenario from Lara Codeca. Now, to prepare a visualisation (using Google Earth), I want to export the vehicle positions in the simulation from SUMO or OmNET coordinates to GPS coordinates.

As material I have the OSM file used for generating the scenario, including the GPS positions of all nodes there. I was hoping to find a simple mapping from the simulation coordinates to GPS coordinates, for example, by knowing the GPS coordinates of the corners of the bounding box and the simulation playground.

Is there a simple way to make this conversion, and how can I find the actual corners that were used by the OSM conversion when generating the playground?

mwil.me
  • 1,134
  • 1
  • 19
  • 33
  • 1
    If you used netconvert to create a .net.xml from the .osm file, the network will have stored details on the projection used. You can quickly check by running the SUMO simulation in GUI mode: if projection information is available, you should see your mouse pointer's position as both x/y and lon/lat in the bottom right corner of the window. – Christoph Sommer Feb 01 '16 at 07:43
  • @ChristophSommer I only see another set of x/y around 3e5/5.5e6, the .net.xml file contains the following line: This should get me started, I will check the SUMO docs. Is there some way to read the projection information from SUMO using traci? – mwil.me Feb 01 '16 at 08:01
  • You might have built your SUMO binary without PROJ or GDAL support. SUMO will then not be able to invert the projection for you. I just tried running the Veins example scenario: at least for this scenario, `traci->getLonLat(mobility->getCurrentPosition())` returns sensible coordinates like [11.0313, 49.5739](https://www.google.com/maps/place/49.5739,11.0312) – Christoph Sommer Feb 02 '16 at 16:57
  • @mwil.me can you please explain how you did the visualization? – bincob Nov 13 '17 at 09:20

1 Answers1

2

The conversion works as follows:

1. Accessing the Location Information from OmNET

// Adapt your path to the mobility module here  
Veins::TraCIMobility* mobility =
  check_and_cast<Veins::TraCIMobility*>(
    getParentModule()->getSubmodule("veinsmobility"));

Veins::TraCICommandInterface* traci = mobility->getCommandInterface();

Coord currPos = mobility->getCurrentPosition();
std::pair<double, double> currLonLat = traci->getLonLat(currPos);

getLonLat() returned absolute 2D coordinates for me, so there is a conversion step required.

2. Finding the Transformation

The .net.xml file from SUMO contains the required transformation. The <location> tag contains the attributes netOffset and projParameters that are needed.

For the Luxembourg scenario, these are

netOffset="-285448.66,-5492398.13"
projParameter="+proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"

3. Inversing the Transformation

The library PROJ.4 can be used to do the inversion. A Python interface is also available (pyproj).

import pyproj

projection = pyproj.Proj(
  "+proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")

# x, y obtained from OmNET
lon, lat = projection(x, y, inverse=True)

In case only the relative location information is available, the x, y values must be adjusted first by adding the netOffset values to them.

Edit

Only the first step is necessary when you build SUMO --with-proj-gdal support, the result of getLonLat() will be in the desired format immediately.

mwil.me
  • 1,134
  • 1
  • 19
  • 33
  • I was able to create a SUMO network from an OSM map and was able to run the Veins simulation on OMNet++ but the simulation playground does not display the polygon shapes. Seeing that you have worked on this, can you please let me know if you have faced similar issues? – bincob Nov 13 '17 at 09:59