forked from Silias-Public/Sonnendach
qr-codes with individual data
This commit is contained in:
parent
76733fd896
commit
7234a330a8
|
@ -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 = ","
|
||||
minRoofSize = 2
|
||||
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 = 5
|
||||
minSuitability = 3
|
||||
electricityPrice = 0.198
|
||||
electricityPrice = 0.11556
|
||||
electricityUsageFactor = 0.75
|
||||
OptionList = []
|
||||
exit = False
|
||||
|
@ -247,8 +249,20 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
|||
elif(suitability == 5):
|
||||
barchart_color = "#a80000"
|
||||
|
||||
qr_url = "https://nexs.ch/redirect?" + urlencode({
|
||||
"id": adress[columnIndexes[14]],
|
||||
"project": "PJ2505-0014",
|
||||
"target": "https://www.solosolar.ch/de/kontakt?" + urlencode({
|
||||
"firstname": adress[columnIndexes[15]],
|
||||
"lastname": adress[columnIndexes[16]],
|
||||
"adresse": f"{adress[columnIndexes[0]]} {adress[columnIndexes[1]]}",
|
||||
"zip": adress[columnIndexes[2]],
|
||||
"city": adress[columnIndexes[3]]
|
||||
}, quote_via=quote_plus)
|
||||
}, quote_via=quote_plus)
|
||||
|
||||
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"
|
||||
|
@ -352,13 +366,13 @@ 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.add_data(qr_url)
|
||||
qr.make(fit=True)
|
||||
qr.make_image(fill='black', back_color='white').save(image_folder_qrcode + image_filename)
|
||||
|
||||
|
@ -367,6 +381,11 @@ def create_images(address_string, driver, image_filename, image_folder_map, imag
|
|||
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 +398,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 +454,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
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import json
|
||||
import requests
|
||||
|
||||
search_string = "Toggenburgstrasse 31 8245 Feuerthalen"
|
||||
search_string = "Pelikanweg 51 3074 Muri b. Bern"
|
||||
|
||||
#Address to coordinates
|
||||
params={
|
||||
|
|
Loading…
Reference in New Issue