Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4672ccef6e | ||
|
|
450b58e1e9 | ||
|
|
7234a330a8 |
+32
-30
@@ -1,6 +1,8 @@
|
||||
import tkinter
|
||||
import threading
|
||||
import matplotlib.pyplot as plt
|
||||
plt.switch_backend("Agg") # Set the backend dynamically
|
||||
from urllib.parse import urlencode, quote_plus
|
||||
|
||||
import selenium.webdriver.firefox.service
|
||||
import webdriver_manager.chrome
|
||||
@@ -24,11 +26,11 @@ import requests
|
||||
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 75", "Value Electricity production", "Roof area", "existing PV Production Power", "existing PV Production begining of operation"]
|
||||
file_split_char = ","
|
||||
DropDownLabels = ["Street: ", "Number: ", "Postal code: ", "City: ", "coordinate X", "coordinate Y", "Sonnendach URL: ", "Suitability:", "Image Filename: ", "PV Production 75", "Value Electricity production", "Roof area", "existing PV Production Power", "existing PV Production begining of operation","id", "firstname", "lastname"]
|
||||
file_split_char = ";"
|
||||
minRoofSize = 2
|
||||
minSuitability = 3
|
||||
electricityPrice = 0.198
|
||||
electricityPrice = 0.09976
|
||||
electricityUsageFactor = 0.75
|
||||
OptionList = []
|
||||
exit = False
|
||||
@@ -185,7 +187,7 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
||||
for month_count in range(12):
|
||||
barChartData[month_count] = barChartData[month_count] + float(
|
||||
roof['attributes']['monats_ertrag'][month_count]) * float(
|
||||
roof['attributes']['flaeche']) * electricityPrice
|
||||
roof['attributes']['flaeche']) * electricityPrice * 0.75
|
||||
sumEnergyRoofs = sumEnergyRoofs + energy
|
||||
sumRoofArea = sumRoofArea + float(roof['attributes']['flaeche'])
|
||||
suitabilities.append(int(roof['attributes']['klasse']))
|
||||
@@ -233,7 +235,7 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
||||
roof_has_solarpanel = False
|
||||
|
||||
if(found and createImages.get() > 0 and roof_is_suitable and (not roof_has_solarpanel)):
|
||||
image_filename = address_string + ".png"
|
||||
image_filename = adress[columnIndexes[14]] + " " + address_string + ".png"
|
||||
|
||||
barchart_color = ""
|
||||
if(suitability == 1):
|
||||
@@ -247,8 +249,10 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
||||
elif(suitability == 5):
|
||||
barchart_color = "#a80000"
|
||||
|
||||
qr_url = "https://nexs.ch"
|
||||
|
||||
create_images(address_string, driver, image_filename, image_folder_map, image_folder_production, image_folder_qrcode, image_folder_barcharts,
|
||||
url, barChartMonth, barChartData, barchart_color)
|
||||
url, barChartMonth, barChartData, barchart_color, qr_url)
|
||||
|
||||
else:
|
||||
image_filename = "not-created"
|
||||
@@ -265,14 +269,6 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
||||
print("Process is running since %d years %d months %d days %d hours %d minutes %d seconds" % (
|
||||
timediff.years, timediff.months, timediff.days, timediff.hours, timediff.minutes, timediff.seconds))
|
||||
|
||||
# if(found):
|
||||
# street = adress[columnIndexes[0]] + " " + adress[columnIndexes[1]]
|
||||
# plz = adress[columnIndexes[2]]
|
||||
# city = adress[columnIndexes[3]]
|
||||
# create_Partner_in_dolibarr(street, plz, city, coordinates, sumEnergyRoofs, sumRoofArea, suitability, featureId, url, response_all_roofs_decoded)
|
||||
|
||||
|
||||
|
||||
|
||||
if(stopThread == True):
|
||||
print("closing Thread")
|
||||
@@ -352,21 +348,26 @@ 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"
|
||||
return info_text
|
||||
|
||||
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):
|
||||
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, qr_url):
|
||||
driver.get(url)
|
||||
time.sleep(2)
|
||||
|
||||
# Create QR-Code
|
||||
qr = qrcode.QRCode(version=1, box_size=10, border=5)
|
||||
qr.add_data(url)
|
||||
qr.make(fit=True)
|
||||
qr.make_image(fill='black', back_color='white').save(image_folder_qrcode + image_filename)
|
||||
# qr = qrcode.QRCode(version=1, box_size=10, border=5)
|
||||
# qr.add_data(qr_url)
|
||||
# qr.make(fit=True)
|
||||
# qr.make_image(fill='black', back_color='white').save(image_folder_qrcode + image_filename)
|
||||
|
||||
# Create Screenshot of Map
|
||||
actions = ActionChains(driver)
|
||||
try:
|
||||
driver.execute_script("""var l = document.getElementsByClassName("ol-zoom ol-unselectable ol-control")[0];
|
||||
l.parentNode.removeChild(l);""")
|
||||
|
||||
# Marker entfernen
|
||||
# driver.execute_script("""var l = document.getElementsByClassName("marker ga-crosshair")[0];
|
||||
# l.parentNode.removeChild(l);""")
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -379,12 +380,13 @@ def create_images(address_string, driver, image_filename, image_folder_map, imag
|
||||
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_map + image_filename)
|
||||
time.sleep(0.2)
|
||||
Image.open(image_folder_map + image_filename).crop(area).save(
|
||||
image_folder_map + image_filename)
|
||||
mapElement.screenshot(image_folder_map + image_filename)
|
||||
# driver.execute_script("window.scrollTo(0, " + str(y) + ")")
|
||||
# time.sleep(1)
|
||||
# driver.save_screenshot(image_folder_map + image_filename)
|
||||
# time.sleep(0.2)
|
||||
# Image.open(image_folder_map + image_filename).crop(area).save(
|
||||
# image_folder_map + image_filename)
|
||||
|
||||
# Create Screenshot of Chart
|
||||
# try:
|
||||
@@ -434,7 +436,7 @@ def create_images(address_string, driver, image_filename, image_folder_map, imag
|
||||
# plt.xlim(barChartMonth[0], barChartMonth[-1])
|
||||
|
||||
plt.savefig(f"{image_folder_barcharts}{image_filename}", bbox_inches='tight')
|
||||
|
||||
plt.close('all')
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -464,10 +466,10 @@ def createFrameFileColums(headers):
|
||||
frameFileColums1.grid(row=2, column=1, padx=10, pady=3)
|
||||
|
||||
for i in range(len(DropDownLabels)):
|
||||
exec("text" + str(i+1) + " = tkinter.Label(frameFileColums1, text=\"" + DropDownLabels[i] + "\")")
|
||||
exec("text" + str(i+1) + ".grid(row=" + str(i+1) + ", column=1, padx=10, pady=3)")
|
||||
exec("dropdown" + str(i+1) + " = tkinter.OptionMenu(frameFileColums1, variablesDropdown[" + str(i) + "], *OptionList)")
|
||||
exec("dropdown" + str(i+1) + ".grid(row=" + str(i+1) + ", column=2, padx=10, pady=3)")
|
||||
text = tkinter.Label(frameFileColums1, text=DropDownLabels[i])
|
||||
text.grid(row=i + 1, column=1, padx=10, pady=3)
|
||||
dropdown = tkinter.OptionMenu(frameFileColums1, variablesDropdown[i], *OptionList)
|
||||
dropdown.grid(row=i+1, column=2, padx=10, pady=3)
|
||||
|
||||
def getColumnIndex():
|
||||
global OptionList
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
import json
|
||||
import requests
|
||||
|
||||
search_string = "Toggenburgstrasse 31 8245 Feuerthalen"
|
||||
search_string = "Blankweg 46 3072 Ostermundigen"
|
||||
|
||||
#Address to coordinates
|
||||
params={
|
||||
|
||||
Reference in New Issue
Block a user