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

Analyse flood risk for buildings #36

Open
leendertvanwolfswinkel opened this issue Sep 10, 2024 · 20 comments
Open

Analyse flood risk for buildings #36

leendertvanwolfswinkel opened this issue Sep 10, 2024 · 20 comments
Assignees

Comments

@leendertvanwolfswinkel
Copy link
Collaborator

leendertvanwolfswinkel commented Sep 10, 2024

UI

  1. Add a "Flood risk buildings button" to the Simulation results tab

image.png

  1. Enable the button if the scenario contains a result with the result code depth-max-dtri and/or s1-max-dtri.

  2. When the user clicks the button, show a dialog where they can fill in the following inputs:

  • Method: DGBC (default) or Advanced. DGBC should only be available if the scenario contains a result with result code depth-max-dtri. Advanced should be available only when there is a s1-max-dtri result
  • Buildings: Polygon vector layer.
  • Floor level column: only enable this option if Method is Advanced. User should be able to choose any float column present in the selected layer. Automatically switch to "floor_level" if that column is available.
  • Output format: GeoPackage (default) or GeoJSON.
  1. OK/Cancel buttons

API requests / workflow

  1. Save the selected buildings to a geopackage, in a layer that has a field "floor_level" that is a copy of the column that the user indicated they want to use as floor level.

  2. Create a "buildings" result object for the scenario

curl -u "__key__:<API_TOKEN>" -d '{"name": "buildings", "code": "buildings", "family": "Raw"}' --header "Content-Type: application/json" https://nxt3.staging.lizard.net/api/v4/scenarios/<SCENARIO_UUID>/results/
  1. The buildings result object for the scenario will now contain an upload_url . The building features need to be uploaded to this url:
curl -T test-buildings.gpkg "<UPLOAD_URL>"
  1. Create an object to store the outputs to (a "vulnerable buildings" object) for this scenario
curl -u "__key__:<API_TOKEN>" -d '{"name": "vulnerable_buildings", "code": "vulnerable_buildings", "family": "Vulnerable_Buildings"}' --header "Content-Type: application/json" https://nxt3.staging.lizard.net/api/v4/scenarios/<SCENARIO_UUID>/results/
  1. Start processingof the vulnerable_buildings result
curl -u "__key__:<API_TOKEN>" -d '{"method": "advanced"}' --header "Content-Type: application/json" https://nxt3.staging.lizard.net/api/v4/scenarios/<SCENARIO_UUID>/results/<RESULT_ID>/process
  1. Track the progress
https://nens.lizard.net/api/v4/tasks/<TASK UUID>/

When the processing is finished

Once the processing is finished, refresh the "downloadable files" list. The vulnerable buildings result should appear in the list

@ldebek ldebek self-assigned this Sep 27, 2024
@ldebek
Copy link
Collaborator

ldebek commented Sep 30, 2024

@leendertvanwolfswinkel Few questions:

  1. Is method name (DGBC or Advanced) should be passed somewhere within the API call or distinction is only definded by the "floor_level" column presence?
  2. Where "total_rain_mm": 42 paylod for the start processing call comes from? Could you please elaborate it?

@leendertvanwolfswinkel
Copy link
Collaborator Author

@benvanbasten-ns I think you created these endpoints, right? Can you help out @ldebek please

@benvanbasten-ns
Copy link
Contributor

benvanbasten-ns commented Oct 3, 2024

Hi @ldebek

1 The method name should be passed in the \process api call. It should either be "dgbc" or "advanced". I changed the API description in this issue
The output format (gpkg or geojson) can also be passed to the API (output_format: gpkg (default) or geojson), just like method.

2 total_rain_mm is no longer required.

As for the floor_level. In case the method is "advanced", the buildings geopackage should contain a "floor_level" attribute.

Regarding the floor level column: this is not configurable in the backend. This column with this particular name should be added in the frontend, if necessary.

@ldebek
Copy link
Collaborator

ldebek commented Oct 4, 2024

