我正在使用Overpass API.
我有一个问题,在我的观点附近(大约100-200英里)找到一些兴趣点(咖啡馆,医院,学校).我只有纬度和经度.
Overpass API提供了使用您的地名获取POI的机会.但我没有.我只有坐标.
我怎样才能做到这一点 ?
我正在尝试在Django上运行的项目中使用带有JavaScript XMLHttpRequest 的立交桥API http://wiki.openstreetmap.org/wiki/Overpass_API,但我一直在使用
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.google.com/accounts/ClientLogin. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
Run Code Online (Sandbox Code Playgroud)
错误.无论我是使用GET还是POST,还是来自任何其他主机,我都会收到此错误,而不仅仅是overpass API.
我已经安装了django-cors-headers https://github.com/ottoyiu/django-cors-headers并遵循那里的说明,将'corsheaders'放入INSTALLED_APPS,'corsheaders.middleware.CorsMiddleware','django.middleware .common.CommonMiddleware',进入MIDDLEWARE_APPS,我已经设置好了
CORS_ORIGIN_ALLOW_ALL = true
Run Code Online (Sandbox Code Playgroud)
在settings.py但似乎没有任何工作.我在本地运行它
python manage.py runserver
Run Code Online (Sandbox Code Playgroud)
但我也是在openshift上主持它.在这些工作中,他们都没有给出上述错误.
如果我在这里遗漏任何东西,请告诉我.
我有一个OpenstreetMap带leaflet.我正在使用这个 Plugin for leaflet来查询Overpass.
var opl = new L.OverPassLayer({
query: "(area['name'='Roma']; node(area)['amenity'='drinking_water']);out;",
});
Run Code Online (Sandbox Code Playgroud)
但是当插件使用时,我的地图没有显示任何内容.
怎么了?
注意:我的查询基于此工作.
编辑:
该查询正在与插件,但不是在http://overpass-turbo.eu/?!
var opl = new L.OverPassLayer({
query: "(node(BBOX)['amenity'='drinking_water'];);out;",
Run Code Online (Sandbox Code Playgroud)
});
完整示例:
var attr_osm = 'Map data © <a href="http://openstreetmap.org/">OpenStreetMap</a> contributors',
attr_overpass = 'POI via <a href="http://www.overpass-api.de/">Overpass API</a>';
var osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {opacity: 0.7, attribution: [attr_osm, attr_overpass].join(', ')});
var map = new L.Map('map').addLayer(osm).setView(new L.LatLng(49.592041, 8.648164),2);
//OverPassAPI overlay
var opl = new L.OverPassLayer({
query: "(node(BBOX)['amenity'='drinking_water'];);out;",
}); …Run Code Online (Sandbox Code Playgroud) 我的目标是获得德国邮政编码区域的所谓“分区统计图”(我猜)。我找到了 python 包“folium”,但它似乎需要一个.json文件作为输入:
https://github.com/python-visualization/folium
在 OpenStreetMap 上我只看到shp.zip和.osm.pbf文件。在shp.zip档案中,我发现了各种我从未听说过的文件结尾,但没有.json文件。如何使用 OpenStreetMap 中的数据来喂养 folium?我是不是跑错方向了?
是否可以减少以下代码的运行时间?
我的目标是从框边界指定的开放街道数据区域获取加权 igraph 对象。
目前我正在尝试使用立交桥 api 来卸载内存负载,这样我就不必在内存中保留大的 osm 文件。
首先,我获取由 bbox(仅街道)指定的 osm 数据作为 xml 结构
library(osmdata)
library(osmar)
install.packages("remotes")
remotes::install_github("hypertidy/scgraph")
library(scgraph)
dat <- opq(bbox = c(11.68771, 47.75233, 12.35058, 48.19743 )) %>%
add_osm_feature(key = 'highway',value = c("trunk", "trunk_link", "primary","primary_link", "secondary", "secondary_link", "tertiary","tertiary_link", "residential", "unclassified" ))%>%
osmdata_xml ()
Run Code Online (Sandbox Code Playgroud)
然后我将生成的 xml 对象dat转换为 osmar 对象dat_osmar,最后转换为igraph对象:
dat_osmar <-as_osmar(xmlParse(dat))
dat_graoh <- as_igraph(dat_osmar)
Run Code Online (Sandbox Code Playgroud)
我如何优化这些例程?
也许可以将dat (XML) 对象分成块并并行解析它?
我经历了几个步骤才最终得到加权无向图。
目前,整个过程在我的机器上需要 89.555 秒。
如果我可以缩短这两个步骤的运行时间:
dat_osmar <-as_osmar(xmlParse(dat))
dat_graoh <- as_igraph(dat_osmar)
Run Code Online (Sandbox Code Playgroud)
那已经有帮助了。
我尝试的方法之一是使用osmdata_sc()而不是 …
无法弄清楚如何在给定位置获得特定半径的所有道路.我目前的疑问是
<query type="way">
<around lat="55.693309807744484" lon="21.151986122131348" radius="50"/>
</query>
<union>
<item/>
<recurse type="down"/>
</union>
<print/>
Run Code Online (Sandbox Code Playgroud)
我试图添加这样的东西,<highway>primary,secondary,tertiary,residential</highway>但它没有用
我正在试图弄清楚在给定的GPS位置周围找到某些类型的所有节点的最佳解决方案.
假设我希望将所有咖啡馆,酒吧,餐馆和公园都围绕给定点X.xx,Y.yy.
[out:json];(node[amenity][leisure](around:500,52.2740711,10.5222147););out;
Run Code Online (Sandbox Code Playgroud)
这没有任何回报,因为我认为它搜索既不可能的舒适和休闲节点.
[out:json];(node[amenity or leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity,leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity;leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity|leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity]|[leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity],[leisure](around:500,52.2740711,10.5222147););out;
[out:json];(node[amenity];[leisure](around:500,52.2740711,10.5222147););out;
Run Code Online (Sandbox Code Playgroud)
这些解决方案导致错误(400:错误请求)
我找到的唯一可行解决方案是以下一个导致查询非常长的解决方案
[out:json];(node[amenity=cafe](around:500,52.2740711,10.5222147);node[leisure=park](around:500,52.2740711,10.5222147);node[amenity=pub](around:500,52.2740711,10.5222147);node[amenity=restaurant](around:500,52.2740711,10.5222147););out;
Run Code Online (Sandbox Code Playgroud)
没有多个"周围"声明,是否有更简单的解决方案?
编辑:发现这个有点短.但仍有多个"周围"的陈述.
[out:json];(node["leisure"~"park"](around:400,52.2784715,10.5249662);node["ameni??ty"~"cafe|pub|restaurant"](around:400,52.2784715,10.5249662););out;
Run Code Online (Sandbox Code Playgroud) 如果我想查询某个区域内的某些对象,这很简单:
area(...);
node(area)[natural=peak];
out;
Run Code Online (Sandbox Code Playgroud)
但是如果该区域被定义为 OSM 数据库中的关系呢?我可以像这样查询该区域...
(rel(...);>;);
out;
Run Code Online (Sandbox Code Playgroud)
...但是我该如何使用区域过滤器呢?
假设我想找到柏林的餐馆,并且有以下查询:
[out:json];
area["boundary"="administrative"]["name"="Berlin"] -> .a;
(
node(area.a)["amenity"="restaurant"];
); out center;
Run Code Online (Sandbox Code Playgroud)
假设这个结果集太大,无法仅通过一个请求来提取以进行跨越。我希望能够使用 SQLOFFSET和LIMIT参数之类的东西来获取前 100 个结果 (0-99),处理它们,然后获取接下来的 100 个结果 (100-199),依此类推。
我在 API 中找不到执行此操作的选项,这可能吗?如果不是,我应该如何查询我的数据以将其分成更小的集合?
我知道我可以增加内存限制或超时,但这仍然让我处理一个大型请求,而不是 n 个小请求,这就是我想要的方式。
我正在尝试从 Overpass API 获取与 Tourism=museum 或 Historical=memorial 匹配的 POI。我尝试了不同的查询,但找不到正确的解决方案,我得到的答复是空的。
以下是无效的查询
area["name"="Bursa"];
(node["tourism"="museum"](area););
(node["historic"="memorial"](area););
out center;
Run Code Online (Sandbox Code Playgroud)
area["name"="Bursa"];
(node["tourism"="museum"]|["historic"="memorial"](area););
out center;
Run Code Online (Sandbox Code Playgroud)
谢谢,艾尔辛。
overpass-api ×10
javascript ×2
choropleth ×1
cors ×1
cross-domain ×1
django ×1
folium ×1
geojson ×1
igraph ×1
leaflet ×1
python ×1
r ×1
r-sf ×1