Skip to content

Commit

Permalink
editoast: bump osm4routing from 0.6.3 to 0.6.5 in /editoast
Browse files Browse the repository at this point in the history
Bumps [osm4routing](https://github.com/Tristramg/osm4routing2) from 0.6.3 to 0.6.5.
- [Commits](https://github.com/Tristramg/osm4routing2/commits)

---
updated-dependencies:
- dependency-name: osm4routing
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
  • Loading branch information
dependabot[bot] authored and woshilapin committed Jul 5, 2024
1 parent 37587e4 commit 725b89a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
5 changes: 3 additions & 2 deletions editoast/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion editoast/osm_to_railjson/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ license = "LGPL-3.0"

[dependencies]
editoast_schemas.workspace = true
geo-types = "0.7.13"
geos.workspace = true
osm4routing = "0.6.1"
osm4routing = "0.6.5"
osmpbfreader = "0.16.1"
serde_json.workspace = true
tracing.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion editoast/osm_to_railjson/src/osm_to_railjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn parse_osm(osm_pbf_in: PathBuf) -> Result<RailJson, Box<dyn Error + Send +
railjson.track_sections = rail_edges
.map(|e| {
let geo = geos::geojson::Geometry::new(geos::geojson::Value::LineString(
e.geometry.iter().map(|c| vec![c.lon, c.lat]).collect(),
e.geometry.iter().map(|c| vec![c.x, c.y]).collect(),
));
TrackSection {
id: e.id.as_str().into(),
Expand Down
31 changes: 15 additions & 16 deletions editoast/osm_to_railjson/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use editoast_schemas::infra::SpeedSection;
use editoast_schemas::infra::Switch;
use editoast_schemas::infra::TrackEndpoint;
use editoast_schemas::primitives::Identifier;
use osm4routing::Coord;
use geo_types::Coord;
use osm4routing::Distance;
use osm4routing::Edge;
use osm4routing::NodeId;
use osmpbfreader::Node;
Expand Down Expand Up @@ -181,9 +182,7 @@ pub fn double_slip_switch(node: NodeId, branches: &[Branch]) -> Switch {

// Computes the angle betwen the segments [oa] and [ob]
pub fn angle(o: Coord, a: Coord, b: Coord) -> f64 {
((a.lat - o.lat).atan2(a.lon - o.lon).to_degrees()
- (b.lat - o.lat).atan2(b.lon - o.lon).to_degrees())
.abs()
((a.y - o.y).atan2(a.x - o.x).to_degrees() - (b.y - o.y).atan2(b.x - o.x).to_degrees()).abs()
}

fn direction(node: &osmpbfreader::Node) -> Direction {
Expand Down Expand Up @@ -500,7 +499,7 @@ fn identifier(tags: &osmpbfreader::Tags) -> Option<OperationalPointIdentifierExt

#[cfg(test)]
mod tests {
use osm4routing::Coord;
use geo_types::Coord;
use rstest::rstest;

use super::*;
Expand All @@ -510,9 +509,9 @@ mod tests {
/* b
. | 90 °
. o–––––a */
let o = Coord { lon: 0.0, lat: 0.0 };
let a = Coord { lon: 1.0, lat: 0.0 };
let b = Coord { lon: 0.0, lat: 1.0 };
let o = Coord { x: 0.0, y: 0.0 };
let a = Coord { x: 1.0, y: 0.0 };
let b = Coord { x: 0.0, y: 1.0 };
assert_eq!(90.0, angle(o, a, b).round());
}

Expand All @@ -529,26 +528,26 @@ mod tests {
fn test_reference_coord() {
let edge = Edge {
nodes: vec![NodeId(0), NodeId(1)],
geometry: vec![Coord { lon: 0., lat: 0. }, Coord { lon: 1., lat: 1. }],
geometry: vec![Coord { x: 0., y: 0. }, Coord { x: 1., y: 1. }],
..Default::default()
};
assert_eq!(1., reference_coord(NodeId(0), &edge).lon);
assert_eq!(0., reference_coord(NodeId(1), &edge).lon);
assert_eq!(1., reference_coord(NodeId(0), &edge).x);
assert_eq!(0., reference_coord(NodeId(1), &edge).x);
}

#[test]
fn test_reference_coord_overlapping_nodes() {
let edge = Edge {
nodes: vec![NodeId(0), NodeId(1), NodeId(2)],
geometry: vec![
Coord { lon: 0., lat: 0. },
Coord { lon: 0., lat: 0. },
Coord { lon: 1., lat: 1. },
Coord { x: 0., y: 0. },
Coord { x: 0., y: 0. },
Coord { x: 1., y: 1. },
],
..Default::default()
};
assert_eq!(1., reference_coord(NodeId(0), &edge).lon);
assert_eq!(0., reference_coord(NodeId(2), &edge).lon);
assert_eq!(1., reference_coord(NodeId(0), &edge).x);
assert_eq!(0., reference_coord(NodeId(2), &edge).x);
}

#[rstest]
Expand Down

0 comments on commit 725b89a

Please sign in to comment.