mirror of
https://github.com/DerTyp7/local-analyzer-python.git
synced 2025-10-28 20:12:10 +01:00
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from operator import itemgetter
|
|
|
|
class Shops:
|
|
def __init__(self, _osm):
|
|
self.osm = _osm
|
|
|
|
def getAllShops(self):
|
|
shopList = []
|
|
|
|
for tag in self.osm.nodeTagList:
|
|
if tag.key == "shop":
|
|
shopList.append(tag.value)
|
|
|
|
for tag in self.osm.wayTagList:
|
|
if tag.key == "shop":
|
|
shopList.append(tag.value)
|
|
return shopList
|
|
|
|
def countOfShops(self):
|
|
shopList = self.getAllShops()
|
|
countDict = []
|
|
|
|
if shopList:
|
|
def isInDict(name):
|
|
for a in countDict:
|
|
if a['name'] == name:
|
|
return True
|
|
return False
|
|
|
|
for shop in shopList:
|
|
print(shop)
|
|
if not isInDict(shop):
|
|
print("add" + str(shopList.count(shop)))
|
|
countDict.append({'name': shop, 'count': shopList.count(shop)})
|
|
return sorted(countDict, key=itemgetter('count'), reverse=True) |