mirror of
https://github.com/netzbegruenung/social-spider.git
synced 2024-05-03 19:23:41 +02:00
commit
fdde736b91
|
@ -30,6 +30,8 @@ MAPPING = {"Neustadt a.d. Aisch-Bad Windsheim": "Neustadt-Aisch",
|
|||
"Kaufbeuren": "Ostallgäu",
|
||||
"Ostallgäu": "Ostallgäu"}
|
||||
|
||||
REMOVE_BW = ["08215", "08226", "08136", "08436"]
|
||||
|
||||
def createLVBasemap():
|
||||
green_data = []
|
||||
for entry in dir_entries():
|
||||
|
@ -45,7 +47,10 @@ def createLVBasemap():
|
|||
name = feature["properties"]["GEN"]
|
||||
for d in green_data:
|
||||
if d["state"] == name:
|
||||
feature["properties"]["green-data"] = d
|
||||
feature["properties"] = {}
|
||||
feature["properties"]["type"] = d["type"]
|
||||
feature["properties"]["level"] = d["level"]
|
||||
feature["properties"]["state"] = d["state"]
|
||||
result_map["features"].append(feature)
|
||||
with open("maps/lv_basemap.geojson", "w", encoding='utf-8') as output_f:
|
||||
json.dump(result_map, output_f, indent=4)
|
||||
|
@ -56,6 +61,23 @@ def initialize():
|
|||
with open("maps/landkreise_simplify200.geojson") as map_f:
|
||||
map_data = json.load(map_f)["features"]
|
||||
|
||||
# add additional bw data:
|
||||
map_data_copy = []
|
||||
for feature in map_data:
|
||||
if feature["properties"]["SN_L"] == "08" and feature["properties"]["RS"] in REMOVE_BW:
|
||||
pass # don't add it
|
||||
else:
|
||||
map_data_copy.append(feature)
|
||||
map_data = map_data_copy
|
||||
with open("maps/additional_bw.geojson") as map_f:
|
||||
map_data2 = json.load(map_f)["features"]
|
||||
for feature in map_data2:
|
||||
feature["properties"]["GEN"] = feature["properties"]["kvname"]
|
||||
feature["properties"]["NBD"] = ""
|
||||
feature["properties"]["BEZ"] = ""
|
||||
feature["properties"]["SN_L"] = "08"
|
||||
map_data += map_data2
|
||||
|
||||
for entry in dir_entries():
|
||||
if entry["type"] == "REGIONAL_CHAPTER":
|
||||
if entry["level"] == "DE:KREISVERBAND":
|
||||
|
@ -254,7 +276,11 @@ def createKVBasemap():
|
|||
else:
|
||||
# skip not-matched map parts
|
||||
continue
|
||||
feature["properties"]["green-data"] = entry
|
||||
feature["properties"] = {}
|
||||
feature["properties"]["type"] = entry["type"]
|
||||
feature["properties"]["level"] = entry["level"]
|
||||
feature["properties"]["state"] = entry["state"]
|
||||
feature["properties"]["district"] = entry["district"]
|
||||
result_features.append(feature)
|
||||
result_map = {"type": "FeatureCollection",
|
||||
"features": result_features}
|
||||
|
|
2046
maps/additional_bw.geojson
Normal file
2046
maps/additional_bw.geojson
Normal file
File diff suppressed because it is too large
Load diff
27075
maps/kv_basemap.geojson
27075
maps/kv_basemap.geojson
File diff suppressed because it is too large
Load diff
29184
maps/kv_fb.geojson
29184
maps/kv_fb.geojson
File diff suppressed because it is too large
Load diff
28832
maps/kv_in.geojson
28832
maps/kv_in.geojson
File diff suppressed because it is too large
Load diff
28812
maps/kv_tw.geojson
28812
maps/kv_tw.geojson
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
2420
maps/lv_fb.geojson
2420
maps/lv_fb.geojson
File diff suppressed because it is too large
Load diff
2420
maps/lv_in.geojson
2420
maps/lv_in.geojson
File diff suppressed because it is too large
Load diff
2420
maps/lv_tw.geojson
2420
maps/lv_tw.geojson
File diff suppressed because it is too large
Load diff
|
@ -12,13 +12,13 @@ def updateMaps(level="lv"):
|
|||
tw_max = 0
|
||||
in_max = 0
|
||||
for feature in map_data["features"]:
|
||||
greendata = feature["properties"]["green-data"]
|
||||
key = "//".join([greendata["type"], greendata["level"], greendata["state"], greendata.get("district", ""), greendata.get("city", "")])
|
||||
p = feature["properties"]
|
||||
key = "//".join([p["type"], p["level"], p["state"], p.get("district", ""), p.get("city", "")])
|
||||
result = data.get(key)
|
||||
print(result)
|
||||
|
||||
social_data = {}
|
||||
if result:
|
||||
_, _, _ , _, _, fb_name, fb_count, tw_name, tw_count, in_name, in_count = data.get(key)
|
||||
_, _, _ , _, _, fb_name, fb_count, tw_name, tw_count, in_name, in_count = result
|
||||
if fb_count > fb_max:
|
||||
fb_max = fb_count
|
||||
if tw_count > tw_max:
|
||||
|
@ -34,11 +34,10 @@ def updateMaps(level="lv"):
|
|||
feature["properties"].update(social_data)
|
||||
|
||||
print(fb_max, tw_max, in_max)
|
||||
plattform = "fb"
|
||||
for plattform, maxval, col in zip(["fb", "tw", "in"], [fb_max, tw_max, in_max], ["#3664a2", "#55acee", "#d02e92"]):
|
||||
for feature in map_data["features"]:
|
||||
count = feature["properties"].get(plattform + "_count", 0)
|
||||
if level=="lv":
|
||||
if level == "lv":
|
||||
# linear for LV
|
||||
feature["properties"]["fill-opacity"] = count/maxval
|
||||
elif level == "kv":
|
||||
|
|
Loading…
Reference in a new issue