Trip Convert¶
To facilitate user migration from SUMO, we designed to convert trips from SUMO to MOSS Protobuf Trip format. To perform this conversion, you need perform a map convert with Map Converter first.
Load SUMO map file and Convert the map¶
from mosstool.map.sumo.map import MapConverter
from mosstool.trip.sumo.route import RouteConverter
from mosstool.type import Map, Persons
from mosstool.util.format_converter import dict2pb
s2m = MapConverter(
net_path="data/sumo/shenzhen.net.xml",
)
m = s2m.convert_map()
id2uid = s2m.get_sumo_id_mappings()
map_pb = dict2pb(m, Map())
s2r = RouteConverter(
converted_map=map_pb,
sumo_id_mappings=id2uid,
route_path="./data/sumo/trips.xml",
)
r = s2r.convert_route()
pb = dict2pb(r, Persons())
with open("data/temp/sumo_persons.pb", "wb") as f:
f.write(pb.SerializeToString())
route_pathis the path of SUMO trip filexmlfile. Either incomplete trips (trips and flows) or complete trips (routes) conversion are supported.