Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d04d4db
progress towards reading speeds
yamilbknsu Jan 2, 2026
0d3c24a
Merge branch 'main' into yep/edge-attributes
yamilbknsu Jan 6, 2026
e440964
Fix to geometry wkb codec
yamilbknsu Jan 8, 2026
bc89911
fix speed computation
yamilbknsu Jan 8, 2026
4e27f1d
checkpoint: incorporate heading into SegmentSplit
robfitzgerald Jan 9, 2026
5d92c7a
directed graph
robfitzgerald Jan 13, 2026
e9a1363
use serde_bytes
robfitzgerald Jan 13, 2026
39c69ff
cargo sort
robfitzgerald Jan 13, 2026
167ed3c
update fieldname
robfitzgerald Jan 13, 2026
5b06318
cargo clippy fix
robfitzgerald Jan 13, 2026
d3cb598
order important
robfitzgerald Jan 13, 2026
d0abfe0
splits for each heading; heading edge cases
robfitzgerald Jan 13, 2026
6351d15
remove debug
robfitzgerald Jan 13, 2026
da6c390
fmt + clippy
robfitzgerald Jan 13, 2026
863977b
class retrieval and class-based speed filling
yamilbknsu Jan 13, 2026
1bd04fd
small optimization
yamilbknsu Jan 13, 2026
895fe18
clippy
yamilbknsu Jan 13, 2026
e341469
collision between heading and no heading restrictions
robfitzgerald Jan 13, 2026
8eaa2b9
added tests covering heading-specific vs blanket access restrictions
robfitzgerald Jan 13, 2026
80f93dc
cargo clippy
robfitzgerald Jan 13, 2026
794bc41
unify segment full type naming
yamilbknsu Jan 14, 2026
c3b40e2
documented and renamed `check_open_intersection`
yamilbknsu Jan 14, 2026
7190885
another intersection rename
yamilbknsu Jan 14, 2026
6ca8d26
doctest
yamilbknsu Jan 14, 2026
1145772
docstrings
yamilbknsu Jan 14, 2026
5dc4aa4
`meters` is the default Haversine unit
yamilbknsu Jan 14, 2026
c05a7a2
fmt
yamilbknsu Jan 14, 2026
f1b2f13
add comment about order
robfitzgerald Jan 15, 2026
a9909b6
remove debug stub
robfitzgerald Jan 15, 2026
af7f2e0
clippy
robfitzgerald Jan 15, 2026
6d048af
remove parenthesis
yamilbknsu Jan 15, 2026
9c2b18e
Merge branch 'yep/edge-attributes' into rjf/directed-graph-merge
robfitzgerald Jan 16, 2026
a68ab28
already a vec
robfitzgerald Jan 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions configuration/bambam-omf/travel-mode-filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"type": "class",
"classes": ["secondary", "tertiary", "residential", "living_street", "unclassified", "service", "pedestrian", "footway", "steps", "path", "track", "bridleway", "unknown"],
"ignore_unset": true,
"allow_unset": true,
"behavior": "include"
},
{ "type": "access_mode", "modes": ["foot"] }
Expand All @@ -20,7 +20,7 @@
{
"type": "class",
"classes": ["primary", "secondary", "tertiary", "residential", "living_street", "unclassified", "service", "pedestrian", "path", "track", "cycleway", "bridleway", "unknown"],
"ignore_unset": true,
"allow_unset": true,
"behavior": "include"
},
{ "type": "access_mode", "modes": ["bicycle"] }
Expand All @@ -33,7 +33,7 @@
{
"type": "class",
"classes": ["motorway", "trunk", "primary", "secondary", "tertiary", "residential", "living_street", "unclassified", "service", "unknown"],
"ignore_unset": true,
"allow_unset": true,
"behavior": "include"
},
{ "type": "access_mode", "modes": ["motor_vehicle", "car", "truck", "motorcycle"] }
Expand Down
32 changes: 20 additions & 12 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
[workspace]
resolver = "2"
members = ["bambam", "bambam-osm", "bambam-gtfs", "bambam-omf", "bambam-gbfs", "bambam-py"]
members = [
"bambam",
"bambam-gbfs",
"bambam-gtfs",
"bambam-omf",
"bambam-osm",
"bambam-py",
]

