nilsnolde / valhalla-qgis-plugin

QGIS plugin to use Valhalla for routing, isochrones and matrices.
GNU General Public License v3.0
12 stars 3 forks source link

Localhost access token #4

Closed Viskovitz closed 3 years ago

Viskovitz commented 3 years ago

I'm running Valhalla in localhost using Docker, but when I try to run a route calculation using localhost provider I get this message

400 (Error transferring http://localhost:8002/route?access_token= - server replied: Bad Request)

Do I need an api key to run Valhalla using localhost as provider? How can I get it?

nilsnolde commented 3 years ago

You don’t need a token. Can you look into the Valhalla docker logs and the QGIS log messages (View > Panels > Log Messages). You’re having some trouble with your input data. Which plugin version are you on? There’s been a problem in #2 but that’s resolved since last week.

Viskovitz commented 3 years ago

If I look into log messages in QGIS I'm getting this in the Processing tab when I start the program (I'm using the Valhalla plugin version 2.2.0):

2021-02-06T21:45:01     WARNING    Parámetro use_highways duplicado registrado para el algoritmo directions_from_polylines_auto
2021-02-06T21:45:01     WARNING    Parámetro use_ferry duplicado registrado para el algoritmo directions_from_polylines_bicycle
2021-02-06T21:45:01     WARNING    Parámetro use_highways duplicado registrado para el algoritmo directions_from_point_layer_auto
2021-02-06T21:45:01     WARNING    Parámetro use_ferry duplicado registrado para el algoritmo directions_from_point_layer_bicycle
2021-02-06T21:45:01     WARNING    Parámetro use_highways duplicado registrado para el algoritmo directions_from_point_layer_truck
2021-02-06T21:45:01     WARNING    Parámetro use_highways duplicado registrado para el algoritmo directions_from_points_2_layers_auto
2021-02-06T21:45:01     WARNING    Parámetro use_highways duplicado registrado para el algoritmo directions_from_points_2_layers_truck
2021-02-06T21:45:01     WARNING    Parámetro use_ferry duplicado registrado para el algoritmo directions_from_points_2_layers_bicycle
2021-02-06T21:45:01     WARNING    Parámetro use_highways duplicado registrado para el algoritmo isochrones_auto
2021-02-06T21:45:01     WARNING    Parámetro use_highways duplicado registrado para el algoritmo isochrones_truck
2021-02-06T21:45:01     WARNING    Parámetro use_ferry duplicado registrado para el algoritmo isochrones_bicycle
2021-02-06T21:45:01     WARNING    Parámetro use_highways duplicado registrado para el algoritmo matrix_auto
2021-02-06T21:45:01     WARNING    Parámetro use_highways duplicado registrado para el algoritmo matrix_truck
2021-02-06T21:45:01     WARNING    Parámetro use_ferry duplicado registrado para el algoritmo matrix_bicycle
2021-02-06T21:45:08     WARNING    Parámetro coordinates duplicado registrado para el algoritmo v.net.visibility

Which mean WARNING Duplicate xxxxxxxxxxx parameter registered for xxxxxxxxxx algorithm.

When I try to calculate a route with Valhalla (truck, shortest) I get this in the Valhalla tab of QGIS Log Panel:

2021-02-06T21:53:23     INFO    url: http://localhost:8002/route?access_token=
             Parameters: {
              "costing": "truck",
              "narrative": false,
              "id": 1,
              "locations": [
              {
              "lon": -3.632699,
              "lat": 37.197079
              },
              {
              "lon": -3.632101,
              "lat": 37.19386
              },
              {
              "lon": -3.627876,
              "lat": 37.190774
              },
              {
              "lon": -3.622394,
              "lat": 37.190986
              },
              {
              "lon": -3.622174,
              "lat": 37.195512
              },
              {
              "lon": -3.624497,
              "lat": 37.193237
              },
              {
              "lon": -3.628447,
              "lat": 37.197627
              }
              ],
              "costing_options": {
              "truck": {
              "weight": 0.0,
              "axle_load": 0.0,
              "width": 0.0,
              "height": 0.0,
              "length": 0.0,
              "hazmat": true,
              "shortest": true
              }
              }
             }
