Skip to content

Conversation

@sandervandermaar-tomtom
Copy link
Collaborator

@sandervandermaar-tomtom sandervandermaar-tomtom commented Sep 29, 2025

Implement conversion of Overture access restrictions to Valhalla arcs.

  • Add "overture-access-restriction-splitter" crate to contain new logic
  • Use already defined Overture types instead of ones introduced for loading of Overture data
  • Add tests for splitting logic
  • Document splitting logic

@sandervandermaar-tomtom sandervandermaar-tomtom marked this pull request as ready for review October 23, 2025 12:42
Copy link
Collaborator

@brad-richardson brad-richardson left a comment

Choose a reason for hiding this comment

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

Great work! A few minor thoughts


/// Compares two floating point numbers with a small tolerance
fn fuzzy_compare(a: f64, b: f64) -> bool {
// less than one centimeter at equator
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you elaborate on this a bit? We're assuming everything is in our original WGS84 projection, etc right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this go in a shared utility?

fuzzy_compare(c1.x, c2.x) && fuzzy_compare(c1.y, c2.y)
}

/// Removes duplicate start and end points from a LineString, while ensuring at least two points remain
Copy link
Collaborator

Choose a reason for hiding this comment

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

How common is this in your testing? I think most of these duplicate coords should be fixed upstream

Copy link
Collaborator

Choose a reason for hiding this comment

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

but it may also be only repairing two consecutive duplicate coords, so 3+ might slip through

for i in 1..segment.geometry.0.len() {
let p1 = &segment.geometry.0[i - 1];
let p2 = &segment.geometry.0[i];
let segment_length = ((p2.y - p1.y).powi(2) + (p2.x - p1.x).powi(2)).sqrt();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This probably works for most cases, but at global scale, we'll need to have a more robust length calculation. We spent quite a bit of time working through issues on this for the splitter: https://github.com/OvertureMaps/transportation-splitter/blob/main/transportation_splitter.py#L608

}

/// Aproximates the length of the segment by summing the distances between its points
fn calc_segment_length(segment: Segment) -> f64
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, this probably works for most cases, but the connector at values won't always match

road_class = Some(class.to_string());
}
} else if column.0 == "access_restrictions" {
let restrictions = column.1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we extract this to its own function? There's a lot going on here

geo_types::Coord { x: 1.0, y: 0.0 },
geo_types::Coord { x: 2.0, y: 0.0 },
geo_types::Coord { x: 3.0, y: 0.0 },
geo_types::Coord { x: 4.0, y: 0.0 },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice, thanks for adding tests. May want to add one or two more that have more complex "real-world" data, ideally directly from production data for the connector LR values to test projection mismatches


// Loop while there are access restrictions to process
while !remaining_segment.properties.access_restrictions.as_ref().unwrap().is_empty() {
let length = calc_segment_length(remaining_segment.clone());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the clone necessary here?

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