new changes maps
This commit is contained in:
81
deploy/osrm/README.md
Normal file
81
deploy/osrm/README.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# Self-hosted OSRM
|
||||
|
||||
The app defaults to the FOSSGIS community routing server. That server is free
|
||||
and keyless, but it is donation-funded infrastructure with a fair-use policy —
|
||||
fine for development, **not** appropriate for a production delivery fleet.
|
||||
Run your own before shipping.
|
||||
|
||||
Everything below is open source and costs nothing but the machine it runs on.
|
||||
|
||||
## 1. Pick a region
|
||||
|
||||
Nearle operates around Coimbatore, so the **southern zone** extract is enough —
|
||||
it covers Tamil Nadu, Kerala, Karnataka, Andhra Pradesh and Telangana.
|
||||
|
||||
| Extract | Download size |
|
||||
| --- | --- |
|
||||
| `asia/india/southern-zone` | **0.52 GB** ← use this |
|
||||
| `asia/india` (all of India) | 1.58 GB |
|
||||
|
||||
Using the regional extract rather than all-India cuts preprocessing time and
|
||||
roughly a third of the memory.
|
||||
|
||||
## 2. Preprocess (one-off, ~15–40 min)
|
||||
|
||||
```sh
|
||||
mkdir -p data && cd data
|
||||
wget https://download.geofabrik.de/asia/india/southern-zone-latest.osm.pbf
|
||||
|
||||
REGION=southern-zone-latest
|
||||
IMG=ghcr.io/project-osrm/osrm-backend:latest
|
||||
|
||||
docker run -t -v "$PWD:/data" $IMG osrm-extract -p /opt/car.lua /data/$REGION.osm.pbf
|
||||
docker run -t -v "$PWD:/data" $IMG osrm-partition /data/$REGION.osrm
|
||||
docker run -t -v "$PWD:/data" $IMG osrm-customize /data/$REGION.osrm
|
||||
```
|
||||
|
||||
`osrm-extract` is the memory-hungry step — give the machine **~8 GB RAM** for
|
||||
the southern zone. Serving afterwards needs far less (the compose file caps at
|
||||
4 GB). If extraction is killed, that is OOM, not corruption: retry with more RAM
|
||||
or a smaller extract.
|
||||
|
||||
Use `/opt/bicycle.lua` instead of `car.lua` if riders are mostly on two-wheelers
|
||||
in pedestrianised areas — but `car.lua` is the right default for motorbike
|
||||
delivery on Indian roads.
|
||||
|
||||
## 3. Serve
|
||||
|
||||
```sh
|
||||
cd .. && docker compose up -d
|
||||
curl "http://localhost:5000/route/v1/driving/76.9558,11.0168;76.9776,10.9984?overview=full"
|
||||
```
|
||||
|
||||
A healthy response starts with `{"code":"Ok"`.
|
||||
|
||||
## 4. Point the app at it
|
||||
|
||||
```sh
|
||||
flutter build apk --dart-define=OSRM_BASE_URL=https://osrm.your-domain.in
|
||||
```
|
||||
|
||||
Put it behind TLS and restrict it to your own backend or app — OSRM has **no
|
||||
authentication of its own**. An open OSRM instance is a free compute service for
|
||||
anyone who finds it. If you already proxy other services, route this through the
|
||||
same gateway.
|
||||
|
||||
## 5. Keep it current
|
||||
|
||||
OSM data drifts as roads change. Re-run step 2 monthly-ish and restart the
|
||||
container. There is no live-update path in OSRM — reprocessing is the only way.
|
||||
|
||||
## Optional: also self-host tiles
|
||||
|
||||
The app's default tile source, [OpenFreeMap](https://openfreemap.org), is a free
|
||||
public instance with no key and no request limits, so self-hosting tiles is not
|
||||
required. If you ever want to, the options are OpenFreeMap's own self-host
|
||||
instructions or serving a [Protomaps](https://protomaps.com) `.pmtiles` extract
|
||||
from the MinIO instance this project already uses. Then:
|
||||
|
||||
```sh
|
||||
--dart-define=MAP_STYLE_URL=https://tiles.your-domain.in/styles/liberty
|
||||
```
|
||||
40
deploy/osrm/docker-compose.yml
Normal file
40
deploy/osrm/docker-compose.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
# Self-hosted OSRM routing backend.
|
||||
#
|
||||
# Run the one-off preprocessing in ./README.md FIRST — this file only serves
|
||||
# the already-built graph.
|
||||
#
|
||||
# docker compose up -d
|
||||
#
|
||||
# Then point the app at it:
|
||||
# flutter build apk --dart-define=OSRM_BASE_URL=http://your-host:5000
|
||||
|
||||
services:
|
||||
osrm:
|
||||
image: ghcr.io/project-osrm/osrm-backend:latest
|
||||
container_name: nearle-osrm
|
||||
restart: unless-stopped
|
||||
command: >
|
||||
osrm-routed
|
||||
--algorithm mld
|
||||
--max-table-size 8000
|
||||
/data/${OSRM_REGION:-southern-zone-latest}.osrm
|
||||
volumes:
|
||||
- ./data:/data:ro
|
||||
ports:
|
||||
- "5000:5000"
|
||||
healthcheck:
|
||||
# Coimbatore -> a nearby point; fails loudly if the graph did not load.
|
||||
test:
|
||||
- CMD-SHELL
|
||||
- >-
|
||||
wget -qO- "http://localhost:5000/route/v1/driving/76.9558,11.0168;76.9776,10.9984"
|
||||
| grep -q '"code":"Ok"' || exit 1
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
# Southern-zone MLD needs well under this; raise for all-India.
|
||||
memory: 4G
|
||||
Reference in New Issue
Block a user