reviving some way of saving and using purely synthetic maps. creating a

few for the traffic signal tutorial.
This commit is contained in:
Dustin Carlino 2019-12-04 12:19:17 -08:00
parent a654f7ddc7
commit 3501aa6d72
11 changed files with 1265 additions and 15 deletions

6
.gitignore vendored
View File

@ -18,6 +18,6 @@ data/input/trips_2014.csv
data/player
data/system/maps/*
data/system/prebaked_results/*
data/system/scenarios/*
data/system/maps
data/system/prebaked_results
data/system/scenarios

View File

@ -62,6 +62,13 @@ pub fn path_all_scenarios(map_name: &str) -> String {
format!("../data/system/scenarios/{}", map_name)
}
pub fn path_synthetic_map(map_name: &str) -> String {
format!("../data/system/synthetic_maps/{}.json", map_name)
}
pub fn path_all_synthetic_maps() -> String {
format!("../data/system/synthetic_maps")
}
// Player data (Players edit this)
pub fn path_ab_test(map_name: &str, test_name: &str) -> String {

View File

@ -0,0 +1,252 @@
{
"name": "traffic sig lvl1",
"roads": [
[
{
"osm_way_id": -1575488510,
"i1": {
"osm_node_id": -1575488346
},
"i2": {
"osm_node_id": -1575488505
}
},
{
"center_points": [
{
"inner_x": 902.4499,
"inner_y": 252.6219
},
{
"inner_x": 849.3512,
"inner_y": 251.3116
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575488510",
"abst:synthetic": "true",
"abst:synthetic_lanes": "ds/ds",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575488508,
"i1": {
"osm_node_id": -1575488346
},
"i2": {
"osm_node_id": -1575488506
}
},
{
"center_points": [
{
"inner_x": 902.4499,
"inner_y": 252.6219
},
{
"inner_x": 957.3609,
"inner_y": 251.9472
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575488508",
"abst:synthetic": "true",
"abst:synthetic_lanes": "ds/ds",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575488494,
"i1": {
"osm_node_id": -1575488346
},
"i2": {
"osm_node_id": -1575488345
}
},
{
"center_points": [
{
"inner_x": 902.4499,
"inner_y": 252.6219
},
{
"inner_x": 891.6688,
"inner_y": 227.1299
},
{
"inner_x": 924.8175,
"inner_y": 216.2455
},
{
"inner_x": 912.8414,
"inner_y": 186.6817
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575488494",
"abst:synthetic": "true",
"abst:synthetic_lanes": "dds/dds",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575488492,
"i1": {
"osm_node_id": -1575488346
},
"i2": {
"osm_node_id": -1575488486
}
},
{
"center_points": [
{
"inner_x": 902.4499,
"inner_y": 252.6219
},
{
"inner_x": 902.2704,
"inner_y": 314.4305
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575488492",
"abst:synthetic": "true",
"abst:synthetic_lanes": "dds/dds",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
]
],
"intersections": [
[
{
"osm_node_id": -1575488506
},
{
"point": {
"inner_x": 957.3609,
"inner_y": 251.9472
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575488505
},
{
"point": {
"inner_x": 849.3512,
"inner_y": 251.3116
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575488486
},
{
"point": {
"inner_x": 902.2704,
"inner_y": 314.4305
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575488346
},
{
"point": {
"inner_x": 902.4499,
"inner_y": 252.6219
},
"intersection_type": "TrafficSignal"
}
],
[
{
"osm_node_id": -1575488345
},
{
"point": {
"inner_x": 912.8414,
"inner_y": 186.6817
},
"intersection_type": "Border"
}
]
],
"buildings": [],
"bus_routes": [],
"areas": [],
"boundary_polygon": {
"points": [
{
"inner_x": 849.3512,
"inner_y": 186.6817
},
{
"inner_x": 957.3609,
"inner_y": 186.6817
},
{
"inner_x": 957.3609,
"inner_y": 314.4305
},
{
"inner_x": 849.3512,
"inner_y": 314.4305
},
{
"inner_x": 849.3512,
"inner_y": 186.6817
}
],
"indices": [
0,
1,
2,
0,
2,
3,
0,
3,
4
],
"uv": null
},
"gps_bounds": {
"min_lon": 1.7976931348623157e308,
"min_lat": 1.7976931348623157e308,
"max_lon": -1.7976931348623157e308,
"max_lat": -1.7976931348623157e308
}
}

View File

@ -0,0 +1,379 @@
{
"name": "traffic sig lvl2",
"roads": [
[
{
"osm_way_id": -1575489671,
"i1": {
"osm_node_id": -1575489629
},
"i2": {
"osm_node_id": -1575488346
}
},
{
"center_points": [
{
"inner_x": 902.3478,
"inner_y": 253.2335
},
{
"inner_x": 902.4517,
"inner_y": 283.5584
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575489671",
"abst:synthetic": "true",
"abst:synthetic_lanes": "dds/dds",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575489666,
"i1": {
"osm_node_id": -1575489629
},
"i2": {
"osm_node_id": -1575489664
}
},
{
"center_points": [
{
"inner_x": 902.3478,
"inner_y": 253.2335
},
{
"inner_x": 953.6038,
"inner_y": 255.0553
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575489666",
"abst:synthetic": "true",
"abst:synthetic_lanes": "ds/ds",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575489661,
"i1": {
"osm_node_id": -1575489629
},
"i2": {
"osm_node_id": -1575489659
}
},
{
"center_points": [
{
"inner_x": 902.3478,
"inner_y": 253.2335
},
{
"inner_x": 848.305,
"inner_y": 251.3705
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575489661",
"abst:synthetic": "true",
"abst:synthetic_lanes": "ds/ds",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575489643,
"i1": {
"osm_node_id": -1575488345
},
"i2": {
"osm_node_id": -1575489629
}
},
{
"center_points": [
{
"inner_x": 903.4691,
"inner_y": 195.0853
},
{
"inner_x": 902.3478,
"inner_y": 253.2335
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575489643",
"abst:synthetic": "true",
"abst:synthetic_lanes": "dds/dds",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575488510,
"i1": {
"osm_node_id": -1575488346
},
"i2": {
"osm_node_id": -1575488505
}
},
{
"center_points": [
{
"inner_x": 902.4517,
"inner_y": 283.5584
},
{
"inner_x": 850.7293,
"inner_y": 279.8677
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575488510",
"abst:synthetic": "true",
"abst:synthetic_lanes": "ds/ds",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575488508,
"i1": {
"osm_node_id": -1575488346
},
"i2": {
"osm_node_id": -1575488506
}
},
{
"center_points": [
{
"inner_x": 902.4517,
"inner_y": 283.5584
},
{
"inner_x": 956.6143,
"inner_y": 280.877
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575488508",
"abst:synthetic": "true",
"abst:synthetic_lanes": "ds/ds",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575488492,
"i1": {
"osm_node_id": -1575488346
},
"i2": {
"osm_node_id": -1575488486
}
},
{
"center_points": [
{
"inner_x": 902.4517,
"inner_y": 283.5584
},
{
"inner_x": 902.2704,
"inner_y": 314.4305
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575488492",
"abst:synthetic": "true",
"abst:synthetic_lanes": "dds/dds",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
]
],
"intersections": [
[
{
"osm_node_id": -1575489664
},
{
"point": {
"inner_x": 953.6038,
"inner_y": 255.0553
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575489659
},
{
"point": {
"inner_x": 848.305,
"inner_y": 251.3705
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575489629
},
{
"point": {
"inner_x": 902.3478,
"inner_y": 253.2335
},
"intersection_type": "TrafficSignal"
}
],
[
{
"osm_node_id": -1575488506
},
{
"point": {
"inner_x": 956.6143,
"inner_y": 280.877
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575488505
},
{
"point": {
"inner_x": 850.7293,
"inner_y": 279.8677
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575488486
},
{
"point": {
"inner_x": 902.2704,
"inner_y": 314.4305
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575488346
},
{
"point": {
"inner_x": 902.4517,
"inner_y": 283.5584
},
"intersection_type": "TrafficSignal"
}
],
[
{
"osm_node_id": -1575488345
},
{
"point": {
"inner_x": 903.4691,
"inner_y": 195.0853
},
"intersection_type": "Border"
}
]
],
"buildings": [],
"bus_routes": [],
"areas": [],
"boundary_polygon": {
"points": [
{
"inner_x": 848.305,
"inner_y": 195.0853
},
{
"inner_x": 956.6143,
"inner_y": 195.0853
},
{
"inner_x": 956.6143,
"inner_y": 314.4305
},
{
"inner_x": 848.305,
"inner_y": 314.4305
},
{
"inner_x": 848.305,
"inner_y": 195.0853
}
],
"indices": [
0,
1,
2,
0,
2,
3,
0,
3,
4
],
"uv": null
},
"gps_bounds": {
"min_lon": 1.7976931348623157e308,
"min_lat": 1.7976931348623157e308,
"max_lon": -1.7976931348623157e308,
"max_lat": -1.7976931348623157e308
}
}

View File

@ -0,0 +1,586 @@
{
"name": "traffic sig lvl3",
"roads": [
[
{
"osm_way_id": -1575490374,
"i1": {
"osm_node_id": -1575490289
},
"i2": {
"osm_node_id": -1575490287
}
},
{
"center_points": [
{
"inner_x": 1080.142,
"inner_y": 440.4727
},
{
"inner_x": 1120.6836,
"inner_y": 441.1477
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575490374",
"abst:synthetic": "true",
"abst:synthetic_lanes": "d/",
"highway": "primary",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575490372,
"i1": {
"osm_node_id": -1575490292
},
"i2": {
"osm_node_id": -1575490289
}
},
{
"center_points": [
{
"inner_x": 1033.9668,
"inner_y": 468.1448
},
{
"inner_x": 1080.142,
"inner_y": 440.4727
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575490372",
"abst:synthetic": "true",
"abst:synthetic_lanes": "d/",
"highway": "primary",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575490370,
"i1": {
"osm_node_id": -1575490291
},
"i2": {
"osm_node_id": -1575490289
}
},
{
"center_points": [
{
"inner_x": 1025.2485,
"inner_y": 438.7533
},
{
"inner_x": 1080.142,
"inner_y": 440.4727
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575490370",
"abst:synthetic": "true",
"abst:synthetic_lanes": "d/",
"highway": "primary",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575490369,
"i1": {
"osm_node_id": -1575490290
},
"i2": {
"osm_node_id": -1575490289
}
},
{
"center_points": [
{
"inner_x": 1026.1936,
"inner_y": 412.1254
},
{
"inner_x": 1080.142,
"inner_y": 440.4727
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575490369",
"abst:synthetic": "true",
"abst:synthetic_lanes": "d/",
"highway": "primary",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575490366,
"i1": {
"osm_node_id": -1575490304
},
"i2": {
"osm_node_id": -1575490292
}
},
{
"center_points": [
{
"inner_x": 967.3292,
"inner_y": 478.0642
},
{
"inner_x": 1033.9668,
"inner_y": 468.1448
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575490366",
"abst:synthetic": "true",
"abst:synthetic_lanes": "d/",
"highway": "primary",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575490365,
"i1": {
"osm_node_id": -1575490303
},
"i2": {
"osm_node_id": -1575490292
}
},
{
"center_points": [
{
"inner_x": 966.6139,
"inner_y": 464.2034
},
{
"inner_x": 1002.0513,
"inner_y": 459.651
},
{
"inner_x": 1033.9668,
"inner_y": 468.1448
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575490365",
"abst:synthetic": "true",
"abst:synthetic_lanes": "d/",
"highway": "primary",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575490359,
"i1": {
"osm_node_id": -1575490302
},
"i2": {
"osm_node_id": -1575490291
}
},
{
"center_points": [
{
"inner_x": 963.5002,
"inner_y": 451.019
},
{
"inner_x": 1003.6103,
"inner_y": 451.9281
},
{
"inner_x": 1025.2485,
"inner_y": 438.7533
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575490359",
"abst:synthetic": "true",
"abst:synthetic_lanes": "d/",
"highway": "primary",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575490356,
"i1": {
"osm_node_id": -1575490301
},
"i2": {
"osm_node_id": -1575490291
}
},
{
"center_points": [
{
"inner_x": 963.6375,
"inner_y": 439.8051
},
{
"inner_x": 1025.2485,
"inner_y": 438.7533
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575490356",
"abst:synthetic": "true",
"abst:synthetic_lanes": "d/",
"highway": "primary",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575490353,
"i1": {
"osm_node_id": -1575490300
},
"i2": {
"osm_node_id": -1575490291
}
},
{
"center_points": [
{
"inner_x": 964.3737,
"inner_y": 427.5211
},
{
"inner_x": 996.0839,
"inner_y": 422.8544
},
{
"inner_x": 1025.2485,
"inner_y": 438.7533
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575490353",
"abst:synthetic": "true",
"abst:synthetic_lanes": "d/",
"highway": "primary",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575490351,
"i1": {
"osm_node_id": -1575490298
},
"i2": {
"osm_node_id": -1575490290
}
},
{
"center_points": [
{
"inner_x": 963.5002,
"inner_y": 408.0905
},
{
"inner_x": 1026.1936,
"inner_y": 412.1254
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575490351",
"abst:synthetic": "true",
"abst:synthetic_lanes": "d/",
"highway": "primary",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
],
[
{
"osm_way_id": -1575490348,
"i1": {
"osm_node_id": -1575490295
},
"i2": {
"osm_node_id": -1575490290
}
},
{
"center_points": [
{
"inner_x": 963.3445,
"inner_y": 395.4267
},
{
"inner_x": 1008.3192,
"inner_y": 400.0956
},
{
"inner_x": 1026.1936,
"inner_y": 412.1254
}
],
"osm_tags": {
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "-1575490348",
"abst:synthetic": "true",
"abst:synthetic_lanes": "d/",
"highway": "primary",
"maxspeed": "25 mph",
"name": "Streety McStreetFace"
},
"turn_restrictions": []
}
]
],
"intersections": [
[
{
"osm_node_id": -1575490304
},
{
"point": {
"inner_x": 967.3292,
"inner_y": 478.0642
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575490303
},
{
"point": {
"inner_x": 966.6139,
"inner_y": 464.2034
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575490302
},
{
"point": {
"inner_x": 963.5002,
"inner_y": 451.019
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575490301
},
{
"point": {
"inner_x": 963.6375,
"inner_y": 439.8051
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575490300
},
{
"point": {
"inner_x": 964.3737,
"inner_y": 427.5211
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575490298
},
{
"point": {
"inner_x": 963.5002,
"inner_y": 408.0905
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575490295
},
{
"point": {
"inner_x": 963.3445,
"inner_y": 395.4267
},
"intersection_type": "Border"
}
],
[
{
"osm_node_id": -1575490292
},
{
"point": {
"inner_x": 1033.9668,
"inner_y": 468.1448
},
"intersection_type": "TrafficSignal"
}
],
[
{
"osm_node_id": -1575490291
},
{
"point": {
"inner_x": 1025.2485,
"inner_y": 438.7533
},
"intersection_type": "TrafficSignal"
}
],
[
{
"osm_node_id": -1575490290
},
{
"point": {
"inner_x": 1026.1936,
"inner_y": 412.1254
},
"intersection_type": "TrafficSignal"
}
],
[
{
"osm_node_id": -1575490289
},
{
"point": {
"inner_x": 1080.142,
"inner_y": 440.4727
},
"intersection_type": "TrafficSignal"
}
],
[
{
"osm_node_id": -1575490287
},
{
"point": {
"inner_x": 1120.6836,
"inner_y": 441.1477
},
"intersection_type": "Border"
}
]
],
"buildings": [],
"bus_routes": [],
"areas": [],
"boundary_polygon": {
"points": [
{
"inner_x": 963.3445,
"inner_y": 395.4267
},
{
"inner_x": 1120.6836,
"inner_y": 395.4267
},
{
"inner_x": 1120.6836,
"inner_y": 478.0642
},
{
"inner_x": 963.3445,
"inner_y": 478.0642
},
{
"inner_x": 963.3445,
"inner_y": 395.4267
}
],
"indices": [
0,
1,
2,
0,
2,
3,
0,
3,
4
],
"uv": null
},
"gps_bounds": {
"min_lon": 1.7976931348623157e308,
"min_lat": 1.7976931348623157e308,
"max_lon": -1.7976931348623157e308,
"max_lat": -1.7976931348623157e308
}
}

View File

@ -85,7 +85,7 @@ impl UI {
"Map Editor",
vec![
(hotkey(Key::Escape), "quit"),
(hotkey(Key::S), "save raw map"),
(None, "save raw map"),
(hotkey(Key::F), "save map fixes"),
(hotkey(Key::J), "warp to something"),
(None, "produce OSM parking+sidewalk diff"),
@ -273,6 +273,7 @@ impl GUI for UI {
self.before_quit(ctx.canvas);
std::process::exit(0);
} else if self.menu.action("save raw map") {
// TODO Only do this for synthetic maps
if self.model.map.name != "" {
self.model.export();
} else {

View File

@ -42,13 +42,19 @@ impl Model {
path: String,
include_bldgs: bool,
intersection_geom: bool,
no_fixes: bool,
mut no_fixes: bool,
prerender: &Prerender,
) -> Model {
let mut timer = Timer::new("import map");
let mut model = Model::blank();
model.include_bldgs = include_bldgs;
model.map = abstutil::read_binary(path, &mut timer);
if path.starts_with(&abstutil::path_all_raw_maps()) {
model.map = abstutil::read_binary(path, &mut timer);
} else {
// Synthetic map!
model.map = abstutil::read_json(path, &mut timer);
no_fixes = true;
}
model.intersection_geom = intersection_geom;
if !no_fixes {
@ -83,14 +89,10 @@ impl Model {
impl Model {
// TODO Only for truly synthetic maps...
pub fn export(&mut self) {
println!("TODO: disabled for now");
/*assert!(self.map.name != "");
// TODO Or maybe we should do this more regularly?
assert!(self.map.name != "");
self.map.boundary_polygon = self.compute_bounds().get_rectangle();
let path = abstutil::path_raw_map(&self.map.name);
abstutil::write_binary(&path, &self.map);
println!("Exported {}", path);*/
abstutil::write_json(abstutil::path_synthetic_map(&self.map.name), &self.map);
}
pub fn save_fixes(&mut self) {

View File

@ -16,6 +16,9 @@ pub fn find_scc(map: &Map, constraints: PathConstraints) -> (HashSet<LaneID>, Ha
}
}
let components = petgraph::algo::kosaraju_scc(&graph);
if components.is_empty() {
return (HashSet::new(), HashSet::new());
}
let largest_group: HashSet<LaneID> = components
.into_iter()
.max_by_key(|c| c.len())

View File

@ -48,8 +48,14 @@ pub struct Map {
}
impl Map {
pub fn new(path: String, use_map_fixes: bool, timer: &mut Timer) -> Map {
let mut raw: RawMap = abstutil::read_binary(path, timer);
pub fn new(path: String, mut use_map_fixes: bool, timer: &mut Timer) -> Map {
let mut raw: RawMap = if path.starts_with(&abstutil::path_all_raw_maps()) {
abstutil::read_binary(path, timer)
} else {
// Synthetic
use_map_fixes = false;
abstutil::read_json(path, timer)
};
if use_map_fixes {
raw.apply_all_fixes(timer);
}

View File

@ -10,8 +10,20 @@ use std::fmt;
#[derive(Debug, Serialize, Deserialize)]
pub struct RawMap {
pub name: String,
#[serde(
serialize_with = "serialize_btreemap",
deserialize_with = "deserialize_btreemap"
)]
pub roads: BTreeMap<OriginalRoad, RawRoad>,
#[serde(
serialize_with = "serialize_btreemap",
deserialize_with = "deserialize_btreemap"
)]
pub intersections: BTreeMap<OriginalIntersection, RawIntersection>,
#[serde(
serialize_with = "serialize_btreemap",
deserialize_with = "deserialize_btreemap"
)]
pub buildings: BTreeMap<OriginalBuilding, RawBuilding>,
pub bus_routes: Vec<Route>,
pub areas: Vec<RawArea>,

View File

@ -92,7 +92,9 @@ impl SimFlags {
scenario.instantiate(&mut sim, &map, &mut rng, timer);
(map, sim, rng)
} else if self.load.starts_with(&abstutil::path_all_raw_maps()) {
} else if self.load.starts_with(&abstutil::path_all_raw_maps())
|| self.load.starts_with(&abstutil::path_all_synthetic_maps())
{
timer.note(format!("Loading map {}", self.load));
let map = Map::new(self.load.clone(), self.use_map_fixes, timer);