- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个 .xml 请求,可以从 OpenStreetMap Overpass API 成功检索数据。
<?xml version="1.0" encoding="UTF-8"?>
<osm-script>
<query type="node">
<has-kv k="name" v="Bethesda"/>
<has-kv k="network" v="Washington Metro"/>
</query>
<query type="way">
<around radius="800"/>
<has-kv k="building"/>
</query>
<union>
<item/>
<recurse type="down"/>
</union>
<print/>
</osm-script>
我现在正在尝试(但失败了)的是通过 Python 请求库发送此 xml(我对其他 Python 解决方案持开放态度)。我发送以下请求:
files = {'file': ('Bethesda.xml', open('Bethesda.xml', 'rb'))}
r = requests.post('http://overpass-api.de/api/interpreter', data=files)
print r.text
但是得到如下错误信息:
<?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 type "file" </p>
<p><strong style="color:#FF0000">Error</strong>: line 1: parse error: An empty query is not allowed </p>
<p><strong style="color:#FF0000">Error</strong>: line 1: parse error: Unknown type "=" </p>
<p><strong style="color:#FF0000">Error</strong>: line 1: parse error: An empty query is not allowed </p>
<p><strong style="color:#FF0000">Error</strong>: line 1: parse error: Unknown type "Bethesda" </p>
<p><strong style="color:#FF0000">Error</strong>: line 1: parse error: ';' expected - '&' found. </p>
<p><strong style="color:#FF0000">Error</strong>: line 2: parse error: Unexpected end of input. </p>
这表示请求已成功到达 Overpass API 并取回 xml 文件,但似乎 xml 请求未成功传输。我尝试了一些变体,但没有比这更好的了。显然,我对 Python 了解不多......
最佳答案
您希望 xml 成为 POST 的主体。当您传入 dict 时,requests 将它变成一个 url 查询字符串,该字符串编码不正确并且无论如何都不是 api 想要的。在我看来这很烦人。查询字符串和正文是不同的野兽 - 它们不应被压缩成单个参数并自动进行猜测。
这个有效:
import requests
r = requests.post('http://overpass-api.de/api/interpreter',
data=open('Bethesda.xml', 'rb'))
print(r.text)
关于python - 尝试使用 Python 请求将 xml 文件发送到 OpenStreetMap Overpass API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16625584/
我目前正在 PostGIS 上运行 openstreetmap 的 nominatim map 的本地副本。 有什么方法可以将速度限制输入到这个数据库中,这样我也可以返回该信息。我发现在查询 open
我正在寻找一种从 OpenStreetMap (OSM) 数据中准确检索街道交叉口的方法。我知道有人提出并回答了类似的问题,但我可以从建议的方法中检索到的数据不是很准确。 首先,我知道以下问题: ho
是否可以从坐标(纬度、经度)、缩放级别和大小(屏幕)获取边界框?我只找到了 calculating bounding box from tile .我需要它,因为 OpenStreetMap 只接受导
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 11 年前关闭。 Improve this
是否有任何用于openstreetmap 的高程API,就像我们为谷歌地图提供的那样? 在谷歌高程 API 中,我们可以传递坐标并获得高程作为响应。 最佳答案 我最近发表了Open-Elevation
无法弄清楚如何在给定位置获取特定半径的所有道路。我当前的查询是 我尝试添加类似 primary,secondary,tertiary,residential 的内容但它
给定纬度/经度组合以及从该点开始的半径(以公里为单位,如果有区别的话),是否有人知道我可以用来获取所有地点列表的服务/API(甚至下载) ,街道等来自提供的纬度/经度的圆圈内?当我说所有的地方时,我对
嗯,我正在寻找一个教程,告诉我如何在我的网络应用程序中包含 OpenStreetMap。 Google 提供了一个很好的教程,告诉我们如何在我们的网络应用程序中包含 Google Map 的分步过程。
我试图理解什么是什么,但我有点困惑: OpenStreetMap 可免费使用 map 。此 map 可能的 API 是: -OpenLayer -MapQuest 为什么 OpenLayer 在 Op
有人知道是否有办法使用 OpenStreetMap(离线或 API)来获取给定 GPS 坐标集的国家/地区名称? 我对使用此处提到的 Google 或 Geonames API 不感兴趣:Countr
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 2年前关闭。 Improve thi
我一直在尝试使用具有以下请求的 OSRM 获取从 A 点到 B 点的 route 的坐标列表: 获取 http://router.project-osrm.org/viaroute?hl=en&loc
我正在使用 LeafletJS 将 map 组件添加到我的应用程序中。除了 map 的本地化,一切都很好。一些国家名称以本地语言显示(我假设)。 有没有办法用英文显示国家名称? 这是我使用的当前代码
只是在我自己的 Openstreetmaps 服务器上闲逛,遇到了一些问题。 1) 我按照以下说明进行操作:http://wiki.openstreetmap.org/wiki/The_Rails_P
我正在与 Open Street Maps 一起工作并使用 leaflet library . 我有一个这样的图层组: var testLayer = new L.LayerGroup(); -->
有没有办法在OpenStreetMap中下载有关中国eh县界的shp格式文件? 最佳答案 您可以通过 Overpass API 获取行政边界。 .对应的query是: relation ["bou
使用 OverPass API,我想在一个单独的查询中进行多个不同的查询,然后在输出中按查询分隔结果。 例如: node( )[amenity~"cafe"]->.my_cafes; node(
我正在尝试检索特定巴士服务的巴士路线。如何在天桥查询中包含两个键,以便我可以找到特定巴士服务的巴士路线?例如,我想查找巴士 Svc 3 的巴士路线? 我如何包含两个功能: “路线”=“巴士” “名称”
我试图在传单 map 上显示很多标记。标记的数据 - 坐标、文本... - 存储在文本文件中。我制作了一个解析文本的解析器,将数据放在一个大数组中,然后我在这个数组上循环以显示每个标记。 我的问题是我
我使用 google API 和 osmdroid API 为安卓设备设计和开发了几个导航应用程序。现在我正在寻找使用 osmdroid API 创建一个室内导航系统。但是,为了做到这一点,我需要从一
我是一名优秀的程序员,十分优秀!