bambam-modal-metrics crate - #169
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a provider-agnostic modal-metrics crate while preserving OSM CLI support.
Changes:
- Adds generic spatial-edge and modal-metric traits.
- Moves WCI/LTS computation from
bambam-osm. - Updates workspace dependencies, CLI wiring, tests, and publishing.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
script/publish_crates.sh |
Adds the new crate to publishing. |
rust/Cargo.toml |
Registers the workspace crate and dependency. |
rust/bambam/src/bin/bambam_util.rs |
Uses generic metrics with OSM types. |
rust/bambam/Cargo.toml |
Adds the metrics dependency. |
rust/bambam-osm/src/model/osm/graph/osm_way_data_serializable.rs |
Implements edge and spatial traits. |
rust/bambam-osm/src/model/osm/graph/osm_node_data_serializable.rs |
Implements the vertex trait. |
rust/bambam-osm/src/lib.rs |
Removes the former app module. |
rust/bambam-osm/src/app/network/wci/ops.rs |
Removes relocated WCI operations. |
rust/bambam-osm/src/app/network/wci/compute_wci.rs |
Removes relocated WCI computation. |
rust/bambam-osm/src/app/network/lts/ops.rs |
Removes relocated LTS predicates. |
rust/bambam-osm/src/app/network/common/ops.rs |
Removes relocated shared operations. |
rust/bambam-osm/src/app/network/common/mod.rs |
Removes the old common module. |
rust/bambam-osm/src/app/mod.rs |
Removes OSM app exports. |
rust/bambam-osm/Cargo.toml |
Adds the metrics dependency. |
rust/bambam-modal-metrics/src/wci/wci.rs |
Generalizes WCI components. |
rust/bambam-modal-metrics/src/wci/ops.rs |
Adds generic WCI operations. |
rust/bambam-modal-metrics/src/wci/mod.rs |
Updates WCI exports. |
rust/bambam-modal-metrics/src/wci/compute_wci.rs |
Adds generic WCI computation and tests. |
rust/bambam-modal-metrics/src/network_traits/vertex_for_modal_metric.rs |
Defines the vertex contract. |
rust/bambam-modal-metrics/src/network_traits/spatial_edge.rs |
Defines the spatial-edge contract. |
rust/bambam-modal-metrics/src/network_traits/mod.rs |
Exports network traits. |
rust/bambam-modal-metrics/src/network_traits/edge_for_modal_metric.rs |
Defines the metric-edge contract. |
rust/bambam-modal-metrics/src/lts/mod.rs |
Updates LTS modules. |
rust/bambam-modal-metrics/src/lts/lts.rs |
Updates generic LTS documentation/imports. |
rust/bambam-modal-metrics/src/lts/compute_lts.rs |
Generalizes LTS computation. |
rust/bambam-modal-metrics/src/lib.rs |
Exports the new crate modules. |
rust/bambam-modal-metrics/src/common/ops.rs |
Adds generic loading and speed helpers. |
rust/bambam-modal-metrics/src/common/modal_metrics.rs |
Generalizes metric dispatch. |
rust/bambam-modal-metrics/src/common/mod.rs |
Exports common modules. |
rust/bambam-modal-metrics/src/common/edge_rtree_entry.rs |
Adds generic spatial indexing. |
rust/bambam-modal-metrics/src/common/cycleway_tag.rs |
Makes cycleway tags cloneable. |
rust/bambam-modal-metrics/src/common/bulk_compute_modal_metric.rs |
Generalizes bulk CSV processing. |
rust/bambam-modal-metrics/Cargo.toml |
Defines the new crate. |
Suppressed comments (1)
rust/bambam-modal-metrics/src/common/edge_rtree_entry.rs:80
- This comparison allocates a new
Stringfor every R-tree candidate becauseSpatialEdge::idreturns an owned string and the OSM implementation callsto_string(). Since this runs in the per-edge neighbor-search hot path, large networks incur many avoidable heap allocations; use an associated ID type or a borrowed/nonallocating identifier instead.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
robfitzgerald
left a comment
There was a problem hiding this comment.
looks great. the compute_{wci|lts} functions are probably the best spot to see where we benefit from the abstractions, since those functions are now very readable, and we can count on them for any network type going forward. great work refactoring this, @admrtin.
the only thing i am deliberating on review is whether the EdgeForModalMetric trait should get split out into 3 traits, EdgeFor{Common|Wci|Lts}, for better interface segregation + extensibility. but let's talk about that later maybe when we get to the OvertureMaps phase of this refactor (or during our standup).
one tiny change to the publish_crates.sh script requested here but it's optional, we can deal with it later if you just want to roll this in.
thanks! great work!
Solves #163 .
New crate containing the logic for computing WCI/LTS modal metrics with generic traits
Three new traits were created:
EdgeForModalMetric,VertexForModalMetric,SpatialEdge.The previous PRs #165 and #157 were adapted with these new traits, so the bambam_util CLI for computing modal metrics still works as expected for OSM data.
The traits are not implemented for OMF segments/connectors yet, as this will require spatial joins with OSM attributes to enrich the data for these computations. See #164 for more information on the OMF data enrichment issue.