TypeError on avoid polygons function

Hi,
I’m trying to use the avoid polygon function, but a TypeError keeps coming up. I’ve tried using different formats and the same error message about exceptions show. The first exception says Network error:network access disabled and the second says typeerror. I’m not an expert in python so apologies if its an easy fix

Hi @nj7,

without the actual polygon and lines for the request it will be rather difficult to help.

Best regards

Hi @amandus, thanks for your reply
I’m not sure if I can share the files as this is for a university project and there are a lot of rules on data protection, but I’ll check with my supervisor. If it helps identify a common problem, I have a road system and a polygon of a flooded area that needed to be clipped to reduce the number of features.
I have managed to figure out that the issue is on line 161 of the python plugin client file, but I can’t open this file to see what this line does.
Hope this clears things up,sorry if its not enough information to identify the issue, hopefully at the very least its enough to know what to look for.
Thanks for your help

Maybe you could try to reproduce the problem with a different polygon and share that one?
You can also try to validate you polygon with a geojson validator e.g. geojson.io.

Also the code for the plugin is open source. Maybe you can point to the correct line in this file, because 161 in client.py is a comment :sweat_smile:

Best regards

Hi, I’ve recreated the issue with another polygon, how can I upload it on here as a geojson file?
The error message I get says the issue is when line 161 is called, so not sure what it means then.
Thanks

just paste the content in a code block by using these quotes:

```
{
  "type": "Polygon",
  "geometry": [...
```

oooh, whait a moment…
you are talking about the QGIS plugin.
You even put it in the correct category…
You referred to it as the python plugin which in my head is the openrouteservice-py package

The line 161 makes a lot more sense now.

Could you please paste the whole error log message (in case of sensitive info please redact it)

ah my bad, should have been clearer. Heres the error message :slight_smile:
Traceback (most recent call last):
File “C:/Users/njone/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ORStools\common\client.py”, line 161, in request
blocking=True)
File “C:/Users/njone/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ORStools\common\networkaccessmanager.py”, line 260, in request
raise self.http_call_result.exception
ORStools.common.networkaccessmanager.RequestsException: Network error: Network access is disabled.

         During handling of the above exception, another exception occurred:
         
         Traceback (most recent call last):
          File "C:/Users/njone/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ORStools\gui\ORStoolsDialog.py", line 309, in run_gui_control
          response = clnt.request('/v2/directions/' + profile + '/geojson', {}, post_json=params)
          File "C:/Users/njone/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ORStools\common\client.py", line 167, in request
          self._check_status()
          File "C:/Users/njone/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ORStools\common\client.py", line 219, in _check_status
          if 400              TypeError: '

heres the trial polygon i made as well

{
  "type": "Polygon",
  "geometry": [3.1743869612910203e-06, 0.008458165209773319 : 3.013473303781211e-06, 0.008180230790309318 : 3.013473303781211e-06, 0.008180230790309318 : 3.013473303781211e-06, 0.008180230790309318 : 
3.386500338820042e-06, 0.00910338474899331 : 3.013473303781211e-06, 0.008180230790309318 : 3.386500338820042e-06, 0.00910338474899331 : 3.386500338820042e-06, 0.00910338474899331: 3.1743869612910203e-06, 0.008458165209773319 : 3.386500338820042e-06, 0.00910338474899331 : 3.1743869612910203e-06, 0.008458165209773319 : 3.1743869612910203e-06, 0.008458165209773319

Hi @nj7,

this is not a valid GeoJSON polygon.
It should look something like this:

{
        "type": "Polygon",
        "coordinates": [
          [
            [
              4.19677734375,
              1.404735957542484
            ],
            [
              4.141845703125,
              1.4761245198527841
            ],
            [
              3.99078369140625,
              1.3731595449619909
            ],
            [
              4.0045166015625,
              1.1905576261723045
            ],
            [
              4.23248291015625,
              1.3113784096477825
            ],
            [
              4.19677734375,
              1.404735957542484
            ]
          ]
        ]
      }

Is that the last of the error message?
The request seems to be malformed and returns a http 400 response.
probably due to the polygon that is passed.
But normally the error message should be more verbose.

Apologies I’ll reformat it now

Yes thats the end of the message. If its reoccuring with other polygons, could it be an issue with my QGIS? I have version 3.16.5 on my laptop.

hmm should not be the qgis version. i’m using 3.16.6 but that shouldn’t make a difference.

Are you passing the polygons as scratch layers?
Or how is the your workflow to create avoid polygons and start/end points?

The polygons were properly saved and I was working with the advanced directions dialogue box in the ORS tools.
Good news though, it has started working! I hadn’t changed anything from my previous attempt, so still no idea what the issue is though.
As with any computing project, its from one problem to another… I’ve cut the actual polygon down to a size the program can manage, but now it says the network request has timed out. Is there any way around this?
Thanks for your help

sorry, but i’m lost here.

normally there should be a meaningful error message in the log text window of the advanced directions tab. As well as the ORS Tools and Python error Log tabs like:

ApiError: 400 ({"error":{"code":2003,"message":"The area of a polygon to avoid must not exceed 2.0E8 square meters."},"info":{"engine":{"version":"6.6.1","build_date":"2021-07-05T10:57:48Z"},"timestamp":1629204996772}})

which appears if your avoid polygons exceed the maximum size of 200 km^2.

Maybe that is the problem with the request.

However, if i can’t reproduce the actual request, it’s rather hard to get to the source the problem