Conversation
|
testcase added |
tools/converter/osm2cityflow.py
Outdated
| if str(wayID + '_' + str(pos) + '_' + str(endPos)) not in road_dic: | ||
| build_road(wayID, maxSpeed, oneDirectionLanes, points, | ||
| wayID + '_' + str(pos) + '_' + str(endPos), nodeID, endID) | ||
| if road_dic[str(wayID + '_' + str(pos) + '_' + str(endPos))]["endIntersection"] == crossID: | ||
| in_roadIDs.append(wayID + '_' + str(pos) + '_' + str(endPos)) | ||
| else: | ||
| out_roadIDs.append(wayID + '_' + str(pos) + '_' + str(endPos)) | ||
| if otherDirectionLanes > 0: | ||
| if str(wayID + '_' + str(endPos) + '_' + str(pos)) not in road_dic: | ||
| build_road(wayID, maxSpeed, otherDirectionLanes, otherPoints, | ||
| wayID + '_' + str(endPos) + '_' + str(pos), endID, nodeID) | ||
| if road_dic[str(wayID + '_' + str(endPos) + '_' + str(pos))]["endIntersection"] == crossID: | ||
| in_roadIDs.append(wayID + '_' + str(endPos) + '_' + str(pos)) | ||
| else: | ||
| out_roadIDs.append(wayID + '_' + str(endPos) + '_' + str(pos)) | ||
| return in_roadIDs, out_roadIDs |
There was a problem hiding this comment.
please make wayID + '_' + str(endPos) + '_' + str(pos) a function
tools/converter/osm2cityflow.py
Outdated
| if tag.getAttribute('k') == 'lanes': | ||
| numLanes = int(tag.getAttribute('v')) | ||
| if tag.getAttribute('k') == 'lanes:forward': | ||
| oneDirectionLanes = int(tag.getAttribute('v')) | ||
| if tag.getAttribute('k') == 'lanes:backward': | ||
| otherDirectionLanes = int(tag.getAttribute('v')) | ||
| if tag.getAttribute('k') == 'oneway' and tag.getAttribute('v') == 'yes': | ||
| oneway = True | ||
| if tag.getAttribute('k') == 'maxspeed': | ||
| maxSpeed = float(tag.getAttribute('v')[0:-3]) * 1.609344 |
There was a problem hiding this comment.
why getAttribute('k') so many times?
There was a problem hiding this comment.
there is a list of tags in one road, their order is not fixed.
| intersection = { | ||
| "id": nodeID, | ||
| "point": {"x": x, "y": y}, | ||
| "width": 5, |
There was a problem hiding this comment.
So the width of an intersection is a constant?
| python osm2cityflow.py --osmFile statecollege.osm --CityFlowNet statecollege_roadnet.json | ||
| ``` | ||
| *Example osm roadnet, CityFlow roadnet and simple flow files can be downloaded [here](https://github.com/cityflow-project/data/tree/master/tools/Converter/examples)* | ||
|
|
There was a problem hiding this comment.
Is there any new dependencies?
There was a problem hiding this comment.
I think there isn't.
There was a problem hiding this comment.
Does the script depend on pyproj and folium?
There was a problem hiding this comment.
pyproj is used to convert latitude and longitude to x-y two-dimensional coordinates.
folium is used to draw two graphs with osm map as background, which show the roads and intersections that will be kept in CityFlow road net.
| cxx_standard: '14' | ||
| target: 'all test' | ||
| - script: cp build/cityflow* . && python3.7 -m unittest discover tests/python/ | ||
| - script: python3.7 -m pip install pyproj folium && cp build/cityflow* . && git clone https://github.com/cityflow-project/data.git && python3.7 -m unittest discover tests/python/ |
There was a problem hiding this comment.
Can we split these commands into serval scripts?
add osm2cityflow
current problems: 1. osm doesn't provide the width of lanes or intersections, so I just set a default value.
2. Only use highway.primary road.
3. Since osm road net will always cut one road into many segments, when there are serval short segments near intersections, vehicles may be unable to stop before stop line and rush across the intersection.