Skip to content

Commit e650c08

Browse files
Merge pull request #303 from NREL/rjf/dependencies-bump
Rjf/dependencies bump
2 parents b6c52ed + cf9e4b4 commit e650c08

File tree

8 files changed

+67
-56
lines changed

8 files changed

+67
-56
lines changed

rust/Cargo.toml

+17-16
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,27 @@ members = [
99
]
1010

1111
[workspace.dependencies]
12-
serde = { version = "1.0.209", features = ["derive"] }
13-
serde_json = { version = "1.0.133", features = ["preserve_order"] }
12+
serde = { version = "1.0.219", features = ["derive"] }
13+
serde_json = { version = "1.0.140", features = ["preserve_order"] }
1414
rayon = "1.10.0"
15-
geo = { version = "0.29.3", features = ["use-serde"] }
16-
geo-types = "0.7.14"
17-
geojson = { version = "0.24.1" }
15+
geo = { version = "0.30.0", features = ["use-serde"] }
16+
geo-traits = "0.2.0"
17+
geo-types = "0.7.16"
18+
geojson = { version = "0.24.2" }
1819
rstar = "0.12.2"
19-
thiserror = "2.0.7"
20-
flate2 = "1.0.35"
20+
thiserror = "2.0.12"
21+
flate2 = "1.1.1"
2122
kdam = "0.6.2"
22-
log = "0.4.22"
23-
env_logger = "0.11.5"
23+
log = "0.4.27"
24+
env_logger = "0.11.8"
2425
csv = { version = "1.3.1" }
25-
itertools = { version = "0.13.0" }
26-
chrono = "0.4.39"
26+
itertools = { version = "0.14.0" }
27+
chrono = "0.4.40"
2728
regex = "1.11.1"
2829
wkt = { version = "0.12.0", features = ["serde"] }
29-
wkb = "0.7.1"
30-
config = "0.14.1"
31-
ordered-float = { version = "4.5.0", features = ["serde"] }
30+
wkb = "0.8.0"
31+
config = "0.15.11"
32+
ordered-float = { version = "5.0.0", features = ["serde"] }
3233
allocative = "0.3.4"
33-
indoc = "2.0.5"
34-
derive_more = { version = "1.0.0", features = ["full"] }
34+
indoc = "2.0.6"
35+
derive_more = { version = "2.0.1", features = ["full"] }

rust/routee-compass-core/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ rayon = { workspace = true }
1717
thiserror = { workspace = true }
1818
flate2 = { workspace = true }
1919
geo = { workspace = true }
20+
geo-traits = { workspace = true }
2021
ordered-float = { workspace = true }
2122
derive_more = { workspace = true }
2223
priority-queue = "2.0.2"
23-
lru = "0.12"
24+
lru = "0.14.0"
2425
csv = { workspace = true }
2526
kdam = { workspace = true }
2627
log = { workspace = true }

rust/routee-compass-core/src/util/geo/geo_io_utils.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use geo::{Coord, CoordsIter, LineString, Point};
2+
use geo_traits::to_geo::ToGeoGeometry;
23
use itertools::Itertools;
34
use wkb;
45
use wkt::{ToWkt, TryFromWkt};
@@ -113,14 +114,13 @@ pub fn parse_wkt_linestring(_idx: usize, row: String) -> Result<LineString<f32>,
113114
}
114115

