2016-08-12 31 views
0

我正在使用立交API查詢附近路段的開放街景地圖。我很確定,我的查詢返回所有nodes的附近way ...但我只想要附近nodes的附近way如何僅獲取路線節點的附近子集

In the documentation it references this problem

一般情況下,你會,而不是僅僅 單一類型的元素感興趣的完整數據。首先,「完整地圖數據」的含義有幾個有效定義 。第一個不清楚的主題是 對邊界框外的節點做什麼,這些節點是 部分位於邊界框內的方式的成員。

同樣的問題重複關係。如果您等待輪到 限制,則您可能更願意獲得包含關係 的所有元素。如果你的邊界框命中例如俄羅斯的邊界, 你可能不想下載世界上一半的一萬公里的邊界 。

但我看了下面的例子,沒有看到解決方案。

基本上,在他們的例子中,我將如何限制返回給那些嚴格在邊界框中的元素(而不是返回俄羅斯的整個邊界)?

我當前的查詢是

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

我想也許我需要將其更改爲node (around:...),然後遞歸向上到way來查詢高速公路的標籤,但我不知道如果我連在正確的軌道上。

回答

2

事實上,它甚至更復雜一點,因爲您需要100米距離內的所有節點的集合交集和屬於相關方法之一的那些節點。以下是查詢應該如何的樣子:根據需要調整距離,標籤的方式。

請注意,根據標記,不能保證您會在一定距離內找到節點,特別是如果道路趨於相當直和較長。這肯定會影響你的結果,因此可能需要嘗試適當的半徑。

// 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; 

檢查出來立交橋渦輪:http://overpass-turbo.eu/s/hPV