if 语句内的正则表达式跨越 OpenStreerMap

问题描述 投票:0回答:1

我正在尝试结合 OSM Overpass 风格的 2 个功能:if 语句 + 正则表达式。
示例:

[out:json][timeout:50];

area["name"="Paris"][admin_level=8]->.searchArea;;

(
  node(area.searchArea)
    ["addr:housenumber"]["addr:postcode"]
    [!"contact:email"]
    [!"contact:phone"]
    [!"phone"]
    [!"email"]
    [!"ref:FR:SIRET"]
    [!"landuse"]
    [!"amenity"]
    [!"leisure"]
    [!"website"]
    [!"shop"]
    [!"brand"]
    [!"office"]
    [!"tourism"]
    [!"operator"]
// Below is the problem I struggle with
    ((if: t["building"] && t["building"]~"dormitory|apartments|yes|residential|house");
)->.filtered;

(
  .filtered;
  >;  
);
out body;

这个想法是:如果关键建筑存在,它应该有有价值的宿舍或公寓或住宅或房屋。如果键不存在,我们将节点添加到结果中。

如果有人可以告诉我第一个是否可能,如果可能的话请告诉我如何做/纠正我的例子。谢谢:)

我试图在官方文档中找到示例,但没有那么多结果。 https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Value_matches_regular_expression_(~,_!~)

尝试使用人工智能进行一些自动更正,但效果也不佳。

filter openstreetmap overpass-api
1个回答
0
投票

在这种情况下不能使用 (if:...),因为它不支持正则表达式。相反,创建一个中间结果

.step1
而不检查建筑物标签,然后使用此中间结果进一步过滤没有建筑物或仅给定建筑物标签列表的节点。将两个结果合并为最终结果。

[out:json][timeout:50];

area["name"="Paris"][admin_level=8]->.searchArea;


node(area.searchArea)
    ["addr:housenumber"]
    ["addr:postcode"]
    [!"contact:email"]
    [!"contact:phone"]
    [!"phone"]
    [!"email"]
    [!"ref:FR:SIRET"]
    [!"landuse"]
    [!"amenity"]
    [!"leisure"]
    [!"website"]
    [!"shop"]
    [!"brand"]
    [!"office"]
    [!"tourism"]
    [!"operator"]->.step1;

(
 node.step1[!building];   // previous result without building
 node.step1["building"~"^(dormitory|apartments|yes|residential|house)$"];  // previous result matching given list of building=... tags
);

out body;
© www.soinside.com 2019 - 2024. All rights reserved.