:clock2: OpenStreetMap Data Extracts - updated on the fly!
A service providing real-time OSM data.
Three components:
The API adds, deletes and requests information about tasks that provide region-bound real-time OSM data in PBF file format via a permanent URL
The backend runs, manages and gathers statistics for tasks
The frontend allows manipulating tasks and serves the OSM data produced by the tasks.
git clone https://github.com/GIScience/OSM-realtime-update
cd OSM-realtime-update/server
npm install
npm start
Use the Dockerfile provided.
docker build -t realtimeosm .
docker run -v /path/to/data:/OSM-realtime-update/server/data -p 1234:1234 -d realtimeosm
(NOTE: data folder must not be existent, will be created by container)
You will find a config.js file in the server directory controlling server and api global settings. For instance this will let you determine the number of workers to be run in parallel, specific storage paths, ports and update settings.
Real-time OSM provides a web-frontend, that is accessible via port 1234.
Point your browser to http://localhost:1234/
.
Base Url: /api
Main collection: /api/tasks
Individual resource: /api/tasks/:id
URL: /api/tasks
Method: POST: x-www-form-unencoded or raw/JSON
Request Parameters:
Response:
Example WKT/x-www-form-unencoded:
curl --data "name=test_region&coverage=Polygon ((-0.61 53.05, -0.22 51.92, -3.04 52.20, -0.61 53.05))&expirationDate=2020-05-01" http://localhost:1234/api/tasks
curl --data 'name=test_region&coverage={"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-0.61,53.05],[-3.04,52.20],[-0.22,51.92],[-0.61,53.05]]]}, "properties": {"name": "GB"}}&expirationDate=2020-05-01' http://localhost:1234/api/tasks
curl --data 'name=Togo&coverage=togo&updateInterval=10' http://localhost:1234/api/tasks
URL: /api/tasks
Method: DELETE
Request Parameters
Response:
Example:
curl –data “id=5” -X DELETE http://localhost:1234/api/tasks
URL: /api/tasks
Method: GET
Filter Parameters in URL:
/api/tasks?id=:id
/api/tasks?name=:name
If no parameter is given, all tasks are returned.
Individual tasks can also be accessed via their resource URL /api/tasks/:id
.
Response:
Example:
curl http://localhost:1234/api/tasks
curl http://localhost:1234/api/tasks/2
curl http://localhost:1234/api/tasks/id=2
curl http://localhost:1234/api/tasks/name=test1
The OSM data files are stored in a subfolder that is served by the web app. File names are generated using name and id.
A main sqlite3 database keeps track of the application state, it contains two tables:
Format:
For each task, initialise data by downloading a suitable .pbf from Geofabrik, clip it to the task’s boundary and update it using osmupdate.
Algorithm:
Worker objects care for a specific task including scheduled updates. A master object manages all workers and checks regularly whether a) workers became obsolete because tasks have been removed or b) a new worker should be spawned because a new task has been added.