如何修复Pandana中的“ JSON解码错误”?

时间:2019-05-25 11:56:00

标签: python openstreetmap

我正在尝试使用Pandana加载器查询以下bbox:

(-9.6420841, -35.7349799, -9.6160445, -35.7408408)

因此查询如下:

net = osm.pdna_network_from_bbox(bbox1[0], bbox1[1], bbox1[2], bbox1[3])

当我运行这段代码时,方法显示如下:

Requesting network data within bounding box from Overpass API in 1 request(s)
Posting to http://www.overpass-api.de/api/interpreter with timeout=180, "{'data': '[out:json][timeout:180];(way["highway"]["highway"!~"motor|proposed|construction|abandoned|platform|raceway"]["foot"!~"no"]["pedestrians"!~"no"](inf,inf,inf,inf);>;);out;'}"

如您所见,Overpass API的查询在节点框中具有无穷大值。

在此之后,我得到以下输出:

Downloaded 0.6KB from www.overpass-api.de in 0.30 seconds
Server at www.overpass-api.de returned status code 400 and no JSON data
---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/osmnet/load.py in overpass_request(data, pause_duration, timeout, error_pause_duration)
    240     try:
--> 241         response_json = response.json()
    242         if 'remark' in response_json:

9 frames
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/osmnet/load.py in overpass_request(data, pause_duration, timeout, error_pause_duration)
    266                 .format(domain, response.status_code), level=lg.ERROR)
    267             raise Exception('Server returned no JSON data.\n{} {}\n{}'
--> 268                             .format(response, response.reason, response.text))
    269 
    270     return response_json

Exception: Server returned no JSON data.
<Response [400]> Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" lang="en"/>
  <title>OSM3S Response</title>
</head>
<body>

<p>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</p>
<p><strong style="color:#FF0000">Error</strong>: line 1: parse error: Unknown query clause </p>

</body>
</html>

0 个答案:

没有答案