获取主要城市所有交叉口 list 的最佳来源和方法是什么?
最佳答案
如果您不介意一些误报,那么以下Overpass API脚本可以很轻松地从OpenStreetMap数据中获取道路交叉口:
http://overpass-turbo.eu/s/QD
(脚本无法检测到错误的相交点-但是,只有两条线相交,例如,当OSM数据中的道路由多路对象表示时)
如果脚本脱机,则可以在此处直接找到更具可读性的版本:
示例脚本:
<!-- 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>