@benvanbasten-ns Thanks for clarification. I have one more question - is RESULT_ID in the process endpoint refers to the buildings result or vulnerable_buildings?

@benvanbasten-ns
Copy link
Contributor

@ldebek Good question. That refers to the vulnerable_buildings result.

@ldebek
Copy link
Collaborator

ldebek commented Oct 4, 2024

@benvanbasten-ns Thanks - one more request. It seems I don't have an access to the staging Lizard (https://nxt3.staging.lizard.net/) - could you please sort that out for me? 😃

@benvanbasten-ns
Copy link
Contributor

@ldebek I think I can. Did you receive an invitation mail?

@ldebek
Copy link
Collaborator

ldebek commented Oct 4, 2024

@benvanbasten-ns Unfortunately not.

@benvanbasten-ns
Copy link
Contributor

@ldebek And now ?

@ldebek
Copy link
Collaborator

ldebek commented Oct 4, 2024

@benvanbasten-ns Got it - thanks!
P.S. Cannot obtain API key

@benvanbasten-ns
Copy link
Contributor

@ldebek Ok, I've given you the right permissions, I think. You should be able to go to https://nxt3.staging.lizard.net/ -> management -> personal api keys

@ldebek
Copy link
Collaborator

ldebek commented Oct 4, 2024

@benvanbasten-ns All works great now - thanks again! :)

@ldebek
Copy link
Collaborator

ldebek commented Oct 9, 2024

Hi @benvanbasten-ns . I have a problem with creating new result for buildings. Getting 403 code during attempt of POST request to https://nxt3.staging.lizard.net/api/v4/scenarios/9b385b9f-2f85-459d-9c2d-0942d78b836a/results/ with {"name": "buildings", "code": "buildings", "family": "Raw"} data. Response message is: {"status":403,"code":10,"message":"Permission denied. #403.10","detail":"You do not have permission to perform this action."} Am I missing something or is it just an insufficient access rights issue?

@benvanbasten-ns
Copy link
Contributor

@ldebek Sorry voor de late response. I've changed your permission. I think you should be able to do it now.

@ldebek
Copy link
Collaborator

ldebek commented Oct 10, 2024

@benvanbasten-ns Thanks Ben. I have another question now - is there a way to remove/overwrite previously created 'buildings' result?
EDIT: I was able to call DELETE method on buildings result and it's not listed in the scenario results... but while trying to recreate buildings result I'm getting 400 code with following message: Per scenario, a result's code must be unique.

@benvanbasten-ns
Copy link
Contributor

@ldebek Yes, that's expected behavior. When you delete something, I becomes marked for deletion (and hidden), and will be deleted after X days. Unfortunately, it will remain in the database for that period... I'll check if I can delete it from the DB

@benvanbasten-ns
Copy link
Contributor

@ldebek for which scenario are you trying to recreate the result?

@ldebek
Copy link
Collaborator

ldebek commented Oct 11, 2024

@benvanbasten-ns This one: https://nxt3.staging.lizard.net/api/v4/scenarios/9b385b9f-2f85-459d-9c2d-0942d78b836a/ . Btw. I'm wondering how to best handle case if processing of the buildings fails for some user and user would like to retry whole workflow? Any hints how should it be done to avoid waiting for deleting from DB to happen?

@benvanbasten-ns
Copy link
Contributor

@ldebek I could not find a buildings result in this scenario. Could it be that it has been cleaned up already? Can you try again?

We are currently thinking about ways to avoid the problem you mention.

@ldebek
Copy link
Collaborator

ldebek commented Oct 16, 2024

@leendertvanwolfswinkel @benvanbasten-ns I've implemented requested functionality, with limitation for cases if user want to re-run analysis for the same scenario. Even if plugin is deleting existing buildings and vulnerable_buildings results for the scenario, process still will fail with a message saying that those 2 results still exist. In such case user have to wait untill results will be actually deleted on the server and re-run the analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants