nens / threedi-schematisation-editor

QGIS tool for editing schematisations
0 stars 0 forks source link

GPKG to Spatialite: add validity check on cross_section_table inputs #70

Closed Patrick-Nijman closed 1 year ago

Patrick-Nijman commented 2 years ago

If the geopackage cross_section_table input cannot be correctly parsed to width / height series in the spatialite, data can be lost. Some examples:

  1. empty cross section table (NULL)
  2. cross section tables with extra blank line
  3. cross section table with space after comma
  4. cross section table with a . in stead of , between width and height

Suggested solution:

"Saving to Spatialite failed. The following features have cross sections with incorrect table inputs: Cross section location {ids} Culvert {ids} Orifice {ids} Pipe {ids} Weir {ids}"

caspervdw commented 2 years ago

Patrick: Not important to Lukasz, basically a description why Casper can't solve this in the model checker. I thought this needed fixing in the modelchecker. But it's the conversion from GPckg to Sqlite

Ik heb het lijstje afgelopen en ik begrijp eigenlijk alle punten niet. Ik vermoed dat dit over records in de v2_cross_section_definition table met een tabulated shape gaat (dus: shape = 5 of 6).

-empty cross section table (NULL)

Er is al een check op NULL waardes in de width kolom (error code 81) of height kolom (error code 82)

-cross section tables with extra blank line

Wat bedoel je precies? een newline aan het einde van width of height veld is valid input en geeft geen errors in gridbuilder.

-cross section table with space after comma

Er zitten geen komma's in de input

-cross section table with a . in stead of , between with and height

Width en height zitten in aparte velden; daar zit geen . of , tussen.

caspervdw commented 2 years ago

Discussed with @Patrick-Nijman -- issue is in the plugin (conversion gpkg -> sqlite)

ldebek commented 1 year ago

Changes available on branch: https://github.com/nens/threedi-schematisation-editor/tree/cross_section_table_validators

leendertvanwolfswinkel commented 1 year ago

I tested it. Test results:

ValueError: not enough values to unpack (expected 2, got 1) 
Traceback (most recent call last):
  File "C:\Users/leendert.vanwolfswin/AppData/Roaming/QGIS/QGIS3\profiles\Release candidates June 2022/python/plugins\threedi_schematisation_editor\__init__.py", line 195, in save_to_default
    self.save_to_spatialite(pick_destination=False)
  File "C:\Users/leendert.vanwolfswin/AppData/Roaming/QGIS/QGIS3\profiles\Release candidates June 2022/python/plugins\threedi_schematisation_editor\__init__.py", line 243, in save_to_spatialite
    converter.export_all_model_data()
  File "C:\Users/leendert.vanwolfswin/AppData/Roaming/QGIS/QGIS3\profiles\Release candidates June 2022/python/plugins\threedi_schematisation_editor\conversion.py", line 706, in export_all_model_data
    self.export_cross_section_definition_data()
  File "C:\Users/leendert.vanwolfswin/AppData/Roaming/QGIS/QGIS3\profiles\Release candidates June 2022/python/plugins\threedi_schematisation_editor\conversion.py", line 611, in export_cross_section_definition_data
    height_values, width_values = list(zip(*parsed_table))
ValueError: not enough values to unpack (expected 2, got 1)
leendertvanwolfswinkel commented 1 year ago

Tested again, all previously mentioned issues have been solved now, except for the last two:

ldebek commented 1 year ago

@leendertvanwolfswinkel Those 2 issues should be solved now.

leendertvanwolfswinkel commented 1 year ago

@ldebek Both issues are solved, but now I get several "Do you want to save changes to the layer Manhole" popups again (I think four times, between data validation and saving to spatialite.

This also happens if I toggle editing on for the Pipe layer and then off again, even when I haven't edited anything.

leendertvanwolfswinkel commented 1 year ago

More info to reproduce the issue:

ldebek commented 1 year ago

@leendertvanwolfswinkel Issue reported in comment above is not related with validation. It seems that there is an issue with handling NULL values in the custom forms comboboxes. Best to move it to the separate ticket.