115116
pub fn parse_wkb_linestring(_idx: usize, row: String) -> Result<LineString<f32>, std::io::Error> {
116-
let mut c = row.as_bytes();
117-
let geom = wkb::wkb_to_geom(&mut c).map_err(|e| {
118-
let msg = format!("failure decoding WKB string: {:?}", e);
119-
std::io::Error::new(std::io::ErrorKind::InvalidData, msg)
120-
})?;
121-
match geom {
117+
let geom = wkb::reader::read_wkb(row.as_bytes())
118+
.map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidData, e.to_string()))?;
119+
120+
match geom.to_geometry() {
122121
geo::Geometry::LineString(l) => {
123-
// somewhat hackish solution since we cannot choose f32 when parsing wkbs
122+
// somewhat hackish solution since we cannot choose f32 when parsing wkbs and
123+
// geo::Convert does not support f64 -> f32, for good reason of course
124124
let coords32 =
125125
l.0.into_iter()
126126
.map(|c| Coord {
@@ -131,10 +131,10 @@ pub fn parse_wkb_linestring(_idx: usize, row: String) -> Result<LineString<f32>,
131131
let l32 = LineString::new(coords32);
132132
Ok(l32)
133133
}
134-
_ => {
134+
g => {
135135
let msg = format!(
136136
"decoded WKB expected to be linestring, found: {}",
137-
geom.to_wkt()
137+
g.to_wkt()
138138
);
139139
Err(std::io::Error::new(std::io::ErrorKind::InvalidData, msg))
140140
}

rust/routee-compass-powertrain/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ documentation = "https://docs.rs/routee-compass"
1212

1313
[dependencies]
1414
routee-compass-core = { path = "../routee-compass-core", version = "0.9.1" }
15-
smartcore = { version = "0.3.1", features = ["serde"] } # random forest
15+
smartcore = { version = "0.4.0", features = ["serde"] } # random forest
1616
thiserror = { workspace = true }
1717
log = { workspace = true }
1818
geo = { workspace = true }
1919
kdam = { workspace = true }
20-
bincode = "1.3.3"
20+
bincode = { version = "2.0.1", features = ["serde"] }
2121
env_logger = { workspace = true }
2222
serde = { workspace = true, features = ["derive"] }
2323
serde_repr = "0.1"
2424
serde_json = { workspace = true }
2525
ordered-float = { workspace = true }
2626
ndarray = "0.16.1"
27-
ort = { version = "2.0.0-alpha.4", optional = true }
27+
ort = { version = "2.0.0-rc.9", optional = true }
2828
rayon = { workspace = true }
2929
itertools = { workspace = true }
3030
ninterp = { version = "0.1.0", features = ["serde"] }

rust/routee-compass-powertrain/src/model/prediction/smartcore/smartcore_speed_grade_model.rs

+20-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use routee_compass_core::model::{
66
use smartcore::{
77
ensemble::random_forest_regressor::RandomForestRegressor, linalg::basic::matrix::DenseMatrix,
88
};
9-
use std::{borrow::Cow, path::Path};
9+
use std::{borrow::Cow, fs::File, path::Path};
1010

1111
pub struct SmartcoreSpeedGradeModel {
1212
rf: RandomForestRegressor<f64, f64, DenseMatrix<f64>, Vec<f64>>,
@@ -27,7 +27,13 @@ impl PredictionModel for SmartcoreSpeedGradeModel {
2727
let mut grade_value = Cow::Owned(grade);
2828
speed_unit.convert(&mut speed_value, &self.speed_unit)?;
2929
grade_unit.convert(&mut grade_value, &self.grade_unit)?;
30-
let x = DenseMatrix::from_2d_vec(&vec![vec![speed_value.as_f64(), grade_value.as_f64()]]);
30+
let x = DenseMatrix::from_2d_vec(&vec![vec![speed_value.as_f64(), grade_value.as_f64()]])
31+
.map_err(|e| {
32+
TraversalModelError::TraversalModelFailure(format!(
33+
"unable to set up prediction input vector: {}",
34+
e
35+
))
36+
})?;
3137
let y = self.rf.predict(&x).map_err(|e| {
3238
TraversalModelError::TraversalModelFailure(format!(
3339
"failure running underlying Smartcore random forest energy prediction: {}",
@@ -47,22 +53,23 @@ impl SmartcoreSpeedGradeModel {
4753
grade_unit: GradeUnit,
4854
energy_rate_unit: EnergyRateUnit,
4955
) -> Result<Self, TraversalModelError> {
50-
// Load random forest binary file
51-
let rf_binary = std::fs::read(routee_model_path).map_err(|e| {
56+
let mut file = File::open(routee_model_path).map_err(|e| {
5257
TraversalModelError::BuildError(format!(
53-
"failure reading smartcore binary text file {} due to {}",
54-
routee_model_path.as_ref().to_str().unwrap_or_default(),
58+
"failure opening file {}: {}",
59+
routee_model_path.as_ref().to_string_lossy(),
5560
e
5661
))
5762
})?;
5863
let rf: RandomForestRegressor<f64, f64, DenseMatrix<f64>, Vec<f64>> =
59-
bincode::deserialize(&rf_binary).map_err(|e| {
60-
TraversalModelError::BuildError(format!(
61-
"failure deserializing smartcore model {} due to {}",
62-
routee_model_path.as_ref().to_str().unwrap_or_default(),
63-
e
64-
))
65-
})?;
64+
bincode::serde::decode_from_std_read(&mut file, bincode::config::legacy()).map_err(
65+
|e| {
66+
TraversalModelError::BuildError(format!(
67+
"failure deserializing smartcore model {} due to {}",
68+
routee_model_path.as_ref().to_str().unwrap_or_default(),
69+
e
70+
))
71+
},
72+
)?;
6673
Ok(SmartcoreSpeedGradeModel {
6774
rf,
6875
speed_unit,

rust/routee-compass/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ serde = { workspace = true, features = ["derive"] }
2626
serde_json = { workspace = true }
2727
csv = { workspace = true }
2828
geo = { workspace = true }
29+
geo-traits = { workspace = true }
2930
geo-types = { workspace = true }
3031
geojson = { workspace = true }
3132
rstar = { workspace = true }
@@ -36,7 +37,7 @@ kdam = { workspace = true }
3637
log = { workspace = true }
3738
rayon = { workspace = true }
3839
serde_repr = "0.1"
39-
rand = "0.8.5"
40+
rand = "0.9.0"
4041
chrono = { workspace = true }
4142
config = { workspace = true }
4243
clap = { version = "4.3.19", features = ["derive"] }

rust/routee-compass/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
match run::command_line_runner(&args, Some(builder), None) {
1313
Ok(_) => {}
1414
Err(e) => {
15-
error!("{}", e.to_string())
15+
error!("{}", e)
1616
}
1717
}
1818
}

rust/routee-compass/src/plugin/output/default/traversal/traversal_output_format.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{collections::HashMap, sync::Arc};
22

33
use super::traversal_ops as ops;
44
use crate::plugin::output::OutputPluginError;
5-
use geo::{CoordFloat, Geometry};
5+
use geo::{CoordFloat, Geometry, TryConvert};
66
use routee_compass_core::{
77
algorithm::search::{EdgeTraversal, SearchTreeBranch},
88
model::{map::MapModel, network::vertex_id::VertexId},
@@ -100,18 +100,19 @@ impl TraversalOutputFormat {
100100
fn geometry_to_wkb_string<T: CoordFloat + Into<f64>>(
101101
geometry: &Geometry<T>,
102102
) -> Result<String, OutputPluginError> {
103-
let bytes = wkb::geom_to_wkb(geometry).map_err(|e| {
104-
OutputPluginError::OutputPluginFailed(format!(
105-
"failed to generate wkb for geometry '{:?}' - {:?}",
106-
geometry, e
107-
))
103+
let mut out_bytes = vec![];
104+
let geom: Geometry<f64> = geometry.try_convert().map_err(|e| {
105+
OutputPluginError::OutputPluginFailed(format!("unable to convert geometry to f64: {}", e))
108106
})?;
109-
let wkb_str = bytes
110-
.iter()
111-
.map(|b| format!("{:02X?}", b))
112-
.collect::<Vec<String>>()
113-
.join("");
114-
Ok(wkb_str)
107+
wkb::writer::write_geometry(&mut out_bytes, &geom, wkb::Endianness::BigEndian).map_err(
108+
|e| {
109+
OutputPluginError::OutputPluginFailed(format!("failed to write geometry as WKB: {}", e))
110+
},
111+
)?;
112+
let out_string = String::from_utf8(out_bytes).map_err(|e| {
113+
OutputPluginError::OutputPluginFailed(format!("failed to read WKB as utf8: {}", e))
114+
})?;
115+
Ok(out_string)
115116
}
116117

117118
// #[cfg(test)]

0 commit comments

Comments
 (0)