Skip to content
/ Kmap Public

Delivery drivers in Phnom Penh lose fifteen to twenty-five percent of their workday due to one-way streets and detours. Using local open data and a lightweight Flask engine, Kmap can quickly determine the fastest route with just one click. This led to more deliveries, less fuel consumption, and easier navigation in Khmer for drivers.

Notifications You must be signed in to change notification settings

KosolCHOU/Kmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kmap Phnom Penh Route Planner

An interactive Flask application that lets you plan routes across Phnom Penh on top of OpenStreetMap data. The backend assembles and caches the city road network with OSMnx/NetworkX, while the frontend renders a mobile-friendly Leaflet interface with address search, live geolocation and multiple vehicle profiles.

Highlights

  • Interactive Leaflet map with draggable markers, Nominatim-powered address search, and location autofill.
  • Multiple vehicle presets (motorbike, car, tuk-tuk, bicycle) that apply different travel-time heuristics.
  • Ranked alternative routes with distance and ETA summaries rendered in a glassmorphic side panel optimised for desktop and mobile.
  • Graph caching on disk so the OpenStreetMap network is downloaded only once.
  • Clean separation between Flask endpoints, routing helpers, and static assets.

Prerequisites

  • Python 3.11 or newer (3.10+ should work but is not regularly tested).
  • System packages required by osmnx and shapely (for example geos, proj, libspatialindex, rtree on many Linux distributions).
  • Internet access on the first run so the OSM road graph and Nominatim search results can be fetched.

Quick Start

# 1. Create and activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate

# 2. Install dependencies
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

# 3. Run the development server
flask --app app --debug run

Open http://127.0.0.1:5000 in your browser. The first route request may take a minute while OSMnx downloads and caches the Phnom Penh road graph to kmap/cache/graph_pp.graphml.

Usage Tips

  1. Choose a starting point by typing coordinates, selecting a search result, clicking the map, or using the “📍” button to read your device position.
  2. Search for a destination or tap the map to drop the target marker; the planner automatically computes up to three ranked routes.
  3. Switch vehicle types to re-run routing with different travel-time profiles.
  4. On mobile, collapse the planner panel with the toggle button to explore the map.

Project Structure

app.py                   Flask entrypoint exposing / and /route
kmap/routing.py          Road graph loading, caching, and route calculation
static/                  Leaflet map client (JavaScript, CSS)
templates/index.html     Main HTML shell
cache/, kmap/cache/      OSMNX HTTP cache and saved road graph
tests/                   Pytest scaffold (add tests here)

Testing

Activate your virtual environment and run:

pytest

Populate tests/ with unit or integration cases as you extend the planner.

Data & Attribution

Contributing

Issues and pull requests that improve routing heuristics, UI polish, or deployment readiness are welcome. When submitting changes, update documentation and add tests where practical.

About

Delivery drivers in Phnom Penh lose fifteen to twenty-five percent of their workday due to one-way streets and detours. Using local open data and a lightweight Flask engine, Kmap can quickly determine the fastest route with just one click. This led to more deliveries, less fuel consumption, and easier navigation in Khmer for drivers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published