Skip to content

Commit 20cac74

Browse files
author
Rob Fitzgerald
authored
Merge pull request #17 from NREL/rjf/compass-edge-lists
Rjf/compass edge lists
2 parents 9aae703 + 16c2bb1 commit 20cac74

17 files changed

Lines changed: 401 additions & 111 deletions

File tree

.github/workflows/rust-publish.yaml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/rust-release.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@ jobs:
2323
rustup component add rustfmt
2424
cargo fmt --all --manifest-path rust/Cargo.toml -- --check
2525
26-
- name: Install test assets
27-
run: |
28-
./setup.sh
29-
30-
- name: Test
31-
run: |
32-
cargo test --workspace --verbose --manifest-path rust/Cargo.toml
26+
- name: Run unit tests
27+
run: cargo test --workspace --manifest-path=rust/Cargo.toml -- --skip test_e2e
3328

3429
- name: Publish bambam-osm
3530
run: cargo publish -p bambam-osm --manifest-path=rust/Cargo.toml --token "${{ secrets.CRATES_IO_TOKEN }}"
@@ -43,3 +38,5 @@ jobs:
4338
- name: Publish bambam
4439
run: cargo publish -p bambam --manifest-path=rust/Cargo.toml --token "${{ secrets.CRATES_IO_TOKEN }}"
4540

41+
# - name: Publish bambam-py
42+
# run: cargo publish -p bambam-py --manifest-path=rust/Cargo.toml --token "${{ secrets.CRATES_IO_TOKEN }}"

.github/workflows/test.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ jobs:
2323
run: |
2424
rustup component add rustfmt
2525
cargo fmt --all --manifest-path rust/Cargo.toml -- --check
26-
26+
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v6
29+
2730
- name: Install test assets
2831
run: |
29-
./setup.sh
32+
./script/setup_test_bambam.sh
33+
./script/setup_test_bambam_osm.sh
3034
3135
- name: Test
3236
run: |

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ Cargo.lock
44
target
55
output
66
cache
7-
.venv
7+
.venv
8+
denver_co/