2021-02-06T21:53:23     INFO    Feature ID 1 caused a ApiError: Error transferring http://localhost:8002/route?access_token= - server replied: Bad Request
2021-02-06T21:53:23     CRITICAL    ApiError: 400 (Error transferring http://localhost:8002/route?access_token= - server replied: Bad Request)

And this is the Valhalla Docker log:

TEST: /custom_files
Valhalla tiles not found!
Hash counter couldn't find hash file!
Either valhalla_tiles.tar couldn't be found or new files or file constellations were detected. Rebuilding files:
PBF hashes: 0
PBF file Counter: 0
No local files and no valhalla_tiles.tar found. Downloading links: !
PATH0: /valhalla/scripts/configure_valhalla.sh
PATH1: /custom_files
PATH2:

=========================================================================
= No valid bounding box or elevation parameter set. Skipping elevation! =
=========================================================================

==========================
= Skipping admin regions =
==========================

==========================
= Skipping timezone data =
==========================

==========================
= Using existing config file =
==========================

=========================
= Build the tile files. =
=========================
Running build tiles with: /custom_files/valhalla.json
2021/02/06 20:52:50.395757 [INFO] Start stage = initialize End stage = cleanup
Input file is required

Valhalla_build_tiles 3.1.0

Usage: valhalla_build_tiles [options] <protocolbuffer_input_file>

valhalla_build_tiles is a program that creates the route graph from an osm.pbf extract. Sample json configs are located in ../conf directory.

:
-h [ --help ] Print this help message.
-v [ --version ] Print the version of this software.
-c [ --config ] arg Path to the json configuration file.
-i [ --inline-config ] arg Inline json config.
-s [ --start ] arg Starting stage of the build pipeline
-e [ --end ] arg End stage of the build pipeline
--input_files arg

Found config file. Starting valhalla service!
2021/02/06 20:52:50.596317 [ERROR] (stat): /custom_files/valhalla_tiles.tar No such file or directory
2021/02/06 20:52:50.596389 [WARN] Tile extract could not be loaded
2021/02/06 20:52:50.596426 [WARN] (stat): /data/valhalla/traffic.tar No such file or directory
2021/02/06 20:52:50.596465 [WARN] Traffic tile extract could not be loaded
2021/02/06 20:52:50.598983 [WARN] /data/valhalla/elevation/ currently has no elevation tiles
0 2021/02/06 20:53:23.759808 POST /route?access_token= HTTP/1.1
2021/02/06 20:53:23.760110 [INFO] Got Loki Request 0
2021/02/06 20:53:23.778255 [WARN] 400::No suitable edges near location request_id=0
0 2021/02/06 20:53:23.778526 400 252
1 2021/02/06 20:57:32.963187 GET / HTTP/1.1
2021/02/06 20:57:32.963420 [INFO] Got Loki Request 1
1 2021/02/06 20:57:32.963810 404 379

Also, when I run docker-compose up I get this errors. I edit the docker-compose.yml to use tile_urls=https://download.geofabrik.de/europe/spain-latest.osm.pbf:

valhalla_1  | 2021/02/06 21:14:17.411298 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for United States
valhalla_1  | 2021/02/06 21:14:17.411440 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for United Kingdom
valhalla_1  | 2021/02/06 21:14:17.411478 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Switzerland
valhalla_1  | 2021/02/06 21:14:17.411507 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Russia
valhalla_1  | 2021/02/06 21:14:17.411535 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Romania
valhalla_1  | 2021/02/06 21:14:17.411611 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Poland
valhalla_1  | 2021/02/06 21:14:17.411676 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Norway
valhalla_1  | 2021/02/06 21:14:17.411752 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Spain
valhalla_1  | 2021/02/06 21:14:17.411795 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Netherlands
valhalla_1  | 2021/02/06 21:14:17.411852 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Hungary
valhalla_1  | 2021/02/06 21:14:17.411944 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Slovakia
valhalla_1  | 2021/02/06 21:14:17.412033 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for France
valhalla_1  | 2021/02/06 21:14:17.412143 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Finland
valhalla_1  | 2021/02/06 21:14:17.412241 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Denmark
valhalla_1  | 2021/02/06 21:14:17.412338 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Brazil
valhalla_1  | 2021/02/06 21:14:17.412447 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Turkey
valhalla_1  | 2021/02/06 21:14:17.412556 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Belgium
valhalla_1  | 2021/02/06 21:14:17.412672 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Belarus
valhalla_1  | 2021/02/06 21:14:17.412741 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Austria
valhalla_1  | 2021/02/06 21:14:17.412861 [ERROR] sqlite3_step() error: NOT NULL constraint failed: admin_access.admin_id.  Ignore if not using a planet extract or check if there was a name change for Australia
nilsnolde commented 3 years ago

Well..

Running build tiles with: /custom_files/valhalla.json
2021/02/06 20:52:50.395757 [INFO] Start stage = initialize End stage = cleanup
Input file is required

Valhalla_build_tiles 3.1.0

You're missing a graph, it never built it, there's no OSM PBF. What's your docker-compose.yml?

Viskovitz commented 3 years ago

I removed the docker image and created again with a new cocker-compose.yml and now it works fine and it don't ask me for a token localy.

I'm pretty new with Docker, sorry.

This is the new docker-compose.yml

version: '3.0'
services:
  valhalla:
    image: gisops/valhalla:latest
    ports:
      - "8002:8002"
    volumes:
      - ./custom_files/:/custom_files
    environment:
      - tile_urls=https://download.geofabrik.de/europe/spain-latest.osm.pbf
      - min_x=-9 # -> Spain | -180 -> World
      - min_y=35 # -> Spain | -90  -> World
      - max_x=4 # -> Spain |  180 -> World
      - max_y=43 # -> Spain |  90  -> World
      - use_tiles_ignore_pbf=False
      - force_rebuild=False
      - force_rebuild_elevation=False
      - build_elevation=True
      - build_admins=True
      - build_time_zones=True
nilsnolde commented 3 years ago

don't worry, you're not the first one who thinks a token might be the problem. I'll close and pin the issue.