此内容没有您所选择的语言版本。

Chapter 4. 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

Procedure

  1. 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.

    Note

    The 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.

    1. Open http://download.geofabrik.de/ in a web browser.
    2. Click a region in the Sub Region list, for example Europe. The subregion page opens.
    3. In the Sub Regions table, download the OSM file (.osm.pbf) for a country, for example Belgium.
  2. 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 the graphhopper directory, and persists user data in a directory called db. 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.

    1. Create the $HOME/{VRP-DATA-DIR} directory.
    2. Create the openstreetmap directory in the $HOME/{VRP-DATA-DIR} directory:

      $HOME/{VRP-DATA-DIR}
      └── openstreetmap
      Copy to Clipboard
    3. Move all of your downloaded OSM files (files with the extension .osm.pbf) to the openstreetmap 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
      Copy to Clipboard
  3. Change directory to optaweb-vehicle-routing-distribution-7.39.0.Final-redhat-00005/sources/optaweb-vehicle-routing-standalone/target.
  4. To run OptaWeb Vehicle Routing, enter the following command:

    java -jar optaweb-vehicle-routing-standalone-7.39.0.Final-redhat-00005.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> \
    Copy to Clipboard

    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.39.0.Final-redhat-00005.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
      Copy to Clipboard
  5. To open the OptaWeb Vehicle Routing user interface, enter the following URL in a web browser:

    http://localhost:8080
    Copy to Clipboard
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat