| 1 | import urllib.request, json
|
|---|
| 2 |
|
|---|
| 3 | def main():
|
|---|
| 4 | key = 'shop'
|
|---|
| 5 | banned = ['no', 'yes']
|
|---|
| 6 | with urllib.request.urlopen('https://taginfo.openstreetmap.org/api/4/key/values?key=' + key + '&sortname=count&sortorder=desc') as url:
|
|---|
| 7 | data = json.loads(url.read().decode())
|
|---|
| 8 | data = data["data"]
|
|---|
| 9 | #print(data[0])
|
|---|
| 10 | # Get an array of values that only includes values with more than min_count() occurrences
|
|---|
| 11 | counted = [x["value"] for x in data if x["count"] > min_count()]
|
|---|
| 12 |
|
|---|
| 13 | print('<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6">')
|
|---|
| 14 | index = 0
|
|---|
| 15 | for value in counted:
|
|---|
| 16 | if value in banned:
|
|---|
| 17 | continue
|
|---|
| 18 | lat = 50 + int(index/10) * 0.00001
|
|---|
| 19 | lon = 20 + index % 10 * 0.00001
|
|---|
| 20 | print('<node id="-' + str(index+1) + '" lat="' + str(lat) + '" lon="' + str(lon) + '"><tag k="' + key + '" v="' + value + '"/></node>')
|
|---|
| 21 | index += 1
|
|---|
| 22 | print('</osm>')
|
|---|
| 23 |
|
|---|
| 24 | def min_count():
|
|---|
| 25 | return 1000
|
|---|
| 26 |
|
|---|
| 27 | main()
|
|---|