OpenStreetMap to ThreeJS renderer for WebGL enabled Browsers
This is the quick and dirty version to run the example, if you want to do more than that you'll have to read and understand the code.
What you will need:
- Python 3.7
- Node 10.0 + Yarn
- Postgresql 9.6 or higher
- Imposm3
- Get Python 3.7 via
pyenv
- Create a virtualenv and install the dependencies with
pipenv
- Load node dependencies with
yarn
- Import OSM data with
imposm3
- Build the Bundle
- Run the server
- Install
pyenv
$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
- Restart your shell:
exec bash
- Install Python 3.7:
pyenv install 3.7.0
- Make it the active python:
pyenv local 3.7.0
- Install
pipenv
:pip install pipenv
- Switch to the git checkout
- Run
pipenv sync
- Run
pipenv shell
to get a shell into the virtualenv
- Switch to the git checkout
- Run
yarn --pure-lockfile
- Get a version of imposm3
- Create a new DB on your Postgres installation:
$ sudo -u postgres psql
>>> CREATE DATABASE osm;
>>> CREATE ROLE osm WITH LOGIN PASSWORD 'password';
>>> ALTER DATABASE osm OWNER TO osm;
>>> \c osm
>>> CREATE EXTENSION postgis;
>>> \q
- Get a OpenStreetMap data extract (for example from Geofabrik)
- Import into the DB:
$ imposm import -connection postgis://osm:password@localhost/osm -mapping import/imposm_mapping.yml -read /path/to/osm.pbf -write -deployproduction -optimize
ATTENTION: Importing the data will take a while and will take much disk space, better start with a small region!
- Install
browserify
:npm install -g browserify
- Build the bundle:
npm run build
If you want to change the area that is rendered you'll have to edit js/main.js
(scroll to the bottom) and change the following line:
const osm = new osmRenderer(10.878281, 48.378979, 10.898172, 48.371667); // order is lat, lon -> lat, lon
- Switch to the git checkout
- Activate the venv:
pipenv shell
- Go to the
server/
dir - Edit the
config.json
to point to the correct DB - Run
python -O server.py
- Open a Browser and go to http://localhost:8080/