Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

la til slik at bbox endres ved nye coordinate inputs #157

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions WMS/Orotfoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from datetime import datetime
import urllib.parse
from dotenv import load_dotenv
import json

# Finner path til .env filen som ligger i ngisopenapi mappen
current_script_directory = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -18,11 +19,24 @@
# Definerer WMS url
wms_url = 'https://waapi.webatlas.no/wms-orto/'

# Leser inn koordinatene fra JSON-filen
coordinates_file_path = os.path.join(current_script_directory, 'resources', 'coordinates.json')
with open(coordinates_file_path, 'r') as file:
data = json.load(file)
coordinates = data['Coordinates']

# Beregner bbox fra koordinatene gitt i applikasjonen
min_x = min(coord[0] for coord in coordinates)
min_y = min(coord[1] for coord in coordinates)
max_x = max(coord[0] for coord in coordinates)
max_y = max(coord[1] for coord in coordinates)
bbox = f'{min_x},{min_y},{max_x},{max_y}'

# Setter directory for lagring av bilde
images_directory = "ortofoto_images"

# Lager hele pathen i samme mappe
images_directory_path = os.path.join(os.path.dirname(__file__), 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)
Expand All @@ -36,7 +50,7 @@
"layers": "ortofoto",
"srs": "EPSG:25832",
'format': 'image/png', # Fil format
'bbox': '751773.690167,7456391.139281,751983.690167,7456601.139281',
'bbox': bbox, # Oppdaterer bbox med de nye verdiene
}

encoded_params = urllib.parse.urlencode(params, quote_via=urllib.parse.quote)
Expand Down
Binary file removed WMS/ortofoto_images/output_20240216104419.png
Binary file not shown.
2 changes: 1 addition & 1 deletion WMS/resources/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Config": {"data_parameters": ["45", "10", "5"], "layers": ["Bygning", "Veg", "Bru"], "colors": ["#000000", "#ffff00", "#00ff00"]}}
{"Config": {"data_parameters": ["60", "40", "5"], "layers": ["Bygning", "Veg", "Bru"], "colors": ["#000000", "#ffff00", "#00ff00"]}}
2 changes: 1 addition & 1 deletion WMS/resources/coordinates.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Coordinates": [[591803.8064666329, 6632754.836968331], [591772.9451496319, 6634003.758540891], [593562.4436277907, 6634048.411673315], [593593.906886548, 6632799.500037341], [591803.8064666329, 6632754.836968331]]}
{"Coordinates": [[588751.5420105711, 6642899.275265058], [588749.8344259012, 6642970.498298281], [589238.8910459754, 6642982.255880976], [589240.6080427505, 6642911.032997987], [588751.5420105711, 6642899.275265058]]}
Binary file added __pycache__/deleteFolder.cpython-311.pyc
Binary file not shown.