Output Overpass query for problematic IDs
This commit is contained in:
parent
6dff91ecbc
commit
a9d5b983cd
1 changed files with 23 additions and 4 deletions
|
@ -29,6 +29,21 @@ def ids(elements):
|
|||
def first(iterable, default=None):
|
||||
return next(iter(iterable), default)
|
||||
|
||||
|
||||
def overpass_query(wd_ids):
|
||||
return f""" [out:json][timeout:25]; (
|
||||
{overpass_selectors(wd_ids)}
|
||||
); out body; >; out skel qt;"""
|
||||
|
||||
|
||||
def overpass_selector(wd_id):
|
||||
return ' nwr["wikidata"=' + wd_id + ']({{bbox}});\n nwr[~":wikidata$"~' + wd_id + ']({{bbox}});'
|
||||
|
||||
|
||||
def overpass_selectors(wd_ids):
|
||||
return "\n".join(overpass_selector(wd_id) for wd_id in wd_ids)
|
||||
|
||||
|
||||
s = requests.Session()
|
||||
|
||||
data = json.load(sys.stdin)
|
||||
|
@ -68,7 +83,11 @@ try:
|
|||
|
||||
finally:
|
||||
print()
|
||||
print()
|
||||
print(f"Not found: {notfound}")
|
||||
print(f"Redirects: {redirects}")
|
||||
print()
|
||||
if notfound:
|
||||
print(f"Not found:")
|
||||
print(overpass_query(notfound))
|
||||
print()
|
||||
if redirects:
|
||||
print(f"Redirects: {redirects}")
|
||||
print(overpass_query(redirects))
|
||||
print()
|
||||
|
|
Loading…
Reference in a new issue