Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3da728df7d | ||
|
|
70c6c0d63d | ||
|
|
7398bffda6 |
@@ -0,0 +1,40 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
def create_barchart(barChartMonth, barChartData, color, image_folder_barcharts, image_filename):
|
||||||
|
barChartMonth.reverse()
|
||||||
|
barChartData.reverse()
|
||||||
|
|
||||||
|
max_wert = max(barChartData)
|
||||||
|
min_wert = min(barChartData)
|
||||||
|
skala = max_wert + max_wert * 0.1
|
||||||
|
|
||||||
|
plt.figure(figsize=(7, 3))
|
||||||
|
plt.bar(barChartMonth, barChartData, color=color)
|
||||||
|
|
||||||
|
plt.ylabel('Stromproduktion in Franken', fontsize=12)
|
||||||
|
|
||||||
|
plt.ylim(0, skala)
|
||||||
|
|
||||||
|
# Turn off the frame (border) around the graphic
|
||||||
|
ax = plt.gca() # Get the current axis
|
||||||
|
ax.spines['top'].set_visible(False)
|
||||||
|
ax.spines['right'].set_visible(False)
|
||||||
|
ax.spines['bottom'].set_visible(False)
|
||||||
|
|
||||||
|
plt.xticks(barChartMonth)
|
||||||
|
# Set the x-axis limits to remove extra space on the right
|
||||||
|
# plt.xlim(barChartMonth[0], barChartMonth[-1])
|
||||||
|
|
||||||
|
plt.savefig(f"{image_folder_barcharts}{image_filename}", bbox_inches='tight')
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
barChartMonth = [8, 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, 9]
|
||||||
|
barChartMonth = [str(item) for item in barChartMonth]
|
||||||
|
|
||||||
|
barChartData=[612.9508602242413, 774.9497310367794, 905.1661458663121, 700.3920174038531, 455.8453881411557, 362.9725109507848, 243.91420489011418, 106.40652073925607, 98.73508056571949, 140.51124465669344, 293.31970563938467, 442.59112071461107]
|
||||||
|
image_folder_barcharts = "barcharts/"
|
||||||
|
image_filename = "test-file.png"
|
||||||
|
color = "red"
|
||||||
|
create_barchart(barChartMonth, barChartData, color, image_folder_barcharts, image_filename)
|
||||||
+128
-37
@@ -1,8 +1,14 @@
|
|||||||
import tkinter
|
import tkinter
|
||||||
import threading
|
import threading
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
import selenium.webdriver.firefox.service
|
||||||
|
import webdriver_manager.chrome
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.chrome.service import Service
|
from selenium.webdriver.chrome.service import Service
|
||||||
|
from selenium.webdriver.firefox.service import Service
|
||||||
from webdriver_manager.chrome import ChromeDriverManager
|
from webdriver_manager.chrome import ChromeDriverManager
|
||||||
|
from webdriver_manager.firefox import DriverManager
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.common.keys import Keys
|
from selenium.webdriver.common.keys import Keys
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
@@ -16,26 +22,29 @@ from selenium.webdriver.common.action_chains import ActionChains
|
|||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
import statistics
|
import statistics
|
||||||
|
from webdriver_manager.firefox import GeckoDriverManager
|
||||||
|
|
||||||
DropDownLabels = ["Street: ", "Number: ", "Postal code: ", "City: ", "coordinate X", "coordinate Y", "Sonnendach URL: ", "Suitability:", "Image Filename: ", "PV Production 100", "Value Electricity production", "Roof area"]
|
DropDownLabels = ["Street: ", "Number: ", "Postal code: ", "City: ", "coordinate X", "coordinate Y", "Sonnendach URL: ", "Suitability:", "Image Filename: ", "PV Production 100", "Value Electricity production", "Roof area", "existing PV Production"]
|
||||||
file_split_char = ","
|
file_split_char = ","
|
||||||
minRoofSize = 2
|
minRoofSize = 2
|
||||||
minSuitability = 3
|
minSuitability = 3
|
||||||
electricityPrice = 0.1
|
electricityPrice = 0.198
|
||||||
OptionList = []
|
OptionList = []
|
||||||
exit = False
|
exit = False
|
||||||
stopThread = False
|
stopThread = False
|
||||||
filename_adresslist = ""
|
filename_adresslist = ""
|
||||||
adresslist = ""
|
adresslist = ""
|
||||||
step = 0
|
step = 0
|
||||||
service = Service(ChromeDriverManager().install())
|
# service = Service(webdriver_manager.chrome.ChromeDriverManager().install())
|
||||||
driver = webdriver.Chrome(service=service)
|
service = selenium.webdriver.firefox.service.Service(GeckoDriverManager().install())
|
||||||
|
# driver = webdriver.Chrome(service=service)
|
||||||
|
driver = webdriver.Firefox(service=service)
|
||||||
driver.minimize_window()
|
driver.minimize_window()
|
||||||
outputtext = "Welcome to application Sonnendach\n"
|
outputtext = "Welcome to application Sonnendach\n"
|
||||||
columnIndexes = []
|
columnIndexes = []
|
||||||
storeToDolibarr = True
|
storeToDolibarr = False
|
||||||
dolibarrURL = ""
|
dolibarrURL = "https://doli.solar-evolution.ch/api/index.php/thirdparties"
|
||||||
dolibarrApiKey = ""
|
dolibarrApiKey = "riE0jT3yvpIT"
|
||||||
dolibarrCountryID = "6" # 6 = Schweiz
|
dolibarrCountryID = "6" # 6 = Schweiz
|
||||||
dolibarrCountryCode = "CH"
|
dolibarrCountryCode = "CH"
|
||||||
dolibarrStateID = "403" # 403 = Kanton Zürich
|
dolibarrStateID = "403" # 403 = Kanton Zürich
|
||||||
@@ -59,12 +68,15 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
|||||||
image_folder_map = "screenshots_map/"
|
image_folder_map = "screenshots_map/"
|
||||||
image_folder_production = "screenshots_production/"
|
image_folder_production = "screenshots_production/"
|
||||||
image_folder_qrcode = "qrcodes/"
|
image_folder_qrcode = "qrcodes/"
|
||||||
|
image_folder_barcharts = "barcharts/"
|
||||||
if(not os.path.exists(image_folder_map[:-1])):
|
if(not os.path.exists(image_folder_map[:-1])):
|
||||||
os.makedirs(image_folder_map[:-1], exist_ok=False)
|
os.makedirs(image_folder_map[:-1], exist_ok=False)
|
||||||
if(not os.path.exists(image_folder_production[:-1])):
|
# if(not os.path.exists(image_folder_production[:-1])):
|
||||||
os.makedirs(image_folder_production[:-1], exist_ok=False)
|
# os.makedirs(image_folder_production[:-1], exist_ok=False)
|
||||||
if (not os.path.exists(image_folder_qrcode[:-1])):
|
if (not os.path.exists(image_folder_qrcode[:-1])):
|
||||||
os.makedirs(image_folder_qrcode[:-1], exist_ok=False)
|
os.makedirs(image_folder_qrcode[:-1], exist_ok=False)
|
||||||
|
if (not os.path.exists(image_folder_barcharts[:-1])):
|
||||||
|
os.makedirs(image_folder_barcharts[:-1], exist_ok=False)
|
||||||
|
|
||||||
startTime = datetime.datetime.now()
|
startTime = datetime.datetime.now()
|
||||||
address_count = len(adress_list)
|
address_count = len(adress_list)
|
||||||
@@ -78,9 +90,12 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
|||||||
sumRoofArea = "not-found"
|
sumRoofArea = "not-found"
|
||||||
featureId = "not-found"
|
featureId = "not-found"
|
||||||
response_all_roofs_decoded = "not-found"
|
response_all_roofs_decoded = "not-found"
|
||||||
|
coordinates = ("not-found", "not-found")
|
||||||
found = True
|
found = True
|
||||||
line = adress_list[i]
|
line = adress_list[i]
|
||||||
adress = line.split(file_split_char)
|
adress = line.split(file_split_char)
|
||||||
|
barChartMonth = [0] * 12
|
||||||
|
barChartData = [0] * 12
|
||||||
if((line != adress_list[0]) and (adress[columnIndexes[6]] == "") and (((len(adress[columnIndexes[0]]) > 0) and (len(adress[columnIndexes[1]]) > 0) and (len(adress[columnIndexes[2]]) > 0) and (len(adress[columnIndexes[3]]) > 0)) or ((len(adress[columnIndexes[4]]) > 0) and (len(adress[columnIndexes[5]]) > 0)))):
|
if((line != adress_list[0]) and (adress[columnIndexes[6]] == "") and (((len(adress[columnIndexes[0]]) > 0) and (len(adress[columnIndexes[1]]) > 0) and (len(adress[columnIndexes[2]]) > 0) and (len(adress[columnIndexes[3]]) > 0)) or ((len(adress[columnIndexes[4]]) > 0) and (len(adress[columnIndexes[5]]) > 0)))):
|
||||||
address_string = adress[columnIndexes[0]] + " " + adress[columnIndexes[1]] + " " + adress[columnIndexes[2]] + " " + adress[columnIndexes[3]]
|
address_string = adress[columnIndexes[0]] + " " + adress[columnIndexes[1]] + " " + adress[columnIndexes[2]] + " " + adress[columnIndexes[3]]
|
||||||
print("searching for Address: " + address_string)
|
print("searching for Address: " + address_string)
|
||||||
@@ -132,9 +147,8 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
|||||||
response_one_roof = requests.get('https://api3.geo.admin.ch/rest/services/api/MapServer/identify',
|
response_one_roof = requests.get('https://api3.geo.admin.ch/rest/services/api/MapServer/identify',
|
||||||
params=params)
|
params=params)
|
||||||
response_one_roof_decoded = json.loads(response_one_roof.content.decode())
|
response_one_roof_decoded = json.loads(response_one_roof.content.decode())
|
||||||
results = (response_one_roof_decoded['results'])
|
# results = (response_one_roof_decoded['results'])
|
||||||
# for result in results:
|
|
||||||
# print(result)
|
|
||||||
building_id = (response_one_roof_decoded)['results'][0]['attributes']['building_id']
|
building_id = (response_one_roof_decoded)['results'][0]['attributes']['building_id']
|
||||||
except:
|
except:
|
||||||
found = False
|
found = False
|
||||||
@@ -158,19 +172,25 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
|||||||
suitabilities = []
|
suitabilities = []
|
||||||
bestRoofEnergy = 0
|
bestRoofEnergy = 0
|
||||||
bestRoof = response_all_roofs_decoded[0]
|
bestRoof = response_all_roofs_decoded[0]
|
||||||
|
barChartMonth = response_all_roofs_decoded[0]['attributes']['monate']
|
||||||
|
barChartData = [0] * 12
|
||||||
for roof in response_all_roofs_decoded:
|
for roof in response_all_roofs_decoded:
|
||||||
energy = float(roof['attributes']['gstrahlung'])*0.2*0.8
|
energy = float(roof['attributes']['gstrahlung'])*0.2*0.8
|
||||||
if(energy > bestRoofEnergy):
|
if(energy > bestRoofEnergy):
|
||||||
bestRoofEnergy = energy
|
bestRoofEnergy = energy
|
||||||
bestRoof = roof
|
bestRoof = roof
|
||||||
if(float(roof['attributes']['flaeche']) > minRoofSize and int(roof['attributes']['klasse']) >= minSuitability):
|
if(float(roof['attributes']['flaeche']) > minRoofSize and int(roof['attributes']['klasse']) >= minSuitability):
|
||||||
|
for month_count in range(12):
|
||||||
|
barChartData[month_count] = barChartData[month_count] + float(
|
||||||
|
roof['attributes']['monats_ertrag'][month_count]) * float(
|
||||||
|
roof['attributes']['flaeche']) * electricityPrice
|
||||||
sumEnergyRoofs = sumEnergyRoofs + energy
|
sumEnergyRoofs = sumEnergyRoofs + energy
|
||||||
sumRoofArea = sumRoofArea + float(roof['attributes']['flaeche'])
|
sumRoofArea = sumRoofArea + float(roof['attributes']['flaeche'])
|
||||||
suitabilities.append(int(roof['attributes']['klasse']) * float(roof['attributes']['flaeche']))
|
suitabilities.append(int(roof['attributes']['klasse']))
|
||||||
|
|
||||||
featureId = str(bestRoof['featureId'])
|
featureId = str(bestRoof['featureId'])
|
||||||
url = "https://www.uvek-gis.admin.ch/BFE/sonnendach/index.html?featureId=" + featureId + "&lang=de"
|
url = "https://www.uvek-gis.admin.ch/BFE/sonnendach/index.html?featureId=" + featureId + "&lang=de"
|
||||||
suitability = statistics.mean(suitabilities) / sumRoofArea
|
suitability = max(suitabilities)
|
||||||
value_electricity_production = sumEnergyRoofs * electricityPrice
|
value_electricity_production = sumEnergyRoofs * electricityPrice
|
||||||
else:
|
else:
|
||||||
found = False
|
found = False
|
||||||
@@ -179,10 +199,48 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
|||||||
|
|
||||||
roof_is_suitable = True # TODO decide if roof is suitable
|
roof_is_suitable = True # TODO decide if roof is suitable
|
||||||
|
|
||||||
if(found and createImages.get() > 0 and roof_is_suitable):
|
existing_solar_panel_power = "none"
|
||||||
image_filename = suitability + " - " + address_string + ".png"
|
roof_has_solarpanel = False # TODO check if roof has solar Panel
|
||||||
create_images(address_string, driver, image_filename, image_folder_map, image_folder_production, image_folder_qrcode,
|
|
||||||
url)
|
#Check if there is solar panel existing
|
||||||
|
address_string_for_existing_solarpanel = adress[columnIndexes[0]] + " " + adress[columnIndexes[1]] + ", " + adress[columnIndexes[2]] + " " + adress[columnIndexes[3]]
|
||||||
|
try:
|
||||||
|
params = {
|
||||||
|
'searchText': str(address_string_for_existing_solarpanel),
|
||||||
|
'searchField': 'address',
|
||||||
|
'layer': "ch.bfe.elektrizitaetsproduktionsanlagen",
|
||||||
|
'returnGeometry': 'false',
|
||||||
|
'contains': 'false'
|
||||||
|
}
|
||||||
|
repsonse_solar_panel = requests.get('https://api3.geo.admin.ch/rest/services/api/MapServer/find',
|
||||||
|
params=params)
|
||||||
|
repsonse_solar_panel_decoded = json.loads(repsonse_solar_panel.content.decode())
|
||||||
|
|
||||||
|
results = (repsonse_solar_panel_decoded['results'])
|
||||||
|
if(len(results) > 0):
|
||||||
|
existing_solar_panel_power = results[0]['attributes']['total_power']
|
||||||
|
|
||||||
|
except:
|
||||||
|
existing_solar_panel_power = "not-found"
|
||||||
|
roof_has_solarpanel = False
|
||||||
|
|
||||||
|
if(found and createImages.get() > 0 and roof_is_suitable and (not roof_has_solarpanel)):
|
||||||
|
image_filename = address_string + ".png"
|
||||||
|
|
||||||
|
barchart_color = ""
|
||||||
|
if(suitability == 1):
|
||||||
|
barchart_color = "#00c5ff"
|
||||||
|
elif(suitability == 2):
|
||||||
|
barchart_color = "#ffff00"
|
||||||
|
elif(suitability == 3):
|
||||||
|
barchart_color = "#ffaa00"
|
||||||
|
elif(suitability == 4):
|
||||||
|
barchart_color = "#ff5500"
|
||||||
|
elif(suitability == 5):
|
||||||
|
barchart_color = "#a80000"
|
||||||
|
|
||||||
|
create_images(address_string, driver, image_filename, image_folder_map, image_folder_production, image_folder_qrcode, image_folder_barcharts,
|
||||||
|
url, barChartMonth, barChartData, barchart_color)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
image_filename = "not-created"
|
image_filename = "not-created"
|
||||||
@@ -190,7 +248,7 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
|||||||
print("saving Address: " + address_string)
|
print("saving Address: " + address_string)
|
||||||
save_information_to_addresslist(adress, adress_list, columnIndexes, coordinates, file_split_char, i,
|
save_information_to_addresslist(adress, adress_list, columnIndexes, coordinates, file_split_char, i,
|
||||||
image_filename, sumEnergyRoofs, sumRoofArea, suitability, url,
|
image_filename, sumEnergyRoofs, sumRoofArea, suitability, url,
|
||||||
value_electricity_production)
|
value_electricity_production, existing_solar_panel_power)
|
||||||
|
|
||||||
save_addresslist_in_file(adress_list, filename_adresslist)
|
save_addresslist_in_file(adress_list, filename_adresslist)
|
||||||
|
|
||||||
@@ -220,7 +278,7 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
|||||||
|
|
||||||
def save_information_to_addresslist(adress, adress_list, columnIndexes, coordinates, file_split_char, list_index,
|
def save_information_to_addresslist(adress, adress_list, columnIndexes, coordinates, file_split_char, list_index,
|
||||||
image_filename, pv_Production100, roof_area, suitability, url,
|
image_filename, pv_Production100, roof_area, suitability, url,
|
||||||
value_electricity_production):
|
value_electricity_production, existing_solar_panel_power):
|
||||||
# Save Information in Addresslist
|
# Save Information in Addresslist
|
||||||
adress[columnIndexes[4]] = str(coordinates[0])
|
adress[columnIndexes[4]] = str(coordinates[0])
|
||||||
adress[columnIndexes[5]] = str(coordinates[1])
|
adress[columnIndexes[5]] = str(coordinates[1])
|
||||||
@@ -230,6 +288,7 @@ def save_information_to_addresslist(adress, adress_list, columnIndexes, coordina
|
|||||||
adress[columnIndexes[9]] = pv_Production100
|
adress[columnIndexes[9]] = pv_Production100
|
||||||
adress[columnIndexes[10]] = value_electricity_production
|
adress[columnIndexes[10]] = value_electricity_production
|
||||||
adress[columnIndexes[11]] = roof_area
|
adress[columnIndexes[11]] = roof_area
|
||||||
|
adress[columnIndexes[12]] = existing_solar_panel_power
|
||||||
new_line_string = ""
|
new_line_string = ""
|
||||||
for j in adress:
|
for j in adress:
|
||||||
new_line_string = new_line_string + str(j) + file_split_char
|
new_line_string = new_line_string + str(j) + file_split_char
|
||||||
@@ -290,7 +349,7 @@ def create_roof_info(roofs):
|
|||||||
info_text = info_text + str(i + 1) + ". Fläche\n" + "Potenzielle Energie: " + str(roofs[i]['attributes']['gstrahlung']*0.2*0.8) + "\nFläche: " + str(roofs[i]['attributes']['flaeche']) + "\nEignung: " + str(roofs[i]['attributes']['klasse']) + " (" + str(roofs[i]['attributes']['klasse_text']).split("##")[0] + ")\n\n"
|
info_text = info_text + str(i + 1) + ". Fläche\n" + "Potenzielle Energie: " + str(roofs[i]['attributes']['gstrahlung']*0.2*0.8) + "\nFläche: " + str(roofs[i]['attributes']['flaeche']) + "\nEignung: " + str(roofs[i]['attributes']['klasse']) + " (" + str(roofs[i]['attributes']['klasse_text']).split("##")[0] + ")\n\n"
|
||||||
return info_text
|
return info_text
|
||||||
|
|
||||||
def create_images(address_string, driver, image_filename, image_folder_map, image_folder_production, image_folder_qrcode, url):
|
def create_images(address_string, driver, image_filename, image_folder_map, image_folder_production, image_folder_qrcode, image_folder_barcharts, url, barChartMonth, barChartData, barchart_color):
|
||||||
driver.get(url)
|
driver.get(url)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
@@ -325,22 +384,54 @@ def create_images(address_string, driver, image_filename, image_folder_map, imag
|
|||||||
image_folder_map + image_filename)
|
image_folder_map + image_filename)
|
||||||
|
|
||||||
# Create Screenshot of Chart
|
# Create Screenshot of Chart
|
||||||
|
# try:
|
||||||
|
# chartElement = driver.find_elements(By.XPATH, "//div[@id='chart']//*")[0]
|
||||||
|
# location = chartElement.location
|
||||||
|
# size = chartElement.size
|
||||||
|
# x = location["x"]
|
||||||
|
# y = location["y"]
|
||||||
|
# w = x + size["width"]
|
||||||
|
# h = size["height"]
|
||||||
|
# area = (x, 0, w, h)
|
||||||
|
# driver.execute_script("window.scrollTo(0, " + str(y) + ")")
|
||||||
|
#
|
||||||
|
# time.sleep(1)
|
||||||
|
# driver.save_screenshot(image_folder_production + image_filename)
|
||||||
|
# time.sleep(0.2)
|
||||||
|
# Image.open(image_folder_production + image_filename).crop(area).save(
|
||||||
|
# image_folder_production + image_filename)
|
||||||
|
# except:
|
||||||
|
# pass
|
||||||
|
|
||||||
|
# Create barchar with matplotlib.pyplot
|
||||||
try:
|
try:
|
||||||
chartElement = driver.find_elements(By.XPATH, "//div[@id='chart']//*")[0]
|
barChartMonth.reverse()
|
||||||
location = chartElement.location
|
barChartMonth = [str(item) for item in barChartMonth]
|
||||||
size = chartElement.size
|
barChartData.reverse()
|
||||||
x = location["x"]
|
|
||||||
y = location["y"]
|
max_wert = max(barChartData)
|
||||||
w = x + size["width"]
|
min_wert = min(barChartData)
|
||||||
h = size["height"]
|
skala = max_wert + max_wert * 0.1
|
||||||
area = (x, 0, w, h)
|
|
||||||
driver.execute_script("window.scrollTo(0, " + str(y) + ")")
|
plt.figure(figsize=(7, 3))
|
||||||
|
plt.bar(barChartMonth, barChartData, color=barchart_color)
|
||||||
|
|
||||||
|
plt.ylabel('Stromproduktion in Franken', fontsize=12)
|
||||||
|
|
||||||
|
plt.ylim(0, skala)
|
||||||
|
|
||||||
|
# Turn off the frame (border) around the graphic
|
||||||
|
ax = plt.gca() # Get the current axis
|
||||||
|
ax.spines['top'].set_visible(False)
|
||||||
|
ax.spines['right'].set_visible(False)
|
||||||
|
ax.spines['bottom'].set_visible(False)
|
||||||
|
|
||||||
|
plt.xticks(barChartMonth)
|
||||||
|
# Set the x-axis limits to remove extra space on the right
|
||||||
|
# plt.xlim(barChartMonth[0], barChartMonth[-1])
|
||||||
|
|
||||||
|
plt.savefig(f"{image_folder_barcharts}{image_filename}", bbox_inches='tight')
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
driver.save_screenshot(image_folder_production + image_filename)
|
|
||||||
time.sleep(0.2)
|
|
||||||
Image.open(image_folder_production + image_filename).crop(area).save(
|
|
||||||
image_folder_production + image_filename)
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -348,9 +439,11 @@ def create_images(address_string, driver, image_filename, image_folder_map, imag
|
|||||||
def read_adresslist(filename_adresslist):
|
def read_adresslist(filename_adresslist):
|
||||||
returnvalues = []
|
returnvalues = []
|
||||||
try:
|
try:
|
||||||
|
print("reading File", filename_adresslist)
|
||||||
adress_file = open(filename_adresslist, "r", encoding="utf-8")
|
adress_file = open(filename_adresslist, "r", encoding="utf-8")
|
||||||
adress_list = adress_file.read().splitlines()
|
adress_list = adress_file.read().splitlines()
|
||||||
adress_file.close()
|
adress_file.close()
|
||||||
|
print("closed File", filename_adresslist)
|
||||||
returnvalues.append(True)
|
returnvalues.append(True)
|
||||||
returnvalues.append(adress_list)
|
returnvalues.append(adress_list)
|
||||||
except:
|
except:
|
||||||
@@ -485,5 +578,3 @@ button1.grid(row=3, column=1, padx=10, pady=3)
|
|||||||
button2 = tkinter.Button(frameButtons, text="EXIT", command=command_exit, width=20, height=2, bg="#FCCA03")
|
button2 = tkinter.Button(frameButtons, text="EXIT", command=command_exit, width=20, height=2, bg="#FCCA03")
|
||||||
button2.grid(row=3, column=2, padx=10, pady=3)
|
button2.grid(row=3, column=2, padx=10, pady=3)
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -2,7 +2,7 @@
|
|||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
search_string = "Toggenburgstrasse 31 8245 Feuerthalen"
|
search_string = "Mattenweg 29 5600 Lenzburg"
|
||||||
|
|
||||||
#Address to coordinates
|
#Address to coordinates
|
||||||
params={
|
params={
|
||||||
@@ -54,4 +54,6 @@ response_all_roofs = requests.get('https://api3.geo.admin.ch/rest/services/api/M
|
|||||||
response_all_roofs_decoded = json.loads(response_all_roofs.content.decode())['results']
|
response_all_roofs_decoded = json.loads(response_all_roofs.content.decode())['results']
|
||||||
for roof in response_all_roofs_decoded:
|
for roof in response_all_roofs_decoded:
|
||||||
# print(roof['attributes'].keys())
|
# print(roof['attributes'].keys())
|
||||||
print("URL:", "https://www.uvek-gis.admin.ch/BFE/sonnendach/index.html?featureId=" + str(roof['featureId']) + "&lang=de", "Fläche:", roof['attributes']['flaeche'], "Eignung(1-5):", roof['attributes']['klasse'], "PV100:", float(roof['attributes']['gstrahlung']*0.2*0.8))
|
print("URL:", "https://www.uvek-gis.admin.ch/BFE/sonnendach/index.html?featureId=" + str(roof['featureId']) + "&lang=de", "Fläche:", roof['attributes']['flaeche'], "Eignung(1-5):", roof['attributes']['klasse'], "PV100:", float(roof['attributes']['gstrahlung']*0.2*0.8))
|
||||||
|
|
||||||
|
print(roof)
|
||||||
Reference in New Issue
Block a user