Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add traffic congestion segments to the main Route #292

Closed
engali94 opened this issue Oct 8, 2024 · 1 comment
Closed

Add traffic congestion segments to the main Route #292

engali94 opened this issue Oct 8, 2024 · 1 comment

Comments

@engali94
Copy link
Contributor

engali94 commented Oct 8, 2024

This approach involves:

  1. Adding a property or method to the main Route struct to retrieve congestion segments.
  2. Each adapter would be responsible for extracting and mapping its specific congestion data to a common format when converting from the adapter-specific route to the main Route.

Pros:

  • Keeps the congestion data close to the route data it belongs to.
  • Provides a unified interface for accessing congestion data across different adapters.

Cons:

  • Slightly increases the complexity of the core Route struct.

Proposed slution:

In ./ferrostar/src/models.rs

pub struct CongestionSegment {
    pub level: String,
    pub geometry: Vec<GeographicCoordinate>,
}
pub struct Route {
    // ... 
    congestion_segments: Option<Vec<CongestionSegment>>,
}

In ./ferrostar/src/routing_adapters/osrm/mod.rs

impl Route {
    pub fn from_osrm(
        route: &OsrmRoute,
        waypoints: &[OsrmWaypoint],
        polyline_precision: u32,
    ) -> Result<Self, ParsingError> {
        // ...

        let congestion_segments = extract_congestion_segments(route)?;

        Ok(Route {
            // ...
            congestion_segments: Some(congestion_segments),
        })
    }
}

fn extract_congestion_segments(route: &OsrmRoute) -> Result<Vec<CongestionSegment>, ParsingError> {
    // adapter-specific logic to extract and convert congestion data
}
@engali94
Copy link
Contributor Author

Closing in favor of #287

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

No branches or pull requests

1 participant