Using the PostGIS Data Reader for GraphHopper

Sunday, November 4, 2018 · 2 minutes to read ·

To use the PostGIS Data Reader for GraphHopper described in the previous post , please do the following:

Download the package in . As of this writing, the most stable can be found postgis-0.11 branch. So change the branch from master and download the package as a ZIP file.

Un-zip the downloaded file. Ensure the Java is installed in the system.

Build the source code by issuing a ./ build in the command line. This will download Maven if it is not installed in the system, and compile all the source files.

Uncomment the PostGIS parameters in the config.yml and set the appropriate values. The PostGIS reader will only be used if all the PostGIS parameters are set.

Prepare the road network data in PostgreSQL. The following columns have to be part of the table or view that will be used for conversion:

osm_id, maxspeed, oneway, fclass, name, geom

For example, to create a View:

CREATE VIEW myroad_view
  (osm_id, maxspeed, oneway, fclass, name, geom)
  AS SELECT id, 0, oneway, 'tertiary'::text, name, geom FROM custom_road_network;

Start the GraphHopper server by adding the parameter /<path where graph will reside>/<table or view name>. The example below will create a graph myroad_view-gh in /Users/mbasa/t for the myroad_view view of PostgreSQL:

./ web /Users/mbasa/t/myroad_view

If the data in PostgreSQL changes and the graph has to be updated, just delete the created graph directory and restart GraphHopper using the above method.


Related articles

GraphHopper with PostGIS Data Reader
October 27, 2018
PostGIS and pgRouting template
February 7, 2011

pgRouting extends the PostGIS / PostgreSQL geospatial database to provide geospatial routing functionality.