convert the rest of usize IDs to u32. savings:

maps: 645mb -> 625mb
scenarios: 431mb -> 390mb (before all the u32 optimizations, this as
500mb!!!)
prebaked: 80mb -> 73mb

and while I'm at it, grab fresh OSM, with lots of manual lane fixes,
especially near divided highways
This commit is contained in:
Dustin Carlino 2020-07-09 11:43:34 -07:00
parent 4cb35c6e3b
commit 4340ad585b
21 changed files with 200 additions and 112 deletions

View File

@ -8,6 +8,7 @@ use serde_json;
use std;
use std::cmp::Ord;
use std::collections::{BTreeMap, BTreeSet};
use std::convert::TryFrom;
use std::fs::File;
use std::io::{stdout, BufReader, BufWriter, Error, ErrorKind, Read, Write};
use std::path::Path;
@ -207,6 +208,19 @@ pub fn deserialize_multimap<
Ok(map)
}
pub fn serialize_usize<S: Serializer>(x: &usize, s: S) -> Result<S::Ok, S::Error> {
if let Ok(x) = u32::try_from(*x) {
x.serialize(s)
} else {
Err(serde::ser::Error::custom(format!("{} can't fit in u32", x)))
}
}
pub fn deserialize_usize<'de, D: Deserializer<'de>>(d: D) -> Result<usize, D::Error> {
let x = <u32>::deserialize(d)?;
Ok(x as usize)
}
// Just list all things from a directory, return sorted by name, with file extension removed.
#[cfg(not(target_arch = "wasm32"))]
pub fn list_all_objects(dir: String) -> Vec<String> {

View File

@ -13,10 +13,11 @@ pub use crate::collections::{
VecMap,
};
pub use crate::io::{
basename, deserialize_btreemap, deserialize_multimap, file_exists, find_next_file,
find_prev_file, list_all_objects, list_dir, load_all_objects, maybe_read_binary,
maybe_read_json, read_binary, read_json, serialize_btreemap, serialize_multimap,
serialized_size_bytes, slurp_file, to_json, write_binary, write_json, FileWithProgress,
basename, deserialize_btreemap, deserialize_multimap, deserialize_usize, file_exists,
find_next_file, find_prev_file, list_all_objects, list_dir, load_all_objects,
maybe_read_binary, maybe_read_json, read_binary, read_json, serialize_btreemap,
serialize_multimap, serialize_usize, serialized_size_bytes, slurp_file, to_json, write_binary,
write_json, FileWithProgress,
};
pub use crate::logs::Warn;
pub use crate::random::{fork_rng, WeightedUsizeChoice};

View File

@ -1,59 +1,59 @@
data/input/austin/osm/Austin.osm,7c8d72cf97072af34cee665006b1e9e6,https://www.dropbox.com/s/8bedio4fpt6yvhg/Austin.osm.zip?dl=0
data/input/austin/osm/downtown_atx.osm,a30b0f460a481598e494f16a9d07a822,https://www.dropbox.com/s/tbadw3f0ex2zzx7/downtown_atx.osm.zip?dl=0
data/input/austin/osm/huge_austin.osm,fb166029fc8006bd20dc959fbbbde3b6,https://www.dropbox.com/s/4x421o9o8px0m6o/huge_austin.osm.zip?dl=0
data/input/raw_maps/ballard.bin,e0b3a3806f0a77684eac3b22054ff2a0,https://www.dropbox.com/s/lr5lkzhtuv0dtr1/ballard.bin.zip?dl=0
data/input/raw_maps/downtown.bin,65e6ac20356d7e8fb8a7467a4e8fd62b,https://www.dropbox.com/s/svhp4gg6cuo8rnf/downtown.bin.zip?dl=0
data/input/raw_maps/ballard.bin,eeb376efa9a87e3a7f8cea5a0a1795c2,https://www.dropbox.com/s/49eq6ctt3vko300/ballard.bin.zip?dl=0
data/input/raw_maps/downtown.bin,4560307f46e64e2b4495494a4406e458,https://www.dropbox.com/s/20zw8valbf35tci/downtown.bin.zip?dl=0
data/input/raw_maps/downtown_atx.bin,cf2cd0fea92b70e5555ac693b2d4a653,https://www.dropbox.com/s/02moxvh1gn41x5s/downtown_atx.bin.zip?dl=0
data/input/raw_maps/huge_austin.bin,d37364ac2da4e9d44de886457ba915ed,https://www.dropbox.com/s/updgay4ia9dsbot/huge_austin.bin.zip?dl=0
data/input/raw_maps/huge_seattle.bin,489c21596454ffa7268627a00667c2a2,https://www.dropbox.com/s/hnw54375v9i8rvj/huge_seattle.bin.zip?dl=0
data/input/raw_maps/huge_seattle.bin,5c06f78dd172f5717895283ac1ea0f65,https://www.dropbox.com/s/mst2n74jqjknyv5/huge_seattle.bin.zip?dl=0
data/input/raw_maps/lakeslice.bin,f3b6e1820abf31f77d30a8cce3963f0d,https://www.dropbox.com/s/6jz3aisto2rhsjj/lakeslice.bin.zip?dl=0
data/input/raw_maps/montlake.bin,749507726d6acc94fbde892bf78bd137,https://www.dropbox.com/s/q7w9lwitdrv3ln2/montlake.bin.zip?dl=0
data/input/raw_maps/south_seattle.bin,4dba5a22610c3ce88fc45b705a682e19,https://www.dropbox.com/s/xa6bmlxa7a25l2k/south_seattle.bin.zip?dl=0
data/input/raw_maps/udistrict.bin,d0dee6bcc4d48865679e940259068b6a,https://www.dropbox.com/s/pordmxw0adnujec/udistrict.bin.zip?dl=0
data/input/raw_maps/west_seattle.bin,1a7f2dc27fe28a5af452daf16086351c,https://www.dropbox.com/s/cunj31v1z0ju4k8/west_seattle.bin.zip?dl=0
data/input/screenshots/downtown.zip,e835ef91deec6a71a17c7b88c2d9d5f7,https://www.dropbox.com/s/qawd35wz62m2acl/downtown.zip.zip?dl=0
data/input/screenshots/lakeslice.zip,2810415bf055b337d418b63fed730b5f,https://www.dropbox.com/s/z0z96lsn7bunqfy/lakeslice.zip.zip?dl=0
data/input/screenshots/montlake.zip,d4a1f87cc6510ebedaa05601b4510eb2,https://www.dropbox.com/s/r9vkgwesqklfuq2/montlake.zip.zip?dl=0
data/input/screenshots/udistrict.zip,0a548e80ba5e453f208bd96505f72f26,https://www.dropbox.com/s/ecnt1tyza48y9o2/udistrict.zip.zip?dl=0
data/input/raw_maps/south_seattle.bin,0ebdda0feb14d520741e7907e9fa4286,https://www.dropbox.com/s/1lsmaiz97gqh02j/south_seattle.bin.zip?dl=0
data/input/raw_maps/udistrict.bin,cbbded9a3045cf4e6a0b10768bc99cde,https://www.dropbox.com/s/4deintbkbocl3v9/udistrict.bin.zip?dl=0
data/input/raw_maps/west_seattle.bin,8472bc3288ea510cad0278b035e5a744,https://www.dropbox.com/s/1p4ui7pbdpq9la0/west_seattle.bin.zip?dl=0
data/input/screenshots/downtown.zip,3e6d333e96cfd7e3cdb90442cdf125ca,https://www.dropbox.com/s/qawd35wz62m2acl/downtown.zip.zip?dl=0
data/input/screenshots/lakeslice.zip,bf5ee0dc54f01aaf8688b3728e706c82,https://www.dropbox.com/s/z0z96lsn7bunqfy/lakeslice.zip.zip?dl=0
data/input/screenshots/montlake.zip,b0e6a179354bfe8182acbc449b606fe8,https://www.dropbox.com/s/r9vkgwesqklfuq2/montlake.zip.zip?dl=0
data/input/screenshots/udistrict.zip,f173a85434221477ee4731d3b5a258b1,https://www.dropbox.com/s/ecnt1tyza48y9o2/udistrict.zip.zip?dl=0
data/input/seattle/N47W122.hgt,0db4e23e51f7680538b0bbbc72208e07,https://www.dropbox.com/s/mmb4mgutwotijdw/N47W122.hgt.zip?dl=0
data/input/seattle/blockface.bin,add872bab9040ae911366328a230f8b5,https://www.dropbox.com/s/rxd2care60tbe75/blockface.bin.zip?dl=0
data/input/seattle/blockface.kml,350bd9e59bf2af4e885a7c0741e6ee6b,https://www.dropbox.com/s/ukknmpjdvilncq9/blockface.kml.zip?dl=0
data/input/seattle/offstreet_parking.bin,a33c05e8962dfe10a7a14b9eb6413803,https://www.dropbox.com/s/7j2gwb18685kd5u/offstreet_parking.bin.zip?dl=0
data/input/seattle/offstreet_parking.kml,e24d1c308ca739df73621846c7b7847c,https://www.dropbox.com/s/dkkkpywob7cdo57/offstreet_parking.kml.zip?dl=0
data/input/seattle/osm/ballard.osm,1cee901222e63f7c443a725f2c5c7924,https://www.dropbox.com/s/po5kj11b312fpvt/ballard.osm.zip?dl=0
data/input/seattle/osm/downtown.osm,7a50e6c097066f919a3447d8279c11b9,https://www.dropbox.com/s/dygnjgxtlixtbrd/downtown.osm.zip?dl=0
data/input/seattle/osm/huge_seattle.osm,fafb6538f972de20b7b1034ae522d62f,https://www.dropbox.com/s/15s8kiebuhw7eq9/huge_seattle.osm.zip?dl=0
data/input/seattle/osm/lakeslice.osm,8ade9db43c3833dd8fa458bc9790c676,https://www.dropbox.com/s/w5twkidrvrqiaas/lakeslice.osm.zip?dl=0
data/input/seattle/osm/montlake.osm,6eaf29328a5c75bfb625719bc1c3f837,https://www.dropbox.com/s/4krhpryh8ekjkfv/montlake.osm.zip?dl=0
data/input/seattle/osm/south_seattle.osm,a415c8d714d0f4934c2f8c79ca6d5a2d,https://www.dropbox.com/s/r2xvzc1xyo5t40b/south_seattle.osm.zip?dl=0
data/input/seattle/osm/udistrict.osm,dd3b931047f54b1a14f2efdb6f9420e0,https://www.dropbox.com/s/0e4ig7ln7y0vodw/udistrict.osm.zip?dl=0
data/input/seattle/osm/washington-latest.osm.pbf,ef33a41125145695082088e34f57ae7d,https://www.dropbox.com/s/ty2ursd4szd67uu/washington-latest.osm.pbf.zip?dl=0
data/input/seattle/osm/west_seattle.osm,a28b390b3a8612fb993799c57917fba3,https://www.dropbox.com/s/8l2q3e28narajfw/west_seattle.osm.zip?dl=0
data/input/seattle/parcels.bin,dff366a1150e01cc058bc85fe13786df,https://www.dropbox.com/s/gno2o3r4emtwmrk/parcels.bin.zip?dl=0
data/input/seattle/osm/ballard.osm,bfa8d63ee45fdf789837c9316c366f77,https://www.dropbox.com/s/8w0lzb6juueewsn/ballard.osm.zip?dl=0
data/input/seattle/osm/downtown.osm,090a9c70cb96f6f6ef6b7457b87ea424,https://www.dropbox.com/s/r68k8mq1c1t9c3x/downtown.osm.zip?dl=0
data/input/seattle/osm/huge_seattle.osm,c0f27a520b55b5d7bf3d69672825e163,https://www.dropbox.com/s/yul97r216jpjzja/huge_seattle.osm.zip?dl=0
data/input/seattle/osm/lakeslice.osm,6f9b495b1833a027fedbd94f21c9a3cd,https://www.dropbox.com/s/nmzifqc54cliljm/lakeslice.osm.zip?dl=0
data/input/seattle/osm/montlake.osm,4450f67d899df4b73132baee693b5b18,https://www.dropbox.com/s/363w15v82bqe3o3/montlake.osm.zip?dl=0
data/input/seattle/osm/south_seattle.osm,fbda605b8a4f580e426790fbb6e6dd15,https://www.dropbox.com/s/7sdgvnpoe983gju/south_seattle.osm.zip?dl=0
data/input/seattle/osm/udistrict.osm,7510484ec8abddbe64a2dc761a94fb67,https://www.dropbox.com/s/wraohtnpydpfe1p/udistrict.osm.zip?dl=0
data/input/seattle/osm/washington-latest.osm.pbf,e06cc7eec144eac6a495d93db6d85766,https://www.dropbox.com/s/fhgqauc5obh05cd/washington-latest.osm.pbf.zip?dl=0
data/input/seattle/osm/west_seattle.osm,ce708f4701cd9118c2e9de0573e69457,https://www.dropbox.com/s/1bsbebu9va987qx/west_seattle.osm.zip?dl=0
data/input/seattle/parcels.bin,5fd9e42c47827328a067a43b83686a1a,https://www.dropbox.com/s/4lql4s0fo3n5smf/parcels.bin.zip?dl=0
data/input/seattle/parcels_urbansim.txt,db63d7d606e8702d12f9399e87e6a00f,https://www.dropbox.com/s/6g8rbsf200dssj3/parcels_urbansim.txt.zip?dl=0
data/input/seattle/popdat.bin,7b49f07a1e9c34c68fa390d03f1cff2f,https://www.dropbox.com/s/r1riqn6kqsh7p5q/popdat.bin.zip?dl=0
data/input/seattle/popdat.bin,b607f9990528d0ca2fbeec9f02a5755e,https://www.dropbox.com/s/hcf80kvl66a4yai/popdat.bin.zip?dl=0
data/input/seattle/sidewalks.bin,034dd47ab77902dbc81c0107f13d8965,https://www.dropbox.com/s/ma9bmisijc7v7xa/sidewalks.bin.zip?dl=0
data/input/seattle/sidewalks.kml,94d385ba03ef1b57a5ba10965913ec6c,https://www.dropbox.com/s/vn8amar9xi6vbvh/sidewalks.kml.zip?dl=0
data/input/seattle/trips_2014.csv,d4a8e733045b28c0385fb81359d6df03,https://www.dropbox.com/s/5ppravwmk6bf20d/trips_2014.csv.zip?dl=0
data/system/cities/seattle.bin,65ed19fe6b0a41d57ccb481a5c76652a,https://www.dropbox.com/s/kwei76ih7g12n1r/seattle.bin.zip?dl=0
data/system/maps/ballard.bin,4e1338644614f04dc51348426466f8f1,https://www.dropbox.com/s/29gsioxwo4a94sj/ballard.bin.zip?dl=0
data/system/maps/downtown.bin,e5f0533502468834a82b85546458c023,https://www.dropbox.com/s/hbv4c8d19hjhnza/downtown.bin.zip?dl=0
data/system/maps/downtown_atx.bin,270eb1508a071fffdd7c6edb78b4beb6,https://www.dropbox.com/s/4q1idnl4oqv3sjr/downtown_atx.bin.zip?dl=0
data/system/maps/huge_austin.bin,aa2e4610a7b9abfeb242f94219dcf1b4,https://www.dropbox.com/s/jun8xldjrv3y6fo/huge_austin.bin.zip?dl=0
data/system/maps/huge_seattle.bin,fd203e2bb9bb56a6a54ab13fe150f863,https://www.dropbox.com/s/v9f85dccgv52n04/huge_seattle.bin.zip?dl=0
data/system/maps/lakeslice.bin,5d6d2a9f761a50727b895e656edf696c,https://www.dropbox.com/s/r8zzfky3e26gdm4/lakeslice.bin.zip?dl=0
data/system/maps/montlake.bin,b6893420323290dc57c377129ea9ee09,https://www.dropbox.com/s/1s6j9leeykkm3r8/montlake.bin.zip?dl=0
data/system/maps/south_seattle.bin,7632b11750a0bead49199338aaa9913f,https://www.dropbox.com/s/ag7p7b4rdg6scrt/south_seattle.bin.zip?dl=0
data/system/maps/udistrict.bin,87dd6f903215866a30c5075f81beace4,https://www.dropbox.com/s/hwzlac2naqtb81t/udistrict.bin.zip?dl=0
data/system/maps/west_seattle.bin,22d1a9e5235cb248d2f017f4c833fdb3,https://www.dropbox.com/s/8450pwzu2m1jj8v/west_seattle.bin.zip?dl=0
data/system/prebaked_results/lakeslice/weekday.bin,27d5e5d62b1f5447aec2c5a1572ff423,https://www.dropbox.com/s/bojl8fu4uvjmwg4/weekday.bin.zip?dl=0
data/system/prebaked_results/montlake/car vs bike contention.bin,75f4d00c72ffe575d65bcfbe21315b2e,https://www.dropbox.com/s/jefg0ikjy9dsrdd/car%20vs%20bike%20contention.bin.zip?dl=0
data/system/prebaked_results/montlake/weekday.bin,a44bdca0f2fbda2f9c803ca2e78c07af,https://www.dropbox.com/s/77v3vmomfyjv7r0/weekday.bin.zip?dl=0
data/system/scenarios/ballard/weekday.bin,c3cf546edcc27d4c85e4e97471419359,https://www.dropbox.com/s/pqpkymbdm1g3xuk/weekday.bin.zip?dl=0
data/system/scenarios/downtown/weekday.bin,726f5894c993fda25d37559e9157c263,https://www.dropbox.com/s/txvpd99vhin98tj/weekday.bin.zip?dl=0
data/system/scenarios/huge_seattle/weekday.bin,710d8459d8d4158af18408e2e1493c24,https://www.dropbox.com/s/ob2glhk181hmgkn/weekday.bin.zip?dl=0
data/system/scenarios/lakeslice/weekday.bin,f1423504c301cfff366cd9b08e529403,https://www.dropbox.com/s/mx1ku2g817kuzoh/weekday.bin.zip?dl=0
data/system/scenarios/montlake/weekday.bin,de756310c6c3420d710c1f7d65b8c4b0,https://www.dropbox.com/s/oa1zlhrs5y3vvs5/weekday.bin.zip?dl=0
data/system/scenarios/south_seattle/weekday.bin,25f0690aa2bf798f3d1e6cc38b74ff7d,https://www.dropbox.com/s/mctc7mhs7ve3v17/weekday.bin.zip?dl=0
data/system/scenarios/udistrict/weekday.bin,f94c8a85416acf4204e24615ae2cb650,https://www.dropbox.com/s/nvhqjh1cyuv6rw4/weekday.bin.zip?dl=0
data/system/scenarios/west_seattle/weekday.bin,e633910c9a781265dba0ac0a96d93025,https://www.dropbox.com/s/6tvhsdg61uje5t3/weekday.bin.zip?dl=0
data/system/cities/seattle.bin,d8e88217584d6ece7abaf1ec4222c7e6,https://www.dropbox.com/s/s1i208j6oy5pd5o/seattle.bin.zip?dl=0
data/system/maps/ballard.bin,3ee77b40b60ce5f95e80251956ca823a,https://www.dropbox.com/s/6f3nlghhqhrf8e4/ballard.bin.zip?dl=0
data/system/maps/downtown.bin,e2e739e380416cae1b733704be5b2dc2,https://www.dropbox.com/s/b8vso3pfevmdm5f/downtown.bin.zip?dl=0
data/system/maps/downtown_atx.bin,a76df031940aa3f5d9f680fa82846f26,https://www.dropbox.com/s/umfhjtr0mw058l2/downtown_atx.bin.zip?dl=0
data/system/maps/huge_austin.bin,87be99eeaa1b1c6d9d074a23df872240,https://www.dropbox.com/s/g25smuci2uta2h2/huge_austin.bin.zip?dl=0
data/system/maps/huge_seattle.bin,767b051c74b6c3a07aba02e0d540afbe,https://www.dropbox.com/s/rod1ohltfkkfh9f/huge_seattle.bin.zip?dl=0
data/system/maps/lakeslice.bin,c89ec7b553f609e6ededfd3a60571126,https://www.dropbox.com/s/bpjsehxrzh82at9/lakeslice.bin.zip?dl=0
data/system/maps/montlake.bin,50c92ff0b5bca1f86432cdfbd220c035,https://www.dropbox.com/s/4xd14op12txfi8h/montlake.bin.zip?dl=0
data/system/maps/south_seattle.bin,61ce25cee6f19ca0428267dbc71792ec,https://www.dropbox.com/s/nlj0ksoywbnos4b/south_seattle.bin.zip?dl=0
data/system/maps/udistrict.bin,fa69034e20276f3ec43cf94a316f32c6,https://www.dropbox.com/s/ncq4eiv7ebahzna/udistrict.bin.zip?dl=0
data/system/maps/west_seattle.bin,0bbeb4f70dbcbd89cd479d92bd33abc3,https://www.dropbox.com/s/z9g60t5w1x9cz41/west_seattle.bin.zip?dl=0
data/system/prebaked_results/lakeslice/weekday.bin,e124afde363d59143a07e35cac5f50aa,https://www.dropbox.com/s/66vumkmd67oc7pd/weekday.bin.zip?dl=0
data/system/prebaked_results/montlake/car vs bike contention.bin,d3e42a758ba4e10e6143c8f8370a638f,https://www.dropbox.com/s/jefg0ikjy9dsrdd/car%20vs%20bike%20contention.bin.zip?dl=0
data/system/prebaked_results/montlake/weekday.bin,2792b98144cb6039170220dfd5f47a5b,https://www.dropbox.com/s/e0waikptje7t242/weekday.bin.zip?dl=0
data/system/scenarios/ballard/weekday.bin,c403d83884a2ba835ba5965553b18930,https://www.dropbox.com/s/xobdb97jzbk0q9g/weekday.bin.zip?dl=0
data/system/scenarios/downtown/weekday.bin,1c7bd52c4c095664f9a1520c4015ebd7,https://www.dropbox.com/s/pgariaxsj6al97q/weekday.bin.zip?dl=0
data/system/scenarios/huge_seattle/weekday.bin,cdeeb0903e9ba2c0c292d1391555079b,https://www.dropbox.com/s/cm7btf1rm981lb5/weekday.bin.zip?dl=0
data/system/scenarios/lakeslice/weekday.bin,6273608f8dec48215f857ae1f4eb0c9f,https://www.dropbox.com/s/273as5xs1hygejf/weekday.bin.zip?dl=0
data/system/scenarios/montlake/weekday.bin,45e0a0647f50189c599ce0c8f3fac548,https://www.dropbox.com/s/xd09e2hqotqjuhd/weekday.bin.zip?dl=0
data/system/scenarios/south_seattle/weekday.bin,affa8a966d2df6c239429649177c3c07,https://www.dropbox.com/s/8843kzs8gcvy26l/weekday.bin.zip?dl=0
data/system/scenarios/udistrict/weekday.bin,58dfd9a454380dd0dd13a38b5ba890c6,https://www.dropbox.com/s/gzbtdro75t5u00f/weekday.bin.zip?dl=0
data/system/scenarios/west_seattle/weekday.bin,2c7a088241bab5ecc6a706e05e45c2f0,https://www.dropbox.com/s/hedo93xlxcbslls/weekday.bin.zip?dl=0

View File

@ -104,9 +104,9 @@ fn inner_warp(ctx: &mut EventCtx, app: &mut App, line: &str) -> Option<Transitio
let r = app.primary.map.maybe_get_r(RoadID(idx))?;
ID::Lane(r.children_forwards[0].0)
}
'l' => ID::Lane(LaneID(idx as u32)),
'l' => ID::Lane(LaneID(idx)),
'i' => ID::Intersection(IntersectionID(idx)),
'b' => ID::Building(BuildingID(idx as u32)),
'b' => ID::Building(BuildingID(idx)),
'a' => ID::Area(AreaID(idx)),
'p' => ID::Pedestrian(PedestrianID(idx)),
'P' => {

View File

@ -468,7 +468,7 @@ pub fn apply_map_edits(ctx: &mut EventCtx, app: &mut App, edits: MapEdits) {
// An edit to one lane potentially affects markings in all lanes in the same road, because
// of one-way markings, driving lines, etc.
for l in road.all_lanes() {
app.primary.draw_map.lanes[l.idx()].clear_rendering();
app.primary.draw_map.lanes[l.0].clear_rendering();
}
}

View File

@ -245,7 +245,7 @@ impl DrawMap {
}
pub fn get_l(&self, id: LaneID) -> &DrawLane {
&self.lanes[id.idx()]
&self.lanes[id.0]
}
pub fn get_i(&self, id: IntersectionID) -> &DrawIntersection {
@ -253,7 +253,7 @@ impl DrawMap {
}
pub fn get_b(&self, id: BuildingID) -> &DrawBuilding {
&self.buildings[id.0 as usize]
&self.buildings[id.0]
}
pub fn get_pl(&self, id: ParkingLotID) -> &DrawParkingLot {

View File

@ -518,7 +518,7 @@ impl EditCmd {
let id = *id;
let lt = *lt;
let lane = &mut map.lanes[id.idx()];
let lane = &mut map.lanes[id.0];
if lane.lane_type == lt {
return false;
}
@ -538,7 +538,7 @@ impl EditCmd {
}
EditCmd::ReverseLane { l, dst_i } => {
let l = *l;
let lane = &mut map.lanes[l.idx()];
let lane = &mut map.lanes[l.0];
if lane.dst_i == *dst_i {
return false;
@ -884,7 +884,7 @@ impl Map {
l.parking_blackhole = None;
}
for (l, redirect) in connectivity::redirect_parking_blackholes(self, timer) {
self.lanes[l.idx()].parking_blackhole = Some(redirect);
self.lanes[l.0].parking_blackhole = Some(redirect);
}
timer.stop("recompute parking blackholes");

View File

@ -56,7 +56,7 @@ pub fn make_all_buildings(
let sidewalk_line =
trim_path(&b.polygon, Line::new(bldg_center.to_pt2d(), sidewalk_pt));
let id = BuildingID(results.len() as u32);
let id = BuildingID(results.len());
let mut bldg = Building {
id,
polygon: b.polygon.clone(),

View File

@ -133,7 +133,7 @@ pub fn make_bus_stops(
idx: map.get_l(sidewalk_pos.lane()).bus_stops.len(),
};
pt_to_stop.insert((sidewalk_pos, driving_pos), id);
map.lanes[sidewalk_pos.lane().idx()].bus_stops.insert(id);
map.lanes[sidewalk_pos.lane().0].bus_stops.insert(id);
bus_stops.insert(
id,
BusStop {

View File

@ -156,7 +156,7 @@ impl Map {
let mut fwd_width_so_far = Distance::ZERO;
let mut back_width_so_far = Distance::ZERO;
for lane in &r.lane_specs {
let id = LaneID(map.lanes.len() as u32);
let id = LaneID(map.lanes.len());
let (src_i, dst_i) = if lane.reverse_pts { (i2, i1) } else { (i1, i2) };
map.intersections[src_i.0].outgoing_lanes.push(id);
@ -254,7 +254,7 @@ impl Map {
timer.start("find parking blackholes");
for (l, redirect) in connectivity::redirect_parking_blackholes(&map, timer) {
map.lanes[l.idx()].parking_blackhole = Some(redirect);
map.lanes[l.0].parking_blackhole = Some(redirect);
}
timer.stop("find parking blackholes");
@ -263,10 +263,10 @@ impl Map {
let lane = b.sidewalk();
// TODO Could be more performant and cleanly written
let mut bldgs = map.lanes[lane.idx()].building_paths.clone();
let mut bldgs = map.lanes[lane.0].building_paths.clone();
bldgs.push(b.id);
bldgs.sort_by_key(|b| map.buildings[b.0 as usize].front_path.sidewalk.dist_along());
map.lanes[lane.idx()].building_paths = bldgs;
bldgs.sort_by_key(|b| map.buildings[b.0].front_path.sidewalk.dist_along());
map.lanes[lane.0].building_paths = bldgs;
}
map.parking_lots =
@ -345,7 +345,7 @@ impl Map {
.collect::<Vec<_>>()
{
map.bus_stops.remove(&id);
map.lanes[id.sidewalk.idx()].bus_stops.remove(&id);
map.lanes[id.sidewalk.0].bus_stops.remove(&id);
}
}
@ -388,11 +388,11 @@ fn is_border(intersection: &Intersection, lanes: &Vec<Lane>) -> bool {
let has_driving_in = intersection
.incoming_lanes
.iter()
.any(|l| lanes[l.idx()].is_driving());
.any(|l| lanes[l.0].is_driving());
let has_driving_out = intersection
.outgoing_lanes
.iter()
.any(|l| lanes[l.idx()].is_driving());
.any(|l| lanes[l.0].is_driving());
has_driving_in != has_driving_out
}
@ -432,15 +432,13 @@ fn match_points_to_lanes<F: Fn(&Lane) -> bool>(
for query_pt in pts {
timer.next();
if let Some((l, pt)) = closest.closest_pt(query_pt.to_pt2d(), max_dist_away) {
if let Some(dist_along) = lanes[l.idx()].dist_along_of_point(pt) {
if let Some(dist_along) = lanes[l.0].dist_along_of_point(pt) {
results.insert(query_pt, Position::new(l, dist_along));
} else {
panic!(
"{} isn't on {} according to dist_along_of_point, even though closest_point \
thinks it is.\n{}",
pt,
l,
lanes[l.idx()].lane_center_pts
pt, l, lanes[l.0].lane_center_pts
);
}
}

View File

@ -44,7 +44,7 @@ pub fn make_all_turns(
// turn leading to it.
let mut incoming_missing: HashSet<LaneID> = HashSet::new();
for l in &i.incoming_lanes {
if lanes[l.idx()].lane_type.supports_any_movement() {
if lanes[l.0].lane_type.supports_any_movement() {
incoming_missing.insert(*l);
}
}
@ -65,7 +65,7 @@ pub fn make_all_turns(
let mut outgoing_missing: HashSet<LaneID> = HashSet::new();
for l in &i.outgoing_lanes {
if lanes[l.idx()].lane_type.supports_any_movement() {
if lanes[l.0].lane_type.supports_any_movement() {
outgoing_missing.insert(*l);
}
}
@ -154,15 +154,15 @@ fn make_vehicle_turns(
// If we fell back to driving lanes for both incoming and outgoing and it's not
// time, then skip. This should prevent duplicates.
if lanes[incoming[0].idx()].lane_type != lane_type
&& lanes[outgoing[0].idx()].lane_type != lane_type
if lanes[incoming[0].0].lane_type != lane_type
&& lanes[outgoing[0].0].lane_type != lane_type
{
continue;
}
// Use an arbitrary lane from each road to get the angle between r1 and r2.
let angle1 = lanes[incoming[0].idx()].last_line().angle();
let angle2 = lanes[outgoing[0].idx()].first_line().angle();
let angle1 = lanes[incoming[0].0].last_line().angle();
let angle2 = lanes[outgoing[0].0].first_line().angle();
let type_from_angle = TurnType::from_angles(angle1, angle2);
let tt = if type_from_angle == TurnType::Right {
@ -283,8 +283,8 @@ fn make_vehicle_turns_for_dead_end(
l1,
*l2,
TurnType::from_angles(
lanes[l1.idx()].last_line().angle(),
lanes[l2.idx()].first_line().angle(),
lanes[l1.0].last_line().angle(),
lanes[l2.0].first_line().angle(),
),
));
}
@ -629,7 +629,7 @@ fn turn_id(parent: IntersectionID, src: LaneID, dst: LaneID) -> TurnID {
fn get_sidewalk<'a>(lanes: &'a Vec<Lane>, children: &Vec<(LaneID, LaneType)>) -> Option<&'a Lane> {
for (id, lt) in children {
if *lt == LaneType::Sidewalk {
return Some(&lanes[id.idx()]);
return Some(&lanes[id.0]);
}
}
None
@ -657,8 +657,8 @@ fn make_vehicle_turn(
l2: LaneID,
turn_type: TurnType,
) -> Option<Turn> {
let src = &lanes[l1.idx()];
let dst = &lanes[l2.idx()];
let src = &lanes[l1.0];
let dst = &lanes[l2.0];
if src.last_pt() == dst.first_pt() {
return None;
@ -710,7 +710,7 @@ fn from_pt(pt: Point2d<f64>) -> Pt2D {
}
fn is_turn_allowed(turn: &Turn, roads: &Vec<Road>, lanes: &Vec<Lane>) -> bool {
let l = &lanes[turn.id.src.idx()];
let l = &lanes[turn.id.src.0];
let r = &roads[l.parent.0];
if let Some(mut types) = l.get_turn_restrictions(r) {
types.any(|turn_type| turn_type == turn.turn_type)
@ -729,8 +729,8 @@ fn does_turn_pass_restrictions(
return true;
}
let src = lanes[turn.id.src.idx()].parent;
let dst = lanes[turn.id.dst.idx()].parent;
let src = lanes[turn.id.src.0].parent;
let dst = lanes[turn.id.dst.0].parent;
for (restriction, to) in &roads[src.0].turn_restrictions {
// The restriction only applies to one direction of the road.

View File

@ -168,7 +168,7 @@ impl Map {
}
pub fn maybe_get_l(&self, id: LaneID) -> Option<&Lane> {
self.lanes.get(id.idx())
self.lanes.get(id.0)
}
pub fn maybe_get_i(&self, id: IntersectionID) -> Option<&Intersection> {
@ -180,7 +180,7 @@ impl Map {
}
pub fn maybe_get_b(&self, id: BuildingID) -> Option<&Building> {
self.buildings.get(id.0 as usize)
self.buildings.get(id.0)
}
pub fn maybe_get_pl(&self, id: ParkingLotID) -> Option<&ParkingLot> {
@ -208,7 +208,7 @@ impl Map {
}
pub fn get_l(&self, id: LaneID) -> &Lane {
&self.lanes[id.idx()]
&self.lanes[id.0]
}
pub fn get_i(&self, id: IntersectionID) -> &Intersection {
@ -225,7 +225,7 @@ impl Map {
}
pub fn get_b(&self, id: BuildingID) -> &Building {
&self.buildings[id.0 as usize]
&self.buildings[id.0]
}
pub fn get_a(&self, id: AreaID) -> &Area {
@ -647,7 +647,7 @@ impl Map {
}
}
pub fn hack_override_offstreet_spots_individ(&mut self, b: BuildingID, spots: usize) {
let b = &mut self.buildings[b.0 as usize];
let b = &mut self.buildings[b.0];
if let Some(ref mut p) = b.parking {
if p.public_garage_name.is_none() {
p.num_spots = spots;

View File

@ -1,11 +1,17 @@
use abstutil::{deserialize_usize, serialize_usize};
use geom::Polygon;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::fmt;
// TODO reconsider pub usize. maybe outside world shouldnt know.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct AreaID(pub usize);
pub struct AreaID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
impl fmt::Display for AreaID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -1,12 +1,18 @@
use crate::{LaneID, Position};
use abstutil::{deserialize_usize, serialize_usize};
use geom::{Line, PolyLine, Polygon, Pt2D};
use serde::{Deserialize, Serialize};
use std::collections::BTreeSet;
use std::fmt;
// TODO reconsider pub usize. maybe outside world shouldnt know.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct BuildingID(pub u32);
pub struct BuildingID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
impl fmt::Display for BuildingID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -1,4 +1,5 @@
use crate::{LaneID, PathConstraints, Position};
use abstutil::{deserialize_usize, serialize_usize};
use serde::{Deserialize, Serialize};
use std::fmt;
@ -17,7 +18,13 @@ impl fmt::Display for BusStopID {
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct BusRouteID(pub usize);
pub struct BusRouteID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
impl fmt::Display for BusRouteID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -1,13 +1,19 @@
use crate::raw::OriginalIntersection;
use crate::{DirectedRoadID, LaneID, Map, PathConstraints, Road, RoadID, TurnID};
use abstutil::{deserialize_usize, serialize_usize};
use geom::{Distance, Polygon};
use serde::{Deserialize, Serialize};
use std::collections::BTreeSet;
use std::fmt;
// TODO reconsider pub usize. maybe outside world shouldnt know.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct IntersectionID(pub usize);
pub struct IntersectionID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
impl fmt::Display for IntersectionID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -3,6 +3,7 @@ use crate::{
osm, BuildingID, BusStopID, DirectedRoadID, IntersectionID, Map, PathConstraints, Road, RoadID,
TurnType,
};
use abstutil::{deserialize_usize, serialize_usize};
use geom::{Angle, Distance, Line, PolyLine, Pt2D};
use serde::{Deserialize, Serialize};
use std::collections::BTreeSet;
@ -15,13 +16,13 @@ pub const PARKING_SPOT_LENGTH: Distance = Distance::const_meters(8.0);
pub const PARKING_LOT_SPOT_LENGTH: Distance = Distance::const_meters(6.4);
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct LaneID(pub u32);
impl LaneID {
pub fn idx(self) -> usize {
self.0 as usize
}
}
pub struct LaneID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
impl fmt::Display for LaneID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -1,4 +1,5 @@
use crate::Position;
use abstutil::{deserialize_usize, serialize_usize};
use geom::{Angle, Line, PolyLine, Polygon, Pt2D};
use serde::{Deserialize, Serialize};
use std::fmt;
@ -13,7 +14,13 @@ use std::fmt;
// - aisle clipping isnt perfect (23rd and rainier, pepsi)
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct ParkingLotID(pub usize);
pub struct ParkingLotID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
impl fmt::Display for ParkingLotID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -1,14 +1,20 @@
use crate::raw::{OriginalRoad, RestrictionType};
use crate::{osm, BusStopID, IntersectionID, LaneID, LaneType, Map, PathConstraints, Zone};
use abstutil::{deserialize_usize, serialize_usize};
use enumset::EnumSet;
use geom::{Distance, PolyLine, Polygon, Speed};
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashSet};
use std::fmt;
// TODO reconsider pub usize. maybe outside world shouldnt know.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct RoadID(pub usize);
pub struct RoadID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
impl fmt::Display for RoadID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -202,7 +202,7 @@ fn make_input_graph(
// pretend like it points to some arbitrary other node. Since no paths will start from
// this unused node, this won't affect results.
// TODO Upstream a method in InputGraph to do this more clearly.
if !any && l.id.idx() == num_lanes - 1 {
if !any && l.id.0 == num_lanes - 1 {
input_graph.add_edge(from, nodes.get(Node::Lane(LaneID(0))), 1);
}
}

View File

@ -32,7 +32,7 @@ pub use crate::render::{
CarStatus, DontDrawAgents, DrawCarInput, DrawPedCrowdInput, DrawPedestrianInput, GetDrawAgents,
PedCrowdLocation, UnzoomedAgent,
};
use abstutil::Cloneable;
use abstutil::{deserialize_usize, serialize_usize, Cloneable};
use geom::{Distance, Pt2D, Speed, Time};
use map_model::{
BuildingID, BusStopID, DirectedRoadID, IntersectionID, LaneID, Map, ParkingLotID, Path,
@ -58,7 +58,14 @@ pub const FOLLOWING_DISTANCE: Distance = Distance::const_meters(1.0);
// for convenient debugging.
// TODO Implement Eq, Hash, Ord manually to guarantee this.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct CarID(pub usize, pub VehicleType);
pub struct CarID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
pub VehicleType,
);
impl fmt::Display for CarID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -72,7 +79,13 @@ impl fmt::Display for CarID {
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct PedestrianID(pub usize);
pub struct PedestrianID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
impl fmt::Display for PedestrianID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -107,7 +120,13 @@ impl fmt::Display for AgentID {
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct TripID(pub usize);
pub struct TripID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
impl fmt::Display for TripID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -116,7 +135,13 @@ impl fmt::Display for TripID {
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct PersonID(pub usize);
pub struct PersonID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
impl fmt::Display for PersonID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -125,7 +150,18 @@ impl fmt::Display for PersonID {
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct OrigPersonID(pub usize, pub usize);
pub struct OrigPersonID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)]
pub enum VehicleType {