Chapter 8. Configure and run OptaWeb Vehicle Routing manually
The easiest way to run OptaWeb Vehicle Routing is to use the runlocally.sh
script. However, if Bash is not available on your system you can manually complete the steps that the runlocally.sh
script performs.
Prerequisites
- OptaWeb Vehicle Routing has been successfully built with Maven as described in Chapter 6, Download and build the OptaWeb Vehicle Routing deployment files.
- Internet access is available.
Procedure
Download routing data.
The routing engine requires geographical data to calculate the time it takes vehicles to travel between locations. You must download and store OpenStreetMap (OSM) data files on the local file system before you run OptaWeb Vehicle Routing.
NoteThe OSM data files are typically between 100 MB to 1 GB and take time to download so it is a good idea to download the files before building or starting the OptaWeb Vehicle Routing application.
-
Open
http://download.geofabrik.de/
in a web browser. - Click a region in the Sub Region list, for example Europe. The subregion page opens.
-
In the Sub Regions table, download the OSM file (
.osm.pbf
) for a country, for example Belgium.
-
Open
Create the data directory structure.
OptaWeb Vehicle Routing reads and writes several types of data on the file system. It reads OSM (OpenStreetMap) files from the
openstreetmap
directory, writes a road network graph to thegraphhopper
directory, and persists user data in a directory calleddb
. Create a new directory dedicated to storing all of these data to make it easier to upgrade to a newer version of OptaWeb Vehicle Routing in the future and continue working with the data you created previously.-
Create the
$HOME/{VRP-DATA-DIR}
directory. Create the
openstreetmap
directory in the$HOME/{VRP-DATA-DIR}
directory:$HOME/{VRP-DATA-DIR} └── openstreetmap
Move all of your downloaded OSM files (files with the extension
.osm.pbf
) to theopenstreetmap
directory.The rest of the directory structure is created by the OptaWeb Vehicle Routing application when it runs for the first time. After that, your directory structure is similar to the following example:
$HOME/{VRP-DATA-DIR} ├── db │ └── vrp.mv.db ├── graphhopper │ └── belgium-latest └── openstreetmap └── belgium-latest.osm.pbf
-
Create the
-
Change directory to
optaweb-vehicle-routing-distribution-7.44.0.Final-redhat-00006/sources/optaweb-vehicle-routing-standalone/target
. To run OptaWeb Vehicle Routing, enter the following command:
java -jar optaweb-vehicle-routing-standalone-7.44.0.Final-redhat-00006.jar \ --app.persistence.h2-dir=$HOME/{VRP-DATA-DIR}/db \ --app.routing.gh-dir=$HOME/{VRP-DATA-DIR}/graphhopper \ --app.routing.osm-dir=$HOME/{VRP-DATA-DIR}/openstreetmap \ --app.routing.osm-file=<OSM_FILE_NAME> \ --app.region.country-codes=<COUNTRY_CODE_LIST> \
In this command, replace the following variables:
-
<OSM_FILE_NAME>
: The OSM file for the region that you want to use and that you downloaded previously <COUNTRY_CODE_LIST>
: A comma-separated list of country codes used to filter geosearch queries. For a list of country codes, see ISO 3166 Country Codes.The application starts after the OSM file is downloaded.
In the following example, OptaWeb Vehicle Routing downloads the OSM map of Central America (
central-america-latest.osm.pbf
) and searches in the countries Belize (BZ) and Guatemala (GT).java -jar optaweb-vehicle-routing-standalone-7.44.0.Final-redhat-00006.jar \ --app.persistence.h2-dir=/home/user/.optaweb-vehicle-routing/db \ --app.routing.osm-dir=/home/user/.optaweb-vehicle-routing/openstreetmap \ --app.routing.gh-dir=/home/user/.optaweb-vehicle-routing/graphhopper \ --app.routing.osm-file=central-america-latest.osm.pbf \ --app.region.country-codes=BZ,GT
-
To open the OptaWeb Vehicle Routing user interface, enter the following URL in a web browser:
http://localhost:8080
Next steps