configuration/denver_test.toml

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
parallelism = 6
2+
response_persistence_policy = "persist_response_from_memory"
3+
4+
[graph]
5+
edge_list.input_file = "../denver_co/edges-compass.csv.gz"
6+
vertex_list_input_file = "../denver_co/vertices-compass.csv.gz"
7+
8+
[mapping]
9+
type = "edge"
10+
geometry = { input_file = "../denver_co/edges-geometries-enumerated.txt.gz" }
11+
tolerance.distance = 15.0
12+
tolerance.unit = "meters"
13+
queries_without_destinations = false
14+
matching_type = ["point", "vertex_id", "edge_id"]
15+
16+
[algorithm]
17+
type = "a*"
18+
19+
# cut off searches that exceed these termination policies.
20+
[termination]
21+
type = "combined"
22+
[[termination.models]]
23+
type = "query_runtime"
24+
limit = "00:01:00"
25+
frequency = 100_000
26+
[[termination.models]]
27+
type = "solution_size"
28+
limit = 2_000_000
29+
30+
[search.traversal]
31+
type = "combined"
32+
33+
[[search.traversal.models]]
34+
type = "distance"
35+
distance_unit = "miles"
36+
37+
[[search.traversal.models]]
38+
type = "fixed_speed"
39+
name = "walk"
40+
speed = 5.0
41+
speed_unit = "kph"
42+
43+
[[search.traversal.models]]
44+
type = "fixed_speed"
45+
name = "bike"
46+
speed = 16.0
47+
speed_unit = "kph"
48+
49+
[[search.traversal.models]]
50+
type = "speed"
51+
speed_table_input_file = "../denver_co/edges-posted-speed-enumerated.txt.gz"
52+
speed_unit = "kph"
53+
54+
[[search.traversal.models]]
55+
type = "multimodal"
56+
57+
[search.traversal.models.dependencies]
58+
walk = [{ input_feature = { name = "walk_speed", type = "speed" }, destination_features = ["edge_time", "trip_time"] }]
59+
bike = [{ input_feature = { name = "bike_speed", type = "speed" }, destination_features = ["edge_time", "trip_time"] }]
60+
drive = [
61+
{ input_feature = { name = "edge_speed", type = "speed" }, destination_features = ["edge_time", "trip_time"] },
62+
# { time_feature = "trip_enroute_delay", destinations = [
63+
# "edge_time",
64+
# "trip_time",
65+
# ] },
66+
]
67+
68+
[search.traversal.models.output_features]
69+
trip_time = { type = "time", unit = "minutes", initial = 0.0, accumulator = true }
70+
edge_time = { type = "time", unit = "minutes", initial = 0.0, accumulator = false }
71+
# penalty_factor = { name = "factor", unit = "none", accumulator = false, format = { FloatingPoint = { initial = 1.0 } } }
72+
73+
# use a time-optimal routing strategy
74+
[cost]
75+
weights = { trip_time = 1.0 }
76+
vehicle_rates = { trip_time = { type = "raw" } }
77+
# weights = { trip_time = 1.0, penalty_factor = 1.0 }
78+
# vehicle_rates = { trip_time = { type = "raw" }, penalty_factor = { type = "raw" } }
79+
cost_aggregation = "sum"
80+
81+
[search.access]
82+
type = "turn_delay"
83+
edge_heading_input_file = "../denver_co/edges-headings-enumerated.csv.gz"
84+
[search.access.turn_delay_model]
85+
type = "tabular_discrete"
86+
time_unit = "seconds"
87+
[search.access.turn_delay_model.table]
88+
no_turn = 0.0
89+
slight_right = 0.5
90+
right = 1.0
91+
sharp_right = 1.5
92+
slight_left = 1.0
93+
left = 2.5
94+
sharp_left = 3.5
95+
u_turn = 9.5
96+
97+
[search.frontier]
98+
type = "combined"
99+
100+
[[search.frontier.models]]
101+
type = "road_class"
102+
road_class_input_file = "../denver_co/edges-road-class-enumerated.txt.gz"
103+
104+
# [[search.frontier.models]]
105+
# type = "turn_restriction"
106+
# turn_restriction_input_file = "../denver_co/edges-turn-restrictions.csv.gz"
107+
108+
[[search.frontier.models]]
109+
type = "time_limit"
110+
time_limit = { time = 40.0, time_unit = "minutes" }
111+
112+
[[plugin.input_plugins]]
113+
type = "grid"
114+
extent_format = "wkt"
115+
grid = { type = "h3", resolution = 8 }
116+
[plugin.input_plugins.population_source]
117+
type = "acs"
118+
acs_type = "five_year"
119+
acs_year = 2022
120+
acs_resolution = "census_tract"
121+
acs_categories = ["B01001_001E"]
122+
123+
[[plugin.input_plugins]]
124+
type = "inject"
125+
format = "key_value"
126+
write_mode = "overwrite"
127+
key = "grid_search"
128+
[plugin.input_plugins.value]
129+
mode = ["walk", "bike", "drive"]
130+
# modes = [{ mode = "walk", road_classes = [4, 5, 6, 7] }, { mode = "bike", road_classes = [4, 5, 6, 7] }, { mode = "drive", road_classes = [1, 2, 3, 4, 5, 6] }]
131+
132+
[[plugin.input_plugins]]
133+
type = "inject"
134+
key = "start_time"
135+
value = "08:00:00"
136+
format = "key_value"
137+
write_mode = "overwrite"
138+
139+
[[plugin.input_plugins]]
140+
type = "inject"
141+
key = "start_weekday"
142+
value = "monday"
143+
format = "key_value"
144+
write_mode = "overwrite"
145+
146+
[[plugin.input_plugins]]
147+
type = "grid_search"
148+
149+
[[plugin.input_plugins]]
150+
type = "load_balancer"
151+
[plugin.input_plugins.weight_heuristic]
152+
type = "custom"
153+
[plugin.input_plugins.weight_heuristic.custom_weight_type]
154+
type = "categorical"
155+
column_name = "mode"
156+
default = 1
157+
mapping = { "walk" = 1, "bike" = 10, "drive" = 100 }
158+
159+
[[plugin.output_plugins]]
160+
type = "summary"
161+
162+
[[plugin.output_plugins]]
163+
type = "isochrone"
164+
time_bin = { type = "list", times = [10, 20, 30, 40] }
165+
isochrone_algorithm = { type = "k_nearest_concave_hull", k = 3 }
166+
destination_point_generator = { type = "destination_point" }
167+
isochrone_output_format = "wkb"
168+
169+
### MEP OPPORTUNITY DATA CONFIGURATION #################################
170+
# assigns opportunities to search results based on a file or api data source
171+
# and a taxonomy for MEP activity types.
172+
# this example shows data loaded from the census LODES online file repository
173+
# assigning activity types by NAICS sector id.
174+
[[plugin.output_plugins]]
175+
type = "opportunity"
176+
collect_format = "aggregate"
177+
178+
[plugin.output_plugins.model]
179+
type = "combined"
180+
181+
[[plugin.output_plugins.model.models]]
182+
type = "api"
183+
vertex_input_file = "../denver_co/vertices-compass.csv.gz"
184+
activity_column_names = ["entertainment", "food", "retail", "healthcare", "services", "jobs"]
185+
table_orientation = "destination_vertex_oriented"
186+
187+
[plugin.output_plugins.model.models.opportunity_source]
188+
type = "lodes"
189+
study_region = { type = "census", geoids = ["08"] }
190+
191+
# collect LODES data at the tract level. while it is available at the block,
192+
# the download + processing time is 10x that of census tracts. other possible values
193+
# are `block`, `county` or `state`.
194+
data_granularity = "census_tract"
195+
# different editions of the dataset, we are choosing LODES v 8.0.
196+
edition = "LODES8"
197+
# Job Type, can have a value of “JT00” for All Jobs, “JT01” for Primary Jobs, “JT02” for All
198+
# Private Jobs, “JT03” for Private Primary Jobs, “JT04” for All Federal Jobs, or “JT05” for
199+
# Federal Primary Jobs
200+
job_type = "JT00"
201+
# Segment of the workforce, can have the values of:
202+
# - S000: Total number of jobs (default)
203+
# - SA01: Number of jobs of workers age 29 or younger
204+
# - SA02: Number of jobs for workers age 30 to 54
205+
# - SA03: Number of jobs for workers age 55 or older
206+
# - SE01: Number of jobs with earnings $1250/month or less
207+
# - SE02: Number of jobs with earnings $1251/month to $3333/month
208+
# - SE03: Number of jobs with earnings greater than $3333/month
209+
# - SI01: Number of jobs in Goods Producing industry sectors
210+
# - SI02: Number of jobs in Trade, Transportation, and Utilities industry sectors
211+
# - SI03: Number of jobs in All Other Services industry sectors
212+
segment = "S000"
213+
214+
# most recent year with all states. Alaska has no coverage from 2017-2022. we may
215+
# want a "continental" variant which could support 2022.
216+
year = 2022
217+
218+
[plugin.output_plugins.model.models.opportunity_source.activity_mapping]
219+
# see https://lehd.ces.census.gov/data/lodes/LODES8/LODESTechDoc8.0.pdf
220+
CNS01 = ["jobs"] # 11 (Agriculture, Forestry, Fishing and Hunting)
221+
CNS02 = ["jobs"] # 21 (Mining, Quarrying, and Oil and Gas Extraction)
222+
CNS03 = ["jobs"] # 22 (Utilities)
223+
CNS04 = ["jobs"] # 23 (Construction)
224+
CNS05 = ["jobs"] # 31-33 (Manufacturing)
225+
CNS06 = ["jobs"] # 42 (Wholesale Trade)
226+
CNS07 = ["jobs", "retail"] # 44-45 (Retail Trade)
227+
CNS08 = ["jobs"] # 48-49 (Transportation and Warehousing)
228+
CNS09 = ["jobs"] # 51 (Information)
229+
CNS10 = ["jobs"] # 52 (Finance and Insurance)
230+
CNS11 = ["jobs"] # 53 (Real Estate and Rental and Leasing)
231+
CNS12 = ["jobs", "services"] # 54 (Professional, Scientific, and Technical Services)
232+
CNS13 = ["jobs"] # 55 (Management of Companies and Enterprises)
233+
CNS14 = ["jobs"] # 56 (Admin/Support/Waste Mgmt/Remediation Services)
234+
CNS15 = ["jobs"] # 61 (Educational Services)
235+
CNS16 = ["jobs", "healthcare"] # 62 (Health Care and Social Assistance)
236+
CNS17 = ["jobs", "entertainment"] # 71 (Arts, Entertainment, and Recreation)
237+
CNS18 = ["jobs", "food"] # 72 (Accommodation and Food Services)
238+
CNS19 = ["jobs"] # 81 (Other Services [except Public Administration])
239+
CNS20 = ["jobs"] # 92 (Public Administration)

