- data: PostgreSQL + PostGIS, osm2pgsql for importing into the database; and OSM data extract
- code: openstreetmap-carto (+ Git, Python)
- editing software: Kosmtik (+ Node.js)
- install PostgreSQL
- install Git
- install Node.js
- install Python if needed (already there on MacOS X and Linux)
- install osm2pgsql
- get a OSM data extract: e.g. Geofabrik or Mapzen Metro-Extracts
- create a folder for openstreetmap-carto and change into the directory on the command line (or Git-Bash)
- Click "Clone or download" at the GitHub-Repository and select "Use HTTPS"
- copy the URL
- execute
git clone <copied URL> .
(code will be checked out in current directory) - execute
./get-shapefiles.sh
or./get-shapefiles.py
(whatever exists)
- create a database (name e.g. osm)
- activate PostGIS:
CREATE EXTENSION postgis;
- opt. activate HStore:
CREATE EXTENSION hstore;
- import data (Linux):
sudo -u postgres osm2pgsql --create --slim --cache CACHE --number-processes NUM --hstore --style path/to/openstreetmap-carto/openstreetmap-carto.style --multi-geometry --database osm --username postgres path/to/extract.pbf
CACHE = size of RAM - memory in use - X (do not choose a size too big as swapping might become necessary then [slow])
NUM = number of CPU cores
Importing can take quite some time depending on the size of the data extract!
- Click "Clone or download" at the GitHub-Repository and select "Download ZIP" (or use the method like for osm-carto above)
- extract the ZIP-file in a directory
- execute
npm install
in this directory (needs Node.js)
- create a local config file, e.g. osm.localconfig:
exports.LocalConfig = function (localizer, project) {
localizer.where('center').then([13.0463, 47.7978, 15]); // Salzburg
localizer.where('Layer').if({'Datasource.type': 'postgis'}).then({
"Datasource.dbname": "osm",
"Datasource.password": "postgres",
"Datasource.user": "postgres",
"Datasource.host": "localhost"
});
// You can also do it in pure JS
project.mml.bounds = [1, 2, 3, 4];
};
- start Kosmtik:
node index.js serve --localconfig path/to/osm.localconfig path/to/openstreetmap-carto/project.yaml
- use your own text editor e.g. Atom, gedit, TextWrangler, Notepad++
- change the *.mss files
- view the changes in Kosmtik
- if you change the layer definitions in project.yaml you have to execute
./yaml2mml.py