GIScience / orstools-qgis-plugin

Plugin for QGIS with a set of tools to use openrouteservice API´s, based on openstreetmap
https://plugins.qgis.org/plugins/ORStools/
MIT License
92 stars 31 forks source link

ORSTool API error when points are too far #116

Closed ghtmtt closed 4 years ago

ghtmtt commented 4 years ago

Here's what I did

If you try to calculate the distance between two far points (e.g. Rome and Florence both in the middle of teh city and places on a street) than the plugin always throws this error:

An error has occurred while executing Python code: 

ORStools.utils.exceptions.ApiError: 404 ({"error":{"code":2010,"message":"Could not find point 0: 20.4493370 45.8700030 within a radius of 350.0 meters."},"info":{"engine":{"version":"6.1.0","build_date":"2020-06-08T02:22:00Z"},"timestamp":1591877998547}}) 
Traceback (most recent call last):
  File "/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python/plugins/ORStools/common/client.py", line 158, in request
    response, content = self.nam.request(self.url,
  File "/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python/plugins/ORStools/common/networkaccessmanager.py", line 260, in request
    raise self.http_call_result.exception
ORStools.common.networkaccessmanager.RequestsException: Network error #404: Error transferring https://api.openrouteservice.org/v2/directions/driving-car/geojson? - server replied: Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python/plugins/ORStools/gui/ORStoolsDialog.py", line 291, in run_gui_control
    response = clnt.request('/v2/directions/' + profile + '/geojson', {}, post_json=params)
  File "/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python/plugins/ORStools/common/client.py", line 171, in request
    self._check_status()
  File "/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python/plugins/ORStools/common/client.py", line 225, in _check_status
    raise exceptions.ApiError(
ORStools.utils.exceptions.ApiError: 404 ({"error":{"code":2010,"message":"Could not find point 0: 20.4493370 45.8700030 within a radius of 350.0 meters."},"info":{"engine":{"version":"6.1.0","build_date":"2020-06-08T02:22:00Z"},"timestamp":1591877998547}})

Python version: 3.8.3 (default, May 14 2020, 11:03:12) [GCC 9.3.0] 
QGIS version: 3.13.0-Master Master, af474eaf81 

Python Path:
/home/matteo/dev/qgis-master/output/python
/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python
/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python/plugins
/home/matteo/dev/qgis-master/output/python/plugins
/usr/lib/python38.zip
/usr/lib/python3.8
/usr/lib/python3.8/lib-dynload
/home/matteo/.local/lib/python3.8/site-packages
/usr/local/lib/python3.8/dist-packages
/usr/lib/python3/dist-packages
/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python
/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python/plugins/ee_plugin/extlibs_linux
/home/matteo/.local/lib/python3.8/site-packages/IPython/extensions
/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python/plugins/qgis_resource_sharing
/home/matteo/.local/share/QGIS/QGIS3/profiles/matteo/python/plugins/qgis_resource_sharing/ext_libs
nilsnolde commented 4 years ago

Hm, the routing service apparently doesn't think it's near a road.

Can you pls share the full debug request (with POST parameters)? Either from the log window in the UI or from the QGIS Log messages panel?

ghtmtt commented 4 years ago

It seems something related to the Project CRS. I had an OSM Tile in 3857 and I get errors while when setting the project CRS to 4326 the problem seems gone. Is this the expected behavior?

nilsnolde commented 4 years ago

Don't think that should (or even could) be the problem. It's transforming any CRS (map CRS while clicking points or layer CRS for layer operations) to WGS84, which is what ORS backend expects. In the response it says Could not find point 0: 20.4493370 45.8700030 within a radius of 350.0 meters., which very much sounds like WGS84, not 3857.

If you can give me the entire request including the POST parameters for the one that's failing we can maybe shed some more light into this. Those are not included in the traceback, only the URL.

nilsnolde commented 4 years ago

That being said, maybe smth changed in the QGIS API for 3.13 regarding project CRS retrieval? Things did change from 2.x to 3.x on that. But I guess we would hear loud cries if that was the case;)

ghtmtt commented 4 years ago

If you can give me the entire request including the POST parameters for the one that's failing we can maybe shed some more light into this. Those are not included in the traceback, only the URL.

I tried and retried in all the ways I could, but the problems is not happening anymore. Maybe something was stuck in the QGIS session... anyway I'll re-open the issue if necesary, thanks for teh assistance :)

ghtmtt commented 4 years ago

That being said, maybe smth changed in the QGIS API for 3.13 regarding project CRS retrieval? Things did change from 2.x to 3.x on that. But I guess we would hear loud cries if that was the case;)

mmm it would be an API break and therefore not possible between minor versions in QGIS :)

nilsnolde commented 4 years ago

Great, love self-solving stuff:)