Skip to content

Routing engine and base map#

Empowerment Center maps can calculate isochrones (the areas that can be reached from a point within a time or a distance) and a time and distance matrix to the features of a layer. Radial isochrones (circles) are always calculated; those that follow the roads need a routing engine. This page explains how to configure it, together with the base map drawn under the layers.

Before you start#

  • The configuration is done by whoever installs ECenter: environment variables or an application.yml mounted in the backend (see Configuration).
  • No routing engine or base map is mandatory.

What changes with a routing engine#

Without engine With engine
Radial isochrones (straight-line distance circles) Yes Yes
Isochrones by time or by road distance No («No hay motor de rutas configurado», no routing engine configured) Yes
Time and distance matrix to the features of a layer No Yes

With an engine, a road isochrone of, for example, 20 and 40 minutes from a shop draws both bands, and its matrix says how long it takes and how far it is to each municipality of the chosen layer that falls within the larger band (at most 500, from the nearest in a straight line to the farthest). Users work with it from the map viewer (see Maps).

Engine failures do not interrupt the map: an isochrone that cannot be calculated keeps its error and the rest is drawn.

Choose an engine#

Engine When
Valhalla Self-hosted, next to ECenter. It is the recommended one: the coordinates do not leave your network. deploy/compose.yaml brings it as an optional service.
OpenRouteService Its cloud service, with a key and daily limits, or self-hosted. With the cloud service, the coordinates of origins and destinations go out to it. Its matrix does not calculate the shortest routes, only the fastest.

Valhalla with Docker Compose#

In deploy/.env (with the headless browser as well, COMPOSE_PROFILES=render,routing):

COMPOSE_PROFILES=routing
ECENTER_MAPS_ROUTING_PROVIDER=valhalla

The routing profile starts the valhalla service, which only the backend sees; deploy/compose.yaml already tells the backend its address (ECENTER_MAPS_ROUTING_URL=http://valhalla:8002).

The first time, Valhalla downloads from Geofabrik the OpenStreetMap extracts in ECENTER_ROUTING_TILE_URLS (by default, Spain with the Balearic Islands, Ceuta and Melilla, and the Canary Islands: 1.5 GB) and builds its road graph in the routing-data volume. Meanwhile, road isochrones fail with their error and everything else works. After that it starts from what is stored, in seconds.

What it took on a development machine (Docker with 2 CPUs and 7.8 GB):

Spain and the Canary Islands Community of Madrid
Building the graph, with the download 24 min 1.5 min
Memory while building it 4.6 GB 0.7 GB
Memory while running 250 MB 250 MB
Disk 5.8 GB 0.5 GB
Variable Default What it is
ECENTER_ROUTING_TILE_URLS Spain and the Canary Islands from Geofabrik The extracts that are downloaded, separated by spaces: a country, a region or several.
ECENTER_ROUTING_MEMORY 6g The container's memory limit. It must cover building the graph.
ECENTER_ROUTING_THREADS 2 Valhalla threads. With more, it builds sooner and uses more memory.

For another area, or to bring the roads up to date (Geofabrik publishes daily), delete the volume and start again:

docker compose stop valhalla && docker compose rm -f valhalla
docker volume rm ecenter_routing-data
docker compose up -d valhalla

Valhalla does not calculate isochrones of more than 120 minutes nor routes longer than 400 km in a matrix (its service limits): the isochrone says so in its error. A matrix of 500 destinations is 500 origin-destination pairs, within the limit of 2,500 that Valhalla 3.9 brings; with an old version that limits the destinations of a matrix to 50, raise it in its configuration or lower ecenter.maps.routing.max-matrix-targets.

OpenRouteService in the cloud#

ECENTER_MAPS_ROUTING_PROVIDER=openrouteservice
ECENTER_MAPS_ROUTING_URL=https://api.openrouteservice.org
ECENTER_MAPS_ROUTING_APIKEY=change-this-key

Its free plan gives 500 isochrones and 500 matrices a day. For a self-hosted OpenRouteService, put its address in ECENTER_MAPS_ROUTING_URL.

All the map configuration#

Property Default What it is
ecenter.maps.routing.provider none none, valhalla or openrouteservice. Variable: ECENTER_MAPS_ROUTING_PROVIDER.
ecenter.maps.routing.url The address of the service.
ecenter.maps.routing.api-key The OpenRouteService key.
ecenter.maps.routing.profile The car one The routing profile (auto in Valhalla, driving-car in OpenRouteService).
ecenter.maps.routing.timeout 30s How long each call to the engine may take.
ecenter.maps.routing.cache-ttl 7d How long a response from the engine is kept: processing a map again does not call it again.
ecenter.maps.routing.max-matrix-targets 500 Maximum destinations of a matrix.
ecenter.maps.max-features 200000 Maximum features of a layer file.
ecenter.maps.max-dots 20000 Maximum points of a dot density.
ecenter.maps.upload-ttl 24h How long an uploaded file lasts without creating the layer.
ecenter.maps.base-map.style A MapLibre style for the base map: the URL of a provider (for example, MapTiler) or a self-hosted one (for example, a Protomaps .pmtiles).
ecenter.maps.base-map.style-dark The style for the dark theme. Without it, the dark theme uses style.
ecenter.maps.base-map.tiles, tiles-dark Raster tiles (…/{z}/{x}/{y}.png), if there is no style, and their dark variant; without it, in dark mode the light ones are shown dimmed.
ecenter.maps.base-map.attribution The base map attribution, if raster tiles are used.
ecenter.maps.base-map.max-zoom 19 The maximum zoom of the raster tiles.

Without a base map, layers are drawn on a plain background in the theme's color. The public OpenStreetMap tiles are only suitable for testing, because of their usage policy.

An example of an application.yml mounted in the backend:

ecenter:
  maps:
    base-map:
      style: https://api.maptiler.com/maps/streets-v2/style.json?key=change-this-key
      style-dark: https://api.maptiler.com/maps/streets-v2-dark/style.json?key=change-this-key
    routing:
      provider: valhalla
      url: http://valhalla:8002

Note

If the base map comes from another origin, add that origin to ECENTER_CSP_MAP_ORIGINS in the frontend (https://api.maptiler.com), so that the application's content policy allows it. See Installation.

See also#