[workspace.dependencies]

# third party
arrow = { version = "55.0.0" }
bamcensus = { version = "0.1.0" }
bamcensus-acs = { version = "0.1.0" }

# nrel
bamcensus-core = { version = "0.1.0" }
bamcensus-acs = { version = "0.1.0" }
bamcensus = { version = "0.1.0" }
bamcensus-lehd = { version = "0.1.0" }
routee-compass = "0.15.2"
routee-compass-core = "0.15.2"
routee-compass-powertrain = "0.15.2"
routee-compass-py = "0.15.2"
routee-compass-macros = "0.15.2"

# third party
arrow = { version = "55.0.0" }
chrono = { version = "0.4.41", features = ["serde"] }
clap = { version = "4.3.19", features = ["derive"] }
config = "0.15.11"
Expand Down Expand Up @@ -51,10 +53,16 @@ rand = "0.9.1"
rayon = "1.10.0"
regex = { version = "1.11.1" }
reqwest = { version = "0.12.12", features = ["blocking"] }
routee-compass = "0.15.2"
routee-compass-core = "0.15.2"
routee-compass-macros = "0.15.2"
routee-compass-powertrain = "0.15.2"
routee-compass-py = "0.15.2"
rstar = { version = "0.12.0" }
serde = { version = "1.0.160", features = ["derive"] }
serde_json = { version = "1.0" }
serde_arrow = { version = "0.13.7", features = ["arrow-55"] }
serde_bytes = { version = "0.11.19" }
serde_json = { version = "1.0" }
serde_with = { version = "3.0", features = ["chrono_0_4"] }
shapefile = { version = "0.7.0", features = ["geo-types"] }
skiplist = "0.5.1"
Expand Down
14 changes: 7 additions & 7 deletions rust/bambam-gbfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ license = "BSD-3-Clause"
description = "GBFS Extensions for The Behavior and Advanced Mobility Big Access Model"

