【发布时间】:2012-09-03 02:34:32
【问题描述】:
如何在OpenStreetMap中提取路口?我要路口的经纬度,谢谢!
【问题讨论】:
标签: intersection openstreetmap
如何在OpenStreetMap中提取路口?我要路口的经纬度,谢谢!
【问题讨论】:
标签: intersection openstreetmap
有一个类似的问题here。没有直接的 API 调用来检索交叉点。但是您可以查询给定边界框中的所有方式(例如直接通过API 或通过Overpass API)并查找由两个或多个方式共享的节点,如另一个答案中所述。
【讨论】:
试试 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的
【讨论】:
正如@scai 完美解释的那样,您必须自己处理原始 OSM 数据才能找到路的交叉节点。
您可以先使用OverpassAPI 尝试不同的算法,而不是编写自己的程序。
示例脚本:
<!-- 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>
【讨论】: