如何找到OpenStreetMap的十字路口?(how to find intersections

2019-07-31 07:37发布

如何提取OpenStreetMap的十字路口?我需要交点的经度和纬度,谢谢!

Answer 1:

已经有一个类似的问题在这里 。 没有直接的API调用来检索交叉点。 但是你可以(通过直接在例如查询在给定的边框中的所有方法API或通过立交桥API ),并寻求通过两个或多个共享的方式在对方的回答解释节点。



Answer 2:

尝试GeoNames的findNearestIntersectionOSM API: http://api.geonames.org/findNearestIntersectionOSMJSON?lat=37.451&lng=-122.18&username=demo

输入是LNG和LAT位置和所述响应包含LNG和LAT最接近交叉路口的:

{"intersection":{...,"lng":"-122.1808293","lat":"37.4506505"}}

它是通过提供GeoNames的 ,但似乎是基于OpenStreetMap的



Answer 3:

作为@scai完全解释的, 你必须自己处理原始数据OSM找到办法相交节点

相反,编写自己的程序,你可以尝试先使用不同的算法OverpassAPI 。

  • 取决于你有兴趣在哪一种方式,加不应该算作交叉口到regv属性方面的类型(在两个脚本部分)。 该类型的方法可以在这里找到: 公路标签 。
  • boundingBox的是您要查看的立交桥 - tourbo网站地图的一部分。
  • 该脚本是基于脚本化链接另一个问题的回答 ,但我重写它,使之更具可读性和添加注释(在这里和原来的回复)。

示例脚本:

<!-- 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>


文章来源: how to find intersections from OpenStreetMap?