Skip to content

bambam-modal-metrics crate - #169

Merged
admrtin merged 10 commits into
mainfrom
amm/network-traits
Aug 20, 2026
Merged

bambam-modal-metrics crate#169
admrtin merged 10 commits into
mainfrom
amm/network-traits

Conversation

@admrtin

@admrtin admrtin commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 String for every R-tree candidate because SpatialEdge::id returns an owned string and the OSM implementation calls to_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.

Comment thread rust/bambam-osm/src/model/osm/graph/osm_way_data_serializable.rs Outdated
Comment thread rust/bambam-osm/src/lib.rs
Comment thread rust/bambam-modal-metrics/Cargo.toml
Comment thread script/publish_crates.sh
admrtin and others added 2 commits August 13, 2026 15:35
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@admrtin admrtin changed the title bambam-modal-metric crate bambam-modal-metrics crate Aug 13, 2026
@admrtin
admrtin requested a review from robfitzgerald August 14, 2026 14:54

@robfitzgerald robfitzgerald left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread rust/bambam-modal-metrics/README.md
Comment thread script/publish_crates.sh
@admrtin
admrtin merged commit d5ae60c into main Aug 20, 2026
1 check passed
@admrtin
admrtin deleted the amm/network-traits branch August 20, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants