[英]Query Overpass API for roads with crossing bridges/railways
I'm trying to query OpenStreetMaps through the Overpass API. 我正在尝试通过Overpass API查询OpenStreetMaps。
What I want to query is roads inside a bounding box that has any kind of bridges crossing above, like railway bridges etc. 我想要查询的是一个边界框内的道路,这个道路上面有任何类型的桥梁,如铁路桥梁等。
I found this example, that does just about what I need: http://maxheight.bplaced.net/overpass/map.html 我找到了这个例子,这正是我需要的: http : //maxheight.bplaced.net/overpass/map.html
So, the queries I've got look like this: 所以,我得到的查询看起来像这样:
<osm-script output="json" timeout="25">
<!-- Railway bridges -->
<query type="way">
<has-kv k="bridge" regv="^(yes|viaduct)$"/>
<has-kv k="railway" />
<bbox-query {{bbox}}/>
</query>
<!-- Find roads below the above railway bridges -->
<query type="way">
<around radius="0" />
<has-kv k="highway" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
<has-kv k="maxheight" modv="not" regv="." />
<has-kv k="maxheight:physical" modv="not" regv="." />
<has-kv k="tunnel" modv="not" regv="." />
</query>
<union>
<item />
<recurse type="way-node"/>
</union>
<!-- print results -->
<print mode="body"/>
<recurse type="down"/>
<print mode="skeleton" order="quadtile"/>
</osm-script>
<osm-script output="json" timeout="25">
<!-- Bridges -->
<query type="way">
<has-kv k="bridge" regv="^(yes|viaduct)$"/>
<has-kv k="railway" modv="not" regv="." />
<bbox-query {{bbox}}/>
</query>
<!-- Find roads below the above bridges -->
<query type="way">
<around radius="0" />
<has-kv k="highway" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
<has-kv k="maxheight" modv="not" regv="." />
<has-kv k="maxheight:physical" modv="not" regv="." />
<has-kv k="tunnel" modv="not" regv="." />
</query>
<union>
<item />
<recurse type="way-node"/>
</union>
<!-- print results -->
<print mode="body"/>
<recurse type="down"/>
<print mode="skeleton" order="quadtile"/>
</osm-script>
The problem is the second query. 问题是第二个查询。 It should find bridges crossing a road, and the accompanying road below.
它应该找到穿过道路的桥梁和下面的伴随道路。
What it does now is return all bridges, except railway bridges - which means it highlights a road with a bike path underneath, a road crossing a lake - which it shouldn't. 它现在所做的就是返回所有的桥梁,除了铁路桥梁 - 这意味着它突出了一条道路,下面有一条自行车道,一条穿越湖泊的道路 - 它不应该。
I noticed this today, when I drove past a location it highlighted and saw that it was just a bike path under the road. 我今天注意到这一点,当我开车经过一个突出显示的位置时,发现它只是一条自行车道。
A few comments regarding the proposed approach above: 关于上述拟议方法的一些评论:
Maxheight Map wants to help find streets with missing maximum height information, something which is quite important for truck routing. Maxheight Map希望帮助找到缺少最大高度信息的街道,这对卡车路线非常重要。 If I get your use case right, you want to find out about ALL roads where bridges cross.
如果我正确使用您的用例,您想了解桥梁交叉的所有道路。 Currently your query would not show any roads, where that maximum height information was already maintained.
目前,您的查询不会显示任何道路,其中已经保留了最大高度信息。 This is fairly easy to solve if you remove the restriction on both tags "maxheight" and "maxheight:physical" in your query.
如果在查询中删除对“maxheight”和“maxheight:physical”标记的限制,这很容易解决。
As already stated, Maxheight Map merges several layers into one Query. 如前所述,Maxheight Map将多个图层合并为一个Query。 But it would also break a large Boundary Box (bbox) into smaller pieces.
但它也会将一个大的边界框(bbox)打成小块。 The XML query posted above has 4 identical parts inside the UNION operation, which makes things look overly complicated.
上面发布的XML查询在UNION操作中有4个相同的部分,这使得事情看起来过于复杂。 In fact for the purpose of your use case, you could get away with a much simpler approach (see below).
事实上,就您的用例而言,您可以采用更简单的方法(见下文)。
You don't have to convert your query into XML format. 您不必将查询转换为XML格式。 Overpass QL (query language) is perfectly fine for Overpass API and of course Overpass Turbo.
Overpass QL(查询语言)非常适用于Overpass API,当然还有Overpass Turbo。
From past experience with Maxheight Map, Overpass API won't give you the solution you're asking for without post-processing the result. 根据过去Maxheight Map的经验,Overpass API不会为您提供您要求的解决方案,而无需对结果进行后处理。 If you're familiar with OpenLayers you might want to take a look at the logic I used.
如果您熟悉OpenLayers,您可能需要查看我使用的逻辑 。 Basically you need to find intersections on inner points only, similar to want PostGIS function st_crosses does.
基本上你只需要在内点找到交点,类似于想要PostGIS函数st_crosses。 Also you would have to take each way's 'layer' information into account as an example.
此外,您还必须考虑每种方式的“图层”信息。
A very stripped down version (for Overpass Turbo) could look like this. 一个非常简化的版本(Overpass Turbo)可能看起来像这样。 However, you need to make sure that actual highway/bridge types match your requirements, and of course don't forget about post processing your results.
但是,您需要确保实际的高速公路/桥梁类型符合您的要求,当然不要忘记对结果进行后处理。 Without it your query result will contain quite a number of false positives.
没有它,您的查询结果将包含大量误报。
((way({{bbox}})[bridge~"^(yes|viaduct)$"];way(around:0)[highway~"^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"][tunnel!~"."]);>;);out;
The correct query is this. 正确的查询是这样的。 Not only does it get it right in regard to bridges crossing roads, it also combines the two into one query.
它不仅适用于跨越道路的桥梁,它还将两者结合为一个查询。
I monitored the network on the OSM Truck QA Map , grabbed the POST data of the request to the Overpass API. 我在OSM Truck QA Map上监控网络,抓取了Overpass API请求的POST数据。
I used the Overpass QL converter to turn it into XML. 我使用Overpass QL转换器将其转换为XML。
View query in Overpass Turbo 在Overpass Turbo中查看查询
<osm-script output="json" timeout="20">
<union into="_">
<union into="_">
<union into="_">
<query into="_" type="way">
<bbox-query {{bbox}}/>
<has-kv k="bridge" modv="" regv="^(yes|viaduct)$"/>
<has-kv k="railway" modv="" v=""/>
</query>
<query into="_" type="way">
<around from="_" into="_" lat="" lon="" radius="0"/>
<has-kv k="highway" modv="" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
<has-kv k="maxheight" modv="not" regv="."/>
<has-kv k="maxheight:physical" modv="not" regv="."/>
<has-kv k="tunnel" modv="not" regv="."/>
</query>
</union>
<recurse from="_" into="_" type="down"/>
</union>
<union into="_">
<union into="_">
<query into="_" type="way">
<bbox-query {{bbox}}/>
<has-kv k="bridge" modv="" regv="^(yes|viaduct)$"/>
<has-kv k="railway" modv="" v=""/>
</query>
<query into="_" type="way">
<around from="_" into="_" lat="" lon="" radius="0"/>
<has-kv k="highway" modv="" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
<has-kv k="maxheight" modv="not" regv="."/>
<has-kv k="maxheight:physical" modv="not" regv="."/>
<has-kv k="tunnel" modv="not" regv="."/>
</query>
</union>
<recurse from="_" into="_" type="down"/>
</union>
<union into="_">
<union into="_">
<query into="_" type="way">
<bbox-query {{bbox}}/>
<has-kv k="bridge" modv="" regv="^(yes|viaduct)$"/>
<has-kv k="railway" modv="" v=""/>
</query>
<query into="_" type="way">
<around from="_" into="_" lat="" lon="" radius="0"/>
<has-kv k="highway" modv="" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
<has-kv k="maxheight" modv="not" regv="."/>
<has-kv k="maxheight:physical" modv="not" regv="."/>
<has-kv k="tunnel" modv="not" regv="."/>
</query>
</union>
<recurse from="_" into="_" type="down"/>
</union>
<union into="_">
<union into="_">
<query into="_" type="way">
<bbox-query {{bbox}}/>
<has-kv k="bridge" modv="" regv="^(yes|viaduct)$"/>
<has-kv k="railway" modv="" v=""/>
</query>
<query into="_" type="way">
<around from="_" into="_" lat="" lon="" radius="0"/>
<has-kv k="highway" modv="" regv="^((primary|secondary|tertiary|trunk)(_link)?|service|residential|unclassified)$"/>
<has-kv k="maxheight" modv="not" regv="."/>
<has-kv k="maxheight:physical" modv="not" regv="."/>
<has-kv k="tunnel" modv="not" regv="."/>
</query>
</union>
<recurse from="_" into="_" type="down"/>
</union>
</union>
<print from="_" limit="" mode="body" order="id"/>
</osm-script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.