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

27 Tallenna kaava jsonina #76

Merged
merged 3 commits into from
Dec 4, 2024
Merged

27 Tallenna kaava jsonina #76

merged 3 commits into from
Dec 4, 2024

Conversation

Mtk112
Copy link
Contributor

@Mtk112 Mtk112 commented Nov 21, 2024

  • Lisätty "Tallenna kaava JSON" nappi, joka tallentaa aktiivisen kaavan ja sen ulkorajan JSON muodossa käyttäjän valitsemaan paikkaan.

  • Lisätty QNetworkProxy, jotta voidaan käyttä AWS:llä olevaa lambdaa.

  • Asetukset muokattu, korvattu lambda isäntä ja -portti proxyn isännällä ja -portilla. Lisätty lambdan osoite.

  • Lisätty kaavan nimen haku. Jos kaavalle ei ole annettu suomenkielistä nimeä, ulkoraja JSONiin asetetaan nimeksi "Nimetön".

  • Lisätty mahdollisuus käyttää paikallista dockerissa olevaa lambdaa.
    Paikallisen lambdan käyttämisesksi, asetuksiin tulee asettaa tyhjä Proxy isäntä ja Proxy portti, sekä lambdan osoite asettaa:
    http://localhost:8083/2015-03-31/functions/function/invocations

  • Molemmat (AWS ja paikallinen) lambdat testattu.

@Mtk112 Mtk112 self-assigned this Nov 21, 2024
@Mtk112 Mtk112 added the enhancement New feature or request label Nov 21, 2024
@Mtk112 Mtk112 changed the title 27 Tallenna/vie kaava jsonina 27 Tallenna kaava jsonina Nov 21, 2024
This was linked to issues Nov 27, 2024
@Mtk112 Mtk112 marked this pull request as ready for review November 27, 2024 07:44
Copy link
Contributor

@LKajan LKajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hienoa, että sait toimimaan!

Comment on lines 10 to 20
class SerializePlan(QDialog, FormClass): # type: ignore
def __init__(self):
super().__init__()
self.setupUi(self)

self.plan_outline_path_edit = self.findChild(QLineEdit, "plan_outline_path_edit")
self.plan_path_edit = self.findChild(QLineEdit, "plan_path_edit")
self.plan_outline_select_button = self.findChild(QPushButton, "plan_outline_select_button")
self.plan_select_button = self.findChild(QPushButton, "plan_select_button")

self.plan_outline_select_button.clicked.connect(self.select_plan_outline_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.findChild:t taitaa olla turhia tässä tapauksessa. setupUi() lataa kaikki muuttujat luokalle, jolloin ne on kyllä olemassa ilman findChild-kutsuja. Tyypityksen saa toimimaan kun ne määrittää "luokkamuuttujiksi".

Suggested change
class SerializePlan(QDialog, FormClass): # type: ignore
def __init__(self):
super().__init__()
self.setupUi(self)
self.plan_outline_path_edit = self.findChild(QLineEdit, "plan_outline_path_edit")
self.plan_path_edit = self.findChild(QLineEdit, "plan_path_edit")
self.plan_outline_select_button = self.findChild(QPushButton, "plan_outline_select_button")
self.plan_select_button = self.findChild(QPushButton, "plan_select_button")
self.plan_outline_select_button.clicked.connect(self.select_plan_outline_file)
class SerializePlan(QDialog, FormClass): # type: ignore
plan_outline_path_edit: QLineEdit
plan_path_edit: QLineEdit
plan_outline_select_button: QPushButton
plan_select_button: QPushButton
def __init__(self):
super().__init__()
self.setupUi(self)
self.plan_outline_select_button.clicked.connect(self.select_plan_outline_file)

# Build the structured outline JSON and write to file
outline_json = {
"type": "Feature",
"properties": {"name": "Example Polygon"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saisiko nimeksi kaavan nimen

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lambdoille kommunikoinnin voisi siirtää kokonaan omaan moduuliin. Plan managerissa voisi edelleen olla get_plan_json(), joka sitten kutsuisi tätä toisessa moduulissa olevaa koodia.

@Mtk112 Mtk112 force-pushed the 27-tallenna/vie-kaava-jsonina branch from fa6f2dc to bcdaf92 Compare November 29, 2024 03:26
Comment on lines 78 to 91
outline_json = None
if plan_json:
geographical_area = plan_json.get("geographicalArea")
if geographical_area:
outline_name = get_plan_name(plan_id, language="fin")
outline_json = {
"type": "Feature",
"properties": {"name": outline_name},
"srid": geographical_area.get("srid"),
"geometry": geographical_area.get("geometry"),
}

if outline_json is None:
outline_json = {} # Fallback to empty dictionary if no outline JSON is created
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outline_json voidaan asettaa heti alkuun defaultiksi.

Suggested change
outline_json = None
if plan_json:
geographical_area = plan_json.get("geographicalArea")
if geographical_area:
outline_name = get_plan_name(plan_id, language="fin")
outline_json = {
"type": "Feature",
"properties": {"name": outline_name},
"srid": geographical_area.get("srid"),
"geometry": geographical_area.get("geometry"),
}
if outline_json is None:
outline_json = {} # Fallback to empty dictionary if no outline JSON is created
outline_json = {}
if plan_json:
geographical_area = plan_json.get("geographicalArea")
if geographical_area:
outline_name = get_plan_name(plan_id, language="fin")
outline_json = {
"type": "Feature",
"properties": {"name": outline_name},
"srid": geographical_area.get("srid"),
"geometry": geographical_area.get("geometry"),
}

- Added UI for selecting path for saving JSONs
- Added get_plan_json that calls lambda with the active_plan_id. The JSONs are extracted from the response and saved at user defined location.
- Changed default lambda port.

Refactor get_plan_json.

Changed lambda call to use QNetworkRequest and created the required QNetworkProxy.

Changed settings to store Proxy host and port. Added lambda url to settings.

Cleanup
- Moved lambda request and response handling to their own module.
- Added capability to use local docker lambdas.
- Added utility to get plan name with plan_id from "Kaava" layer.

Update lambda_service.py
Initialize or reset proxy each time before request is sent.
Create LambdaService object when button is pressed.
Removed redundant code.
@Mtk112 Mtk112 force-pushed the 27-tallenna/vie-kaava-jsonina branch from e4161fa to 4d8202d Compare December 3, 2024 15:17
@Mtk112 Mtk112 merged commit 00abcb0 into main Dec 4, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tallenna kaavan ulkoraja jsonina Tallenna/vie kaava jsonina
2 participants