Skip to content

ToureNPlaner/TurnByTurn

Repository files navigation

You need:

* A postgresql database
* python3 + bottle for python (temporarily packaged with this program with an increased MEMFILE_MAX)
* Reasonably much disk space
* A dump of the area you want covered. .pbf files are the smallest to download so I recommend them. You can download *.osm.pbf files from various sources. I get mine from geofabrik: http://download.geofabrik.de/

An upstart job is provided with turnbyturn-upstart.conf. Copy it to /etc/init/turnbyturn.conf and then use "start/stop turnbyturn". Logs can be found in /var/log/upstart/turnbyturn.conf

First, prepare the postgresql database with the openstreetmap data.

----

# switch default table encoding to uniccode
# https://wiki.archlinux.org/index.php/PostgreSQL#Change_Default_Encoding_of_New_Databases_To_UTF-8_.28Optional.29
sudo -u postgres psql
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
\q

# http://wiki.openstreetmap.org/wiki/Osmosis/PostGIS_Setup
# create the osm user with a database "gis" with the "gis" language. It may already exist but it won't hurt running it anyway
sudo -u postgres -i
createuser osm
createdb -E UTF8 -O osm gis
createlang plpgsql gis

# postgis schemas
psql gis < /usr/share/postgresql/contrib/postgis-2.1/postgis.sql
psql gis < /usr/share/postgresql/contrib/postgis-2.1/spatial_ref_sys.sql

# you possibly need additional projections
# http://wiki.openstreetmap.org/wiki/Mapnik#Invalid_projection_in_pgSQL
wget https://raw.github.com/openstreetmap/osm2pgsql/master/900913.sql && psql -f 900913.sql gis
psql gis -c "GRANT ALL ON geometry_columns, spatial_ref_sys TO osm;"

psql gis -c "CREATE EXTENSION hstore;"

# load the pbf with osmosis
# --tf accept-ways highway=*    keep only ways with tag highway=(anything)
# --used-node   Restricts output of nodes to those that are used in ways and relations.
# and write it to current_directory/pgsqldump/
# By default java uses /tmp as temporary directory. Sometimes /tmp is a tmpfs that might get full
mkdir pgsqldump/
JAVACMD_OPTIONS="-Djava.io.tmpdir=/var/tmp" osmosis --read-pbf file="germany.osm.pbf" --tf accept-ways highway=* --used-node --buffer --write-pgsql-dump directory=pgsqldump

# Create the tables and
# use the modified files from this repository:
# * pgsnapshot_schema_0.6.sql - creates tables with specified columns
# * pgsnapshot_load_0.6.sql - copies only the columns we need into the database (I have not found how to tell osmosis which columns to dump with --write-pgsql-dump)
cd pgsqldump
psql -U postgres -d gis -f ./pgsnapshot_schema_0.6.sql
psql -U postgres -d gis -f ./pgsnapshot_load_0.6.sql

sudo -u postgres psql -d gis
GRANT ALL ON nodes, ways, way_nodes TO osm;
# Clustering can potentially take a long time
# CLUSTER nodes USING idx_nodes_geom;
vacuum analyze;

About

TurnByTurn Directions - Server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages