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

Update facilities tableDevelop update Facilities DB from reviewed geopackage #15

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

pkinglinz
Copy link
Contributor

Upload reviewed gpkg to the temp_facilities table in the database
Update facilities table

  • update attributes on “facilities” table from temp upload table, based on “sql”
  • update geometries on “facilities” table from temp upload table, based on “geometry_change” and feature geometry

copy of symlink the update_facilities folder of the repo to your plugin directory in qgis, I used ln -s ~/dev/nz-facilities/update_facilities/ ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins

create the config
the plugin connects to db via a config file. This file is autogenerated if it doesn't exist but user will need to find and update the link to the database.
image
then navigate to the update_facilities folder and select the config.ini file

I suggest you create a test db to connect to, this is the dump file I was using and the command used on ubuntu to restore it
https://linzsrm.sharepoint.com/:u:/s/Topography/ES9g9Rysll5IpQEPoyBG2Q0BXP3iYNAu8_quettsfsjoXg?e=eI2N8l

pg_restore -h localhost -p 5432 -d facilities_test_db -U postgres -O -v -x --no-table-access-method "/home/pking/dev/nz-facilities/change_detection/facilities_dump/facilities.backup"

you will need to add the logging tables and update the temp_facilities table, there is an sql file with some quick code to do this in the sharepoint folder mentioned above

I have also put test data and an output from the facilities script in the share point

fixed name of MoE schools layer on data.govt. Assume it is changed everytime they update the layer
set up plugin, my file is update_facilities.py. tes_dbconn.py test the database connection, update_temp_facilities.py handles updating the temp_facilities table in the database. A config will be created with correct sections but will need to be manually configured
Updates facilities table using the temp table and attribute in the change_action column. If errors are encountered it is rolled back.
Test before running updates. Move run to class. Text red on fail, green on pass.
Logging via DB so anyone from team can access. Logs what task it is doing, when starts task, errors and final result of task.
logs single line of added, delete, modified geom, mod attr and modified both geom and attr
Now only logs results when successful. Added type hints to logging function
@pkinglinz pkinglinz self-assigned this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant