如何仅获取路径节点的附近子集

How to get only the nearby subset of a way's nodes

我正在使用立交桥 API 查询附近路段的 Open Street Maps。我很确定我的查询正在返回附近 waynodesall... 但我只想要 nearby nodes 附近的 way.

In the documentation it references this problem:

In general, you will be rather interested in complete data than just elements of a single type. First, there are several valid definitions of what "complete map data" means. The first unclear topic is what to do with nodes outside the bounding box which are members of ways that lie partly inside the bounding box.

The same question repeats for relations. If you wait for a turn restriction, you may prefer to get all elements of the relation included. If your bounding box hits for example the border of Russia, you likely don't want to download ten thousands kilometers of boundary around half the world.

但是我看了后面的例子,没有看到解决方案。

基本上,在他们的示例中,我如何将返回的元素严格限制在边界框中(而不是返回俄罗斯的整个边界)?

我当前的查询是

way (around:100,50.746,7.154) [highway~"^(secondary|tertiary)$"];
>;
out ids geom;

我在想也许我需要将其更改为 node (around:...) 然后向上递归到 way 以查询高速公路标签,但我不确定我是否在正确的轨道。

其实还要复杂一点,因为你需要100m距离内所有节点的集合交集,以及属于相关路段的节点。您的查询应如下所示:调整距离,根据需要为方式添加标签。

请注意,根据标记的不同,无法保证您会在一定距离内找到节点,尤其是在道路比较直且较长的情况下。这肯定会影响您的结果,因此可能需要对合适的半径进行一些试验。

// Find nodes up to 100m around center point 
// (center is overpass turbo specific for center point lat/lon in current map view)
node(around:100,{{center}})->.aroundnodes;

// recurse up to ways with highway = secondary/tertiary
way(bn.aroundnodes)[highway~"^(secondary|tertiary)$"]->.allways;

// determine nodes belonging to found ways
node(w.allways)->.waynodes;

( 
// determine intersection of all ways' nodes and nodes around center point  
  node.waynodes.aroundnodes;  
// and return ways (intersection is just a workaround for a bug)  
  way.allways.allways; 
 );
out;

在 overpass turbo 中查看:http://overpass-turbo.eu/s/hPV