获取城市中所有路口的列表 [英] Get list of all intersections in a city

查看:155
本文介绍了获取城市中所有路口的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何得到一个主要城市所有路口的最佳来源和方式?

不要介意一些误报,下面的Overpass API脚本很容易从OpenStreetMap数据中获得道路交叉点:

http://overpass-turbo.eu/s/QD

(脚本可以' t检测错误的交叉点 - 尽管只有两条线相遇,例如,当一条道路由OSM数据中的多路对象表示时)

直接在这里下载一个更可读的版本:




  • 根据您感兴趣的方式,添加类型这些方式不应该算作与 regv 属性的交集(在两个脚本部分)。您可以在这里找到各种方式:公路标签

  • BoundingBox是您在Overpass-tourbo网站上查看的地图的一部分。



脚本:

 <! - 只选择您感兴趣的方式类型 - > 
< query type =wayinto =relevant_ways>
< has-kv k =highway/>
< bbox-query {{bbox}} />
< / query>

<! - 现在单独为每个路径找到所有相交节点 - >
< foreach from =related_waysinto =this_way>

<! - 获取以这种方式链接的所有方法 - >
< recurse from =this_waytype =way-nodeinto =this_ways_nodes/>
<! - 再一次,只选择您感兴趣的方式,看看开始 - >
< query type =wayinto =linked_ways>
< item set =linked_ways/>
< has-kv k =highway/>
< / query>

<! - 以当前方式获取所有链接方式 - >
<差异到=linked_ways_only>
< item set =linked_ways/>
< item set =this_way/>
< /差>

<! - 返回所有相交节点 - >
< query type =node>
< item set =linked_ways_only_nodes/>
< item set =this_ways_nodes/>
< / query>
< print />
< / foreach>


What is the best source and way to get a list of all intersections in a major city?

解决方案

If one doesn't mind a few false positives the following Overpass API script gets road intersections out of OpenStreetMap data pretty easily:

http://overpass-turbo.eu/s/QD

(the script can't detect false intersections – where only two lines meet, though, e.g. when a road is represented by multiple way objects in the OSM data)

In case that the script goes offline a more readable version directly here:

  • Dependent on which kind of ways you are interested in, add the types of ways which should not count as intersection to the regv attribute (at two script sections). The type of ways can be found here: highway tags.
  • The BoundingBox is the part of the map you are viewing on the Overpass-tourbo Website.

Sample Script:

<!-- Only select the type of ways you are interested in -->
<query type="way" into="relevant_ways">
  <has-kv k="highway"/>
  <has-kv k="highway" modv="not" regv="footway|cycleway|path|service|track"/>
  <bbox-query {{bbox}}/>
</query>

<!-- Now find all intersection nodes for each way independently -->
<foreach from="relevant_ways" into="this_way">  

  <!-- Get all ways which are linked to this way -->
  <recurse from="this_way" type="way-node" into="this_ways_nodes"/>
  <recurse from="this_ways_nodes" type="node-way" into="linked_ways"/>
  <!-- Again, only select the ways you are interested in, see beginning -->
  <query type="way" into="linked_ways">
    <item set="linked_ways"/>
    <has-kv k="highway"/>
    <has-kv k="highway" modv="not" regv="footway|cycleway|path|service|track"/>
  </query>

  <!-- Get all linked ways without the current way --> 
  <difference into="linked_ways_only">
    <item set="linked_ways"/>
    <item set="this_way"/>
  </difference>
  <recurse from="linked_ways_only" type="way-node" into="linked_ways_only_nodes"/>

  <!-- Return all intersection nodes -->
  <query type="node">
    <item set="linked_ways_only_nodes"/>
    <item set="this_ways_nodes"/>
  </query>
  <print/>
</foreach>

这篇关于获取城市中所有路口的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