[dependencies]
chrono = { workspace = true }
clap = { workspace = true }
env_logger = { workspace = true }
geo = { workspace = true }
humantime = { workspace = true }
kdam = { workspace = true }
log = { workspace = true }
reqwest = { workspace = true }
routee-compass-core = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_with = { workspace = true }
chrono = { workspace = true }
humantime = { workspace = true }
log = { workspace = true }
geo = { workspace = true }
reqwest = { workspace = true }
clap = { workspace = true }
kdam = { workspace = true }
21 changes: 11 additions & 10 deletions rust/bambam-omf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ keywords = [
categories = ["command-line-utilities", "science", "science::geo"]

[dependencies]
bamcensus-core = { workspace = true }
bamcensus-acs = { workspace = true }
bamcensus-lehd = { workspace = true }
bamcensus = { workspace = true }
routee-compass = { workspace = true }
routee-compass-core = { workspace = true }
routee-compass-powertrain = { workspace = true }

arrow = { workspace = true }
bamcensus = { workspace = true }
bamcensus-acs = { workspace = true }
bamcensus-core = { workspace = true }
bamcensus-lehd = { workspace = true }
chrono = { workspace = true }
clap = { workspace = true }
config = { workspace = true }
Expand All @@ -41,16 +38,20 @@ itertools = { workspace = true }
kdam = { workspace = true }
log = { workspace = true }
object_store = { workspace = true }
parquet = { workspace = true }
opening-hours-syntax = { workspace = true }
ordered-float = { workspace = true }
parquet = { workspace = true }
rayon = { workspace = true }
reqwest = { workspace = true }
routee-compass = { workspace = true }
routee-compass-core = { workspace = true }
routee-compass-powertrain = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_arrow = { workspace = true }
serde_bytes = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
uom = { workspace = true }
wkt = { workspace = true }
wkb = { workspace = true }
wkt = { workspace = true }
17 changes: 16 additions & 1 deletion rust/bambam-omf/src/app/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use crate::{
app::CliBoundingBox,
collection::{
filter::TravelModeFilter, ObjectStoreSource, OvertureMapsCollectionError,
OvertureMapsCollectorConfig, ReleaseVersion, TransportationCollection,
OvertureMapsCollectorConfig, ReleaseVersion, SegmentAccessRestrictionWhen,
TransportationCollection,
},
graph::OmfGraphVectorized,
util,
Expand All @@ -18,6 +19,20 @@ pub struct NetworkEdgeListConfiguration {
pub filter: Vec<TravelModeFilter>,
}

impl From<&NetworkEdgeListConfiguration> for SegmentAccessRestrictionWhen {
fn from(value: &NetworkEdgeListConfiguration) -> Self {
let user_modes_opt = value.filter.iter().find_map(|f| match f {
TravelModeFilter::MatchesModeAccess { modes } => Some(modes.clone()),
_ => None,
});
let mut result = SegmentAccessRestrictionWhen::default();
if let Some(modes) = user_modes_opt {
result.mode = Some(modes);
}
result
}
}

/// runs an OMF network import using the provided configuration.
pub fn run(
bbox: Option<&CliBoundingBox>,
Expand Down
4 changes: 4 additions & 0 deletions rust/bambam-omf/src/collection/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ pub enum OvertureMapsCollectionError {
ReadError { path: PathBuf, message: String },
#[error("Error writing to '{path}': {message}")]
WriteError { path: PathBuf, message: String },
#[error("Invalid `between` vector: {0}")]
InvalidBetweenVector(String),
#[error("Required attribute is None: {0}")]
MissingAttribute(String),
#[error("{0}")]
InternalError(String),
}
18 changes: 11 additions & 7 deletions rust/bambam-omf/src/collection/filter/travel_mode_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ pub enum TravelModeFilter {
MatchesClasses {
classes: HashSet<SegmentClass>,
behavior: MatchBehavior,
ignore_unset: bool,
allow_unset: bool,
},
/// filter a row based on a class with additional subclass(es). fails if not a match,
/// and optionally, if 'class' or 'subclass' are unset.
#[serde(rename = "class_with_subclasses")]
MatchesClassesWithSubclasses {
classes: HashMap<SegmentClass, Vec<SegmentSubclass>>,
behavior: MatchBehavior,
ignore_unset: bool,
allow_unset: bool,
},

/// filter a row based on the [SegmentMode].
Expand Down Expand Up @@ -145,35 +145,39 @@ impl TravelModeFilter {
/// returns false if there is no match.
pub fn matches_filter(&self, segment: &TransportationSegmentRecord) -> bool {
match self {
// subtype matching. default behavior is REJECT
TravelModeFilter::MatchesSubtype { subtype } => segment
.subtype
.as_ref()
.map(|s| s == subtype)
.unwrap_or_default(),

// class matching. default behavior set by user (allow_unset).
TravelModeFilter::MatchesClasses {
classes,
behavior,
ignore_unset,
allow_unset,
} => segment
.class
.as_ref()
.map(|c| behavior.apply(classes.contains(c)))
.unwrap_or(*ignore_unset),
.unwrap_or(*allow_unset),

// subclass matching. default behavior set by user (allow_unset).
TravelModeFilter::MatchesClassesWithSubclasses {
classes,
behavior,
ignore_unset,
allow_unset,
} => match (segment.class.as_ref(), segment.subclass.as_ref()) {
(Some(cl), None) => behavior.apply(classes.contains_key(cl)),
(Some(cl), Some(sc)) => match classes.get(cl) {
None => *ignore_unset,
None => *allow_unset,
Some(subclasses) => behavior.apply(subclasses.contains(sc)),
},
_ => *ignore_unset,
_ => *allow_unset,
},

// mode matching. default behavior is ALLOW
TravelModeFilter::MatchesModeAccess { modes } => {
let restrictions = segment
.access_restrictions
Expand Down
6 changes: 4 additions & 2 deletions rust/bambam-omf/src/collection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ mod collector;
mod collector_config;
mod error;
mod object_source;
mod record;
mod taxonomy;
mod version;

pub mod constants;
pub mod filter;
pub mod record;

pub use collector::OvertureMapsCollector;
pub use collector_config::OvertureMapsCollectorConfig;
Expand All @@ -17,7 +17,9 @@ pub use filter::RowFilter;
pub use filter::RowFilterConfig;
pub use object_source::ObjectStoreSource;
pub use record::{
BuildingsRecord, OvertureRecord, OvertureRecordType, PlacesRecord, TransportationCollection,
BuildingsRecord, OvertureRecord, OvertureRecordType, PlacesRecord,
SegmentAccessRestrictionWhen, SegmentClass, SegmentFullType, SegmentSpeedLimit,
SegmentSpeedUnit, SegmentSubclass, SegmentSubtype, TransportationCollection,
TransportationConnectorRecord, TransportationSegmentRecord,
};
pub use taxonomy::{TaxonomyModel, TaxonomyModelBuilder};
Expand Down
8 changes: 4 additions & 4 deletions rust/bambam-omf/src/collection/record/common.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct OvertureMapsBbox {
xmin: Option<f32>,
xmax: Option<f32>,
ymin: Option<f32>,
ymax: Option<f32>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct OvertureMapsSource {
property: Option<String>,
dataset: Option<String>,
Expand All @@ -18,14 +18,14 @@ pub struct OvertureMapsSource {
confidence: Option<f64>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct OvertureMapsNames {
primary: Option<String>,
common: Option<HashMap<String, Option<String>>>,
rules: Option<Vec<OvertureMapsNamesRule>>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
struct OvertureMapsNamesRule {
variant: Option<String>,
language: Option<String>,
Expand Down
7 changes: 5 additions & 2 deletions rust/bambam-omf/src/collection/record/geometry_wkb_codec.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use geo::{Geometry, MapCoords, TryConvert};
use geozero::{error::GeozeroError, wkb::Wkb, ToGeo};
use serde::{Deserialize, Deserializer};
use serde_bytes;

// Deserialize into an enum that can handle both Vec<u8> and String
/// Deserialize into an enum that can handle both String and Vec<u8>, in
/// that order.
#[derive(Deserialize)]
#[serde(untagged)]
enum BytesOrString {
Bytes(Vec<u8>),
String(String),
#[serde(with = "serde_bytes")]
Bytes(Vec<u8>),
}

impl std::fmt::Display for BytesOrString {
Expand Down
12 changes: 7 additions & 5 deletions rust/bambam-omf/src/collection/record/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ pub use record_type::OvertureRecordType;
pub use transportation_collection::TransportationCollection;
pub use transportation_connector::TransportationConnectorRecord;
pub use transportation_segment::{
SegmentAccessRestriction, SegmentAccessType, SegmentClass, SegmentHeading, SegmentMode,
SegmentSubclass, SegmentSubtype, TransportationSegmentRecord,
SegmentAccessRestriction, SegmentAccessRestrictionWhen, SegmentAccessType, SegmentClass,
SegmentDestination, SegmentFullType, SegmentHeading, SegmentMode, SegmentRecognized,
SegmentSpeedLimit, SegmentSpeedUnit, SegmentSubclass, SegmentSubtype, SegmentUsing,
TransportationSegmentRecord,
};

// Common structs and functions for many record types
use common::OvertureMapsBbox;
use common::OvertureMapsNames;
use common::OvertureMapsSource;
pub use common::OvertureMapsBbox;
pub use common::OvertureMapsNames;
pub use common::OvertureMapsSource;
pub mod geometry_wkb_codec;
Loading
Loading