Hi,

I am trying to get an OSM (OpenStreetMap) file to match up in our
simulation environment: graphics and physics. In the OSM file there is:


*  <bounds minlat="52.3563000" minlon="4.9644000" maxlat="52.3695000"
maxlon="4.9950000"/>*
When using 'netedit' to open and convert this without changing any import
options (using the defaults), the resulting .net.xml file contains this:


*    <location netOffset="0.00,0.00"
convBoundary="632716.63,5781956.68,637568.98,5805326.56"
origBoundary="4.949961,52.171210,5.020771,52.382096"
projParameter="+proj=utm +zone=31 +ellps=WGS84 +datum=WGS84 +units=m
+no_defs"/>*
These lat/lon values no longer exactly match the original OSM file. In
fact, I'm having trouble getting our vehicle physics coordinates (in the
rest of our simulation) to match up like this. I have tried taking the
average of 'convBoundary' and 'origBoundary', but both of these are not the
same as the average from the original OSM file, and I get TraCI MoveToXY()
errors stating the car is more than 100 meters away from a road.

How I got the offset working after experimentation is to take the original
OSM file's center:



*  center_lat = (bounds.minlat + bounds.maxlat) / 2 => 52.3629  center_lon
= (bounds.minlon + bounds.maxlon) / 2 => 4.9797*
Then I plugged these lat/lon coordinates into a Python script (or use the
C++ Simulation::convertGeo() function is probably also possible):







*  import sumolib  net = sumolib.net.readNet('myfile.net.xml')  lon=4.9797
lat=52.3629  x,y = net.convertLonLat2XY(lon,lat)  print(f"lon {lon}, lat
{lat} => x={x}, y={y}")*
This gives the output:


*  lon 4.9797, lat 52.3629 => x=634798.9593672334, y=5803246.7227927195*
This effectively being the center/origin in XY coordinates of the
*original* OSM file (not the .net.xml conversion).
I then plug these numbers in as my 'netOffset' in 'myfile.net.xml':


*    <location netOffset="634798.9593672334,5803246.7227927195"
convBoundary="632716.63,5781956.68,637568.98,5805326.56"
origBoundary="4.949961,52.171210,5.020771,52.382096"
projParameter="+proj=utm +zone=31 +ellps=WGS84 +datum=WGS84 +units=m
+no_defs"/>*
And then I seem to have a perfect match when translating our vehicle
physics coordinates to SUMO (using MoveToXY() with that 'netOffset'), since
my code uses 'netOffset' as the preferred offset of my vehicle coordinates
to match up with SUMO.

Now, my question (finally) is: *can I extract the original OSM's lat/lon
center somehow from the converted .net.xml file?* I would like to get the
offset correctly just by having the .net.xml, without needing the original
.osm file as well. Right now I don't see how/if the original number is
stored in the generated .net.xml file.

Thanks,
Ruud van Gaal
_______________________________________________
sumo-user mailing list
[email protected]
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/sumo-user

Reply via email to