Skip to content

Implementation of traffic data integration with Valhalla routing engine for Careem's food delivery platform in Amman, featuring OSM data processing and distance validations with OSRM

License

Notifications You must be signed in to change notification settings

muhammadazzazy/osm-valhalla-traffic-mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Valhalla Traffic Integration for Careem

Overview

A Python-based solution for integrating historical traffic data with Valhalla's routing engine to improve ETA accuracy for Careem's ride-hailing platform in Amman, Jordan. This implementation enhances Valhalla's routing capabilities without modifying its core C++ codebase.

Prerequisites

  • Python 3.x
  • Osmium Tool
  • Valhalla routing engine
  • OSRM (for validation)

Setup and Configuration

Installing Valhalla

Follow the gis-ops guide for installing Valhalla on Ubuntu.

Running Valhalla

For basic Valhalla configuration and running instructions, see the gis-ops guide for running Valhalla.

Project-Specific Setup

After installing and configuring Valhalla:

  1. Clone the repository:
    git clone https://github.com/muhammadazzazy/osm-valhalla-traffic-mapper.git
    cd osm-valhalla-traffic-mapper
  2. Download Jordan OSM data:
    ./scripts/download_jordan_osm.sh
  3. Extract Amman region:
    ./scripts/extract_amman_data.sh

Project Structure

osm-valhalla-traffic-mapper/
├── src/
│   ├── routes.py                 # OSRM vs Valhalla distance comparison logic
│   ├── graph_id.py               # Python implementation of the to_string functionality provided by Valhalla
│   ├── predicted_speeds.py       # Historical speeds conversion to DCT-II functionality
│   ├── main.py                   # Traffic CSV file preparation and writing utilities 
│   ├── get_etas.py               # Valhalla ETA extraction functionality
│   ├── speeds_checker.py         # Speed-limit violation validator
│   ├── speeds_extractor.py       # Speed data extraction from JSON
│   └── valhalla_way_id_mapper.py # OSM way ID mapping tools
│   └── valhalla_monitor.py       # Traffic CSV monitoring for automating updates to routing graph
├── scripts/
│   ├── download_jordan_osm.sh    # Script to download Jordan OSM data
│   └── extract_amman_data.sh     # Script to extract Amman region data using Osmium

Source Files (src/)

Route Processing

  • routes.py: Validates routing accuracy by comparing Valhalla and OSRM distance calculations
  • get_etas.py: Extracts and processes ETAs from Valhalla
  • graph_id.py: Handles Valhalla graph ID conversion and processing

Speed Data Management

  • predicted_speeds.py: Converts historical speed data using DCT-II functionality
  • speeds_checker.py: Validates speed data against Jordan's traffic regulations
  • speeds_extractor.py: Extracts speed data from JSON format

Data Integration

  • main.py: Prepares and writes traffic CSV files
  • valhalla_way_id_mapper.py: Maps OSM way IDs to coordinates

Scripts (scripts/)

  • download_jordan_osm.sh: Downloads latest Jordan OSM data
  • extract_amman_data.sh: Extracts Amman-specific region using Osmium

Core Components

Routing System Integration

The system integrates with Valhalla through:

  • Graph ID conversion matching Valhalla's internal format
  • OSM way ID mapping for coordinate pairs
  • Batch processing support for routing requests

Traffic Data Processing

Processes historical traffic data to enhance ETA accuracy:

  • Processes 2016 weekly speed patterns (5-minute intervals)
  • Extracts day/night speed variations
  • Validates against local speed limits
  • Prepares data in Valhalla-compatible format

Contributing

Contributions welcome via pull requests.

Acknowledgments

  • OpenStreetMap contributors
  • Valhalla and OSRM teams

About

Implementation of traffic data integration with Valhalla routing engine for Careem's food delivery platform in Amman, featuring OSM data processing and distance validations with OSRM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published