rust/Cargo.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ bamcensus-core = { version = "0.1.0" }
99
bamcensus-acs = { version = "0.1.0" }
1010
bamcensus = { version = "0.1.0" }
1111
bamcensus-lehd = { version = "0.1.0" }
12-
routee-compass = { version = "0.14.0" }
13-
routee-compass-core = { version = "0.14.0" }
14-
routee-compass-powertrain = { version = "0.14.0" }
12+
routee-compass = { git = "https://github.com/NREL/routee-compass.git", rev = "5e8503a" }
13+
routee-compass-core = { git = "https://github.com/NREL/routee-compass.git", rev = "5e8503a" }
14+
routee-compass-powertrain = { git = "https://github.com/NREL/routee-compass.git", rev = "5e8503a" }
1515

1616
# third party
1717
arrow = { version = "55.0.0" }
@@ -25,11 +25,14 @@ flate2 = "1.0"
2525
futures = { version = "0.3.31", features = ["executor"] }
2626
geo = { version = "0.30.0", features = ["use-serde"] }
2727
geo-buffer = "0.2.0"
28+
geo-traits = "0.3.0"
29+
geo-types = "0.7.16"
2830
geojson = { version = "0.24.1" }
2931
geozero = { version = "0.14.0", features = ["with-wkb"] }
3032
gtfs-structures = "0.43.0"
3133
h3o = { version = "0.8.0", features = ["serde", "geo"] }
3234
hex = "0.4.3"
35+
inventory = { version = "0.3.21" }
3336
itertools = { version = "0.14.0" }
3437
kdam = "0.6.2"
3538
log = "0.4.19"
@@ -38,17 +41,19 @@ object_store = { "version" = "0.12.0", features = ["aws"] }
3841
osmio = "0.14.0"
3942
osmpbf = "0.3.4"
4043
parquet = { version = "55.0.0", features = ["snap", "async", "object_store"] }
44+
rand = "0.9.1"
4145
rayon = "1.10.0"
4246
regex = { version = "1.11.1" }
4347
reqwest = { version = "0.12.12", features = ["blocking"] }
4448
rstar = { version = "0.12.0" }
4549
serde = { version = "1.0.160", features = ["derive"] }
4650
serde_json = { version = "1.0" }
51+
shapefile = { version = "0.7.0", features = ["geo-types"] }
4752
skiplist = "0.5.1"
4853
thiserror = "2.0.12"
4954
tokio = "1.39.2"
5055
toml = { version = "0.8.20" }
5156
uom = { version = "0.37.0", features = ["serde"]}
52-
wkb = "0.7.1"
57+
wkb = "0.9.0"
5358
wkt = { version = "0.13.0", features = ["serde"] }
5459
zip = "2.1.3"

rust/bambam-osm/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ mod tests {
106106
Err(_) => true, // default
107107
};
108108
let temp_directory = "src/test/tmp";
109-
let pbf_file = "src/test/liechtenstein-latest.osm.pbf";
109+
let pbf_file = "src/test/liechtenstein-250908.osm.pbf";
110110
let extent_file = "src/test/schaan_liechtenstein.txt";
111111
let config_file = "src/test/test_osm_import.toml";
112112
let conf = crate::App::Pbf {

0 commit comments

Comments
 (0)