Skip to content

Commit

Permalink
Enable more tags to trigger construction warnings
Browse files Browse the repository at this point in the history
Instead of enabling only `highway|landuse|building=construction` (+ everything with construction:* and construction=*), enable it for all tags that have `*=construction` (unless explicitly blacklisted), for example railways.

Also adds `operational_status=(under_)construction`. An uncommon key, so I'm also happy to ignore it if preferred.

Additionally, only use a loop once and fix a typo
  • Loading branch information
Famlam committed Aug 17, 2024
1 parent bdd90b9 commit 53f2406
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions plugins/Construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def init(self, logger):
been in construction for more than two years or opening data is
exceeded.'''))

self.tag_construction = ["highway", "landuse", "building"]
# Tags where the value "construction" does not refer to construction work on the object itself\
# Note that only company=construction is documented
self.tag_not_construction = ["company", "craft", "historic", "industrial", "shop"]

self.tag_date = ["opening_date", "open_date", "construction:date", "temporary:date_on", "date_on"]
self.default_date = datetime.datetime(9999, 12, 1)
self.today = datetime.datetime.today()
Expand All @@ -65,15 +68,14 @@ def convert2date(self, string):
pass

def node(self, data, tags):
construction_found = False
for t in tags:
if t == "construction" or (t.startswith("construction:") and t != "construction:date"):
construction_found = True
break
construction_found = "construction" in tags

if not construction_found and "operational_status" in tags:
construction_found = tags.get("operational_status").endswith("construction")
if not construction_found:
for t in self.tag_construction:
if tags.get(t) == "construction":
for t in tags:
if ((t.startswith("construction:") and t != "construction:date")
or (tags.get(t) == "construction" and t not in self.tag_not_construction and ":" not in t)):
construction_found = True
break

Expand All @@ -95,7 +97,7 @@ def node(self, data, tags):

delta = int(self.total_seconds(self.today - end_date))
if delta > 0:
# Change the subclass every 6 months after expiration, re-popup the marker in frontend event if set as false-positive
# Change the subclass every 6 months after expiration, re-popup the marker in frontend even if set as false-positive
return {"class": 4070, "subclass": delta // self.recall}

def way(self, data, tags, nds):
Expand Down Expand Up @@ -124,11 +126,16 @@ def test(self):
{"highway": "construction"},
{"landuse": "construction"},
{"building": "construction"},
{"operational_status": "under_construction"},
{"railway": "construction"},
{"construction:man_made": "water_works"},
]
other_tags = [{"highway": "primary"},
{"landuse": "farm"},
{"building": "yes"},
{"company": "construction"},
{"construction:date": "2001-01-01"},
{"removed:landuse": "construction"},
]

correct_dates = ["2010-02-03",
Expand Down

0 comments on commit 53f2406

Please sign in to comment.