when converting lon, lat to network coordinates, leave out the rawUTM=True. moveToXY requires the shifted positions rather than raw UTM.
x2, y2 = net.convertLonLat2XY(lon, lat) Am Di., 9. Okt. 2018 um 08:03 Uhr schrieb Gama Lins de Araujo, Thais < [email protected]>: > Hello Mr Jakob, > > > I am sorry to bother again, but I replaced the line of code I had with the > one you provided, and the simulation looks just the same. The vehicle > drives by the side of the road the whole time, and it also seems not to > have the right angle. This is how my code looks like now: > > > x,y = df_dropped_1st_veh_instance['Local_X'].iloc[k], > df_dropped_1st_veh_instance['Local_Y'].iloc[k] > lon, lat = net.convertXY2LonLat(x * 0.3048, y * 0.3048, True) > x2, y2 = net.convertLonLat2XY(lon, lat, rawUTM=True) > > traci.vehicle.moveToXY(traci_veh, '', 0, x2, y2, angle, 2) > > for the angle I used INVALID_DOUBLE_VALUE and transformed it to radians. > > Here is a sample of the data I have: > > Local_X Local_Y Global_X Global_Y > 0 16.467 35.381 6451137.641 1873344.962 > 1 16.447 39.381 6451140.329 1873342.000 > 2 16.426 43.381 6451143.018 1873339.038 > 3 16.405 47.380 6451145.706 1873336.077 > 4 16.385 51.381 6451148.395 1873333.115 > 5 16.364 55.381 6451151.084 1873330.153 > 6 16.344 59.381 6451153.772 1873327.192 > 7 16.323 63.379 6451156.461 1873324.230 > > Thank you in advance, > > Thais Gama > > > > > > > > ------------------------------ > *Von:* Jakob Erdmann <[email protected]> > *Gesendet:* Montag, 8. Oktober 2018 12:51 > *An:* Gama Lins de Araujo, Thais; Sumo project User discussions > *Cc:* sumo-user > *Betreff:* Re: [sumo-user] use State Plain Coordinates to move vehicle > (MoveToXY) > > Hello, > the position conversion functions provided by traci and libsumo only > support the projection embedded in the .net.xml file. In case of an OSM > import this means it will always transform between meters and WGS84 lon,lat. > > Since NAD83 and WGS84 are within 1m of each other, you could use > net.convertXY2LonLat(x_feet * 0,3048, y_feet * 0,3048, True) > (The third argument is for using raw UTM values instead adding the network > offset) > > regards, > Jakob > > Am Mo., 8. Okt. 2018 um 12:24 Uhr schrieb Gama Lins de Araujo, Thais via > sumo-user <[email protected]>: > >> Hello Mr. Behrisch<https://sourceforge.net/u/behrisch/> / Erdmann< >> https://sourceforge.net/u/namdre/>, >> >> >> I would like to know if there is a way in SUMO that I can directly use CA >> State Plane NAD83 coordinate in feet to move vehicles in a network with the >> moveToXY command, or do I need to do any transformations before hand? >> >> >> When I use this piece of code (I got from >> http://sumo.dlr.de/wiki/Tools/Sumolib#coordinate_transformations) I seem >> to get reasonable results for latitude and longitude, but the x and y >> resulting from conversion are not matching the network. When I run this >> code: >> >> >> x,y = df_dropped_1st_veh_instance['Local_X'].iloc[k], >> df_dropped_1st_veh_instance['Local_Y'].iloc[k] >> #x, y = traci.vehicle.getPosition(traci_veh) >> lon, lat = traci.simulation.convertGeo(x, y) >> x2, y2 = traci.simulation.convertGeo(lon, lat, fromGeo=True) >> #x, y = net.convertLonLatXY(lon, lat) >> print 'x=%4.6f y=%4.6f' % (x2, y2) >> >> the vehicle drives off the road network the whole time. In this case I am >> using the local coordinates (Local_X and Local_Y) which are described as: >> "Lateral (X) coordinate of the front center of the vehicle with respect to >> the left-most edge of the section in the direction of travel". When I use >> the Global coordinates (Global_X and Global_Y) my vehicle will just stand >> outside the network for the whole time, and those are the actual geo >> coordinates, described as such: "CA State Plane NAD83 coordinate". >> >> i know my network is in datum=WGS84, by the information given in the >> network xml file, and that it is shifted by the netOffset parameter. >> >> I wonder if that might be the problem? >> >> <location netOffset="-561583.51,-4188054.44" >> convBoundary="205.71,83.75,327.03,729.01" >> origBoundary="-122.300034,37.837827,-122.295689,37.846489" >> projParameter="+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m >> +no_defs"/> >> >> >> PS.: i need high accuracy and precision, the vehicles should move exactly >> according to my coordinates, provided in the data I have. The data is very >> big (more than 1Gb), so I am sending only a subset of it, which refers to >> one car only. And also my code and files to run the simulation, in case >> those are needed. >> >> >> Thank you in advance for your help, >> >> >> Thais >> _______________________________________________ >> sumo-user mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/sumo-user >> _______________________________________________ >> sumo-user mailing list >> [email protected] >> To change your delivery options, retrieve your password, or unsubscribe >> from this list, visit >> https://dev.eclipse.org/mailman/listinfo/sumo-user >> > _______________________________________________ sumo-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sumo-user
