diff --git a/WMS/Ortofoto.py b/WMS/Ortofoto.py index a2d9eb5..ed7ab7f 100644 --- a/WMS/Ortofoto.py +++ b/WMS/Ortofoto.py @@ -5,12 +5,12 @@ from dotenv import load_dotenv import json -def generate_orto(): +def generate_orto_picture(): # Finner path til .env filen som ligger i ngisopenapi mappen current_script_directory = os.path.dirname(os.path.abspath(__file__)) project_root = os.path.abspath(os.path.join(current_script_directory, '..', 'ngisopenapi')) env_file_path = os.path.join(project_root, '.env') - + coordinates_file_path = os.path.join(current_script_directory, 'resources', 'coordinates.json') # Laster .env fra riktig path load_dotenv(env_file_path) @@ -34,13 +34,13 @@ def generate_orto(): bbox = f'{min_x},{min_y},{max_x},{max_y}' # Setter directory for lagring av bilde - images_directory = "ortofoto_images" + images_directory = "rawphotos" # Lager hele pathen i samme mappe images_directory_path = os.path.join(current_script_directory, images_directory) # Sjekker om filen eksisterer - os.makedirs(images_directory_path, exist_ok=True) + #os.makedirs(images_directory_path, exist_ok=True) # Angi hvilke layers, bbox og hva enn du er interessert i params = { @@ -58,8 +58,6 @@ def generate_orto(): # Build and print the full URL full_url = f"{wms_url}?{encoded_params}" - print("Generated URL:") - print(full_url) # Headers som legger en browser request headers = { @@ -68,11 +66,11 @@ def generate_orto(): # Oppretter en get request til WMS serveren gjennom url og api nøkkel response = requests.get(full_url, headers=headers) # Ensure the request is made to `full_url` - + print("HELLO"); if response.status_code == 200: # Genererer et filnavn basert på dato og tid bildet ble hentet på - timestamp = datetime.now().strftime("%Y%m%d%H%M%S") - file_name = f"output_{timestamp}.png" + #timestamp = datetime.now().strftime("%Y%m%d%H%M%S") + file_name = f"orto.png" # Hele fil pathen image_path = os.path.join(images_directory_path, file_name) diff --git a/WMS/Sanderscript.py b/WMS/Sanderscript.py index aaf91e0..698b08c 100644 --- a/WMS/Sanderscript.py +++ b/WMS/Sanderscript.py @@ -27,13 +27,13 @@ def generate_wms_picture(): bbox = f'{min_x},{min_y},{max_x},{max_y}' # Velger et sted å lagre bildene - images_directory = "Fasitfoto" + images_directory = "rawphotos" # Lagrer alt i mappen definert - images_directory_path = os.path.join(images_directory) + images_directory_path = os.path.join(current_script_directory, images_directory) # Sjekker om filen eksisterer - os.makedirs(images_directory_path, exist_ok=True) + #os.makedirs(images_directory_path, exist_ok=True) # WMS parametere, de tomme feltene blir definert videre i koden wms_params = { @@ -54,8 +54,7 @@ def generate_wms_picture(): 'sld_body': '' } - # Spør som en input hvilket "Layers brukeren vil se" - layer_names = input("Enter LAYERS (layer names, comma-separated if multiple, Current layers are: veg,bru,bygning): ") + layer_names = "bygning" wms_params['LAYERS'] = layer_names # Starter SLD body @@ -95,8 +94,6 @@ def generate_wms_picture(): # Bygger og printer URLen med de riktige definerte WMS parameterene full_url = f"{base_url}?{encoded_params}" - print("Generated URL:") - print(full_url) # Headers som lager en browser request headers = { @@ -104,11 +101,10 @@ def generate_wms_picture(): } response = requests.get(full_url, headers=headers) - if response.status_code == 200: # Genererer et filnavn basert på dato og tid bildet ble hentet på - timestamp = datetime.now().strftime("%Y%m%d%H%M%S") - file_name = f"output_{timestamp}.png" + #timestamp = datetime.now().strftime("%Y%m%d%H%M%S") + file_name = f"fasit.png" # Hele fil pathen image_path = os.path.join(images_directory_path, file_name) @@ -118,5 +114,4 @@ def generate_wms_picture(): print(f"Bildet ble lagret i {image_path}.") else: print(f"Kunne ikke lagre bilde, statuskode: {response.status_code}") - -generate_wms_picture() + \ No newline at end of file diff --git a/WMS/Util.py b/WMS/Util.py index d30dcec..d9a9810 100644 --- a/WMS/Util.py +++ b/WMS/Util.py @@ -51,7 +51,7 @@ def split_image(image_path, output_folder, tile_size): tile.save(f"{output_folder}/tile_{i}_{i}.png") #Return the amount of tiles created - return horizontal_tiles + vertical_tiles + return horizontal_tiles def split_files(image_path, output_folder, tiles, training_fraction, validation_fraction): diff --git a/WMS/__pycache__/ortofoto.cpython-311.pyc b/WMS/__pycache__/ortofoto.cpython-311.pyc new file mode 100644 index 0000000..49f9a34 Binary files /dev/null and b/WMS/__pycache__/ortofoto.cpython-311.pyc differ diff --git a/WMS/__pycache__/sanderscript.cpython-311.pyc b/WMS/__pycache__/sanderscript.cpython-311.pyc new file mode 100644 index 0000000..cb69d3d Binary files /dev/null and b/WMS/__pycache__/sanderscript.cpython-311.pyc differ diff --git a/WMS/__pycache__/util.cpython-311.pyc b/WMS/__pycache__/util.cpython-311.pyc index 5de20bf..9cfd512 100644 Binary files a/WMS/__pycache__/util.cpython-311.pyc and b/WMS/__pycache__/util.cpython-311.pyc differ diff --git a/WMS/email/train/images/tile_0_0.png b/WMS/email/train/images/tile_0_0.png new file mode 100644 index 0000000..ac9805d Binary files /dev/null and b/WMS/email/train/images/tile_0_0.png differ diff --git a/WMS/email/train/images/tile_10_10.png b/WMS/email/train/images/tile_10_10.png new file mode 100644 index 0000000..b6a2113 Binary files /dev/null and b/WMS/email/train/images/tile_10_10.png differ diff --git a/WMS/email/train/images/tile_11_11.png b/WMS/email/train/images/tile_11_11.png new file mode 100644 index 0000000..62204a8 Binary files /dev/null and b/WMS/email/train/images/tile_11_11.png differ diff --git a/WMS/email/train/images/tile_1_1.png b/WMS/email/train/images/tile_1_1.png index 51a6b3e..9e49137 100644 Binary files a/WMS/email/train/images/tile_1_1.png and b/WMS/email/train/images/tile_1_1.png differ diff --git a/WMS/email/train/images/tile_2_2.png b/WMS/email/train/images/tile_2_2.png index 894ba60..75f1290 100644 Binary files a/WMS/email/train/images/tile_2_2.png and b/WMS/email/train/images/tile_2_2.png differ diff --git a/WMS/email/train/images/tile_3_3.png b/WMS/email/train/images/tile_3_3.png index 2eae7b0..e23fdbe 100644 Binary files a/WMS/email/train/images/tile_3_3.png and b/WMS/email/train/images/tile_3_3.png differ diff --git a/WMS/email/train/images/tile_4_4.png b/WMS/email/train/images/tile_4_4.png index 2e9cef8..4c38f25 100644 Binary files a/WMS/email/train/images/tile_4_4.png and b/WMS/email/train/images/tile_4_4.png differ diff --git a/WMS/email/train/images/tile_5_5.png b/WMS/email/train/images/tile_5_5.png index 53c0855..e794c3d 100644 Binary files a/WMS/email/train/images/tile_5_5.png and b/WMS/email/train/images/tile_5_5.png differ diff --git a/WMS/email/train/images/tile_6_6.png b/WMS/email/train/images/tile_6_6.png index 72b5014..7022ac2 100644 Binary files a/WMS/email/train/images/tile_6_6.png and b/WMS/email/train/images/tile_6_6.png differ diff --git a/WMS/email/train/images/tile_7_7.png b/WMS/email/train/images/tile_7_7.png index ad6338f..7a14ec8 100644 Binary files a/WMS/email/train/images/tile_7_7.png and b/WMS/email/train/images/tile_7_7.png differ diff --git a/WMS/email/train/images/tile_8_8.png b/WMS/email/train/images/tile_8_8.png index 9293b8d..078c04b 100644 Binary files a/WMS/email/train/images/tile_8_8.png and b/WMS/email/train/images/tile_8_8.png differ diff --git a/WMS/email/train/images/tile_9_9.png b/WMS/email/train/images/tile_9_9.png new file mode 100644 index 0000000..d7becae Binary files /dev/null and b/WMS/email/train/images/tile_9_9.png differ diff --git a/WMS/email/train/masks/tile_0_0.png b/WMS/email/train/masks/tile_0_0.png new file mode 100644 index 0000000..a5435f2 Binary files /dev/null and b/WMS/email/train/masks/tile_0_0.png differ diff --git a/WMS/email/train/masks/tile_10_10.png b/WMS/email/train/masks/tile_10_10.png new file mode 100644 index 0000000..a5435f2 Binary files /dev/null and b/WMS/email/train/masks/tile_10_10.png differ diff --git a/WMS/email/train/masks/tile_11_11.png b/WMS/email/train/masks/tile_11_11.png new file mode 100644 index 0000000..87f395e Binary files /dev/null and b/WMS/email/train/masks/tile_11_11.png differ diff --git a/WMS/email/train/masks/tile_1_1.png b/WMS/email/train/masks/tile_1_1.png index 3f60232..a5435f2 100644 Binary files a/WMS/email/train/masks/tile_1_1.png and b/WMS/email/train/masks/tile_1_1.png differ diff --git a/WMS/email/train/masks/tile_2_2.png b/WMS/email/train/masks/tile_2_2.png index 5f85b1d..a5435f2 100644 Binary files a/WMS/email/train/masks/tile_2_2.png and b/WMS/email/train/masks/tile_2_2.png differ diff --git a/WMS/email/train/masks/tile_3_3.png b/WMS/email/train/masks/tile_3_3.png index db4731b..a5435f2 100644 Binary files a/WMS/email/train/masks/tile_3_3.png and b/WMS/email/train/masks/tile_3_3.png differ diff --git a/WMS/email/train/masks/tile_4_4.png b/WMS/email/train/masks/tile_4_4.png index 89a9435..a5435f2 100644 Binary files a/WMS/email/train/masks/tile_4_4.png and b/WMS/email/train/masks/tile_4_4.png differ diff --git a/WMS/email/train/masks/tile_5_5.png b/WMS/email/train/masks/tile_5_5.png index 94caf44..a5435f2 100644 Binary files a/WMS/email/train/masks/tile_5_5.png and b/WMS/email/train/masks/tile_5_5.png differ diff --git a/WMS/email/train/masks/tile_6_6.png b/WMS/email/train/masks/tile_6_6.png index 439ff78..a5435f2 100644 Binary files a/WMS/email/train/masks/tile_6_6.png and b/WMS/email/train/masks/tile_6_6.png differ diff --git a/WMS/email/train/masks/tile_7_7.png b/WMS/email/train/masks/tile_7_7.png index 7657e70..a5435f2 100644 Binary files a/WMS/email/train/masks/tile_7_7.png and b/WMS/email/train/masks/tile_7_7.png differ diff --git a/WMS/email/train/masks/tile_8_8.png b/WMS/email/train/masks/tile_8_8.png index b99c2e3..f5541e4 100644 Binary files a/WMS/email/train/masks/tile_8_8.png and b/WMS/email/train/masks/tile_8_8.png differ diff --git a/WMS/email/train/masks/tile_9_9.png b/WMS/email/train/masks/tile_9_9.png new file mode 100644 index 0000000..75d08b1 Binary files /dev/null and b/WMS/email/train/masks/tile_9_9.png differ diff --git a/WMS/email/val/images/tile_0_0.png b/WMS/email/val/images/tile_0_0.png deleted file mode 100644 index 51a6b3e..0000000 Binary files a/WMS/email/val/images/tile_0_0.png and /dev/null differ diff --git a/WMS/email/val/images/tile_12_12.png b/WMS/email/val/images/tile_12_12.png new file mode 100644 index 0000000..203db31 Binary files /dev/null and b/WMS/email/val/images/tile_12_12.png differ diff --git a/WMS/email/val/images/tile_13_13.png b/WMS/email/val/images/tile_13_13.png new file mode 100644 index 0000000..fed3b14 Binary files /dev/null and b/WMS/email/val/images/tile_13_13.png differ diff --git a/WMS/email/val/images/tile_14_14.png b/WMS/email/val/images/tile_14_14.png new file mode 100644 index 0000000..978cdf6 Binary files /dev/null and b/WMS/email/val/images/tile_14_14.png differ diff --git a/WMS/email/val/images/tile_15_15.png b/WMS/email/val/images/tile_15_15.png new file mode 100644 index 0000000..f1bbe54 Binary files /dev/null and b/WMS/email/val/images/tile_15_15.png differ diff --git a/WMS/email/val/masks/tile_0_0.png b/WMS/email/val/masks/tile_0_0.png deleted file mode 100644 index 3f60232..0000000 Binary files a/WMS/email/val/masks/tile_0_0.png and /dev/null differ diff --git a/WMS/email/val/masks/tile_12_12.png b/WMS/email/val/masks/tile_12_12.png new file mode 100644 index 0000000..fd1a69e Binary files /dev/null and b/WMS/email/val/masks/tile_12_12.png differ diff --git a/WMS/email/val/masks/tile_13_13.png b/WMS/email/val/masks/tile_13_13.png new file mode 100644 index 0000000..a5435f2 Binary files /dev/null and b/WMS/email/val/masks/tile_13_13.png differ diff --git a/WMS/email/val/masks/tile_14_14.png b/WMS/email/val/masks/tile_14_14.png new file mode 100644 index 0000000..a5435f2 Binary files /dev/null and b/WMS/email/val/masks/tile_14_14.png differ diff --git a/WMS/email/val/masks/tile_15_15.png b/WMS/email/val/masks/tile_15_15.png new file mode 100644 index 0000000..3c9558a Binary files /dev/null and b/WMS/email/val/masks/tile_15_15.png differ diff --git a/WMS/rawphotos/fasit.png b/WMS/rawphotos/fasit.png index 37e7981..bd8f685 100644 Binary files a/WMS/rawphotos/fasit.png and b/WMS/rawphotos/fasit.png differ diff --git a/WMS/rawphotos/orto.png b/WMS/rawphotos/orto.png index 95bb9c7..64450b2 100644 Binary files a/WMS/rawphotos/orto.png and b/WMS/rawphotos/orto.png differ diff --git a/WMS/resources/config.json b/WMS/resources/config.json index 8b1d465..2b86c57 100644 --- a/WMS/resources/config.json +++ b/WMS/resources/config.json @@ -1 +1 @@ -{"Config": {"data_parameters": ["90", "10", "10"], "layers": ["Bygning", "Veg", "Bru"], "colors": ["#000000", "#ffff00", "#00ff00"]}} \ No newline at end of file +{"Config": {"data_parameters": ["70", "30", "10"], "layers": ["Bygning", "Veg", "Bru"], "colors": ["#000000", "#ffff00", "#00ff00"]}} \ No newline at end of file diff --git a/__pycache__/main.cpython-311.pyc b/__pycache__/main.cpython-311.pyc index 1a7c50d..220d254 100644 Binary files a/__pycache__/main.cpython-311.pyc and b/__pycache__/main.cpython-311.pyc differ diff --git a/main.py b/main.py index e17056d..e7f8898 100644 --- a/main.py +++ b/main.py @@ -24,7 +24,8 @@ from pydantic import BaseModel from deleteFolder import delete_all_folders from WMS import util -from WMS import Orotfoto +from WMS import ortofoto +from WMS import sanderscript # Class for the FastAPI. Will contain all our methods for updating values and starting scripts @@ -321,13 +322,13 @@ async def generatePhotos(): config = data["Config"]; - #Her må de forskjellige WMSene plugges inn - #generate_wms_picture(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) - #generate_wms_photo(coordinates, config) + #Genererer bilder fra de forskjellige WMSene + fasit_path = sanderscript.generate_wms_picture() + orto_path = ortofoto.generate_orto_picture() #Også må de riktige urlene plugges inn som image_path util.split_image("WMS/rawphotos/fasit.png", "WMS/tiles/fasit", 100) tiles = util.split_image("WMS/rawphotos/orto.png", "WMS/tiles/orto", 100) + print("TILES:" + str(tiles)); util.split_files("WMS/tiles", "WMS/email", tiles, config["data_parameters"][0], config["data_parameters"][1]) -