Skip to content

Change the backend for xlsformconverter to use the new convert2json library#23

Open
suricactus wants to merge 25 commits into
mainfrom
json2qgis
Open

Change the backend for xlsformconverter to use the new convert2json library#23
suricactus wants to merge 25 commits into
mainfrom
json2qgis

Conversation

@suricactus
Copy link
Copy Markdown
Collaborator

@suricactus suricactus commented Mar 16, 2026

Instead of directly parsing and converting the xlsform into a QGIS project, we add an intermediate step:

  1. xlsform - parse and convert to an abstract JSON representation
  2. json - get the abstract JSON representation and converts it to an actual QGIS project with all it's files

The xlsforms2qgis library will be retired and convert2qgis is going to take care of the conversion. We eventually publish it even to pypi.

See https://github.com/opengisch/convert2qgis

@nirvn
Copy link
Copy Markdown
Member

nirvn commented May 12, 2026

@suricactus , let me know when you want me to review / test this.

@suricactus
Copy link
Copy Markdown
Collaborator Author

Not yet, needs a bit more love and polishing. But we are close!

@suricactus suricactus force-pushed the json2qgis branch 2 times, most recently from 400271b to 2e58148 Compare May 19, 2026 06:42
@suricactus suricactus force-pushed the json2qgis branch 2 times, most recently from e45c55c to ef5df4b Compare May 19, 2026 10:17
@suricactus
Copy link
Copy Markdown
Collaborator Author

@nirvn ready for review of the current state of the PR.

@nirvn
Copy link
Copy Markdown
Member

nirvn commented May 20, 2026

@suricactus , looking at this now.

@nirvn
Copy link
Copy Markdown
Member

nirvn commented May 20, 2026

Hitting this bug when trying the alg on QGIS 4:

~~~~~~~~~~~~~~~~~~~~^^
File "/home/webmaster/.local/share/QGIS/QGIS4/profiles/default/python/plugins/xlsformconverter/convert2qgis_c2d491e9552d44132bc42edcab8eeecc09a087c2.whl/convert2qgis/json2qgis/json2qgis.py", line 118, in _create_project
self._create_layer(dataset_def)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/home/webmaster/.local/share/QGIS/QGIS4/profiles/default/python/plugins/xlsformconverter/convert2qgis_c2d491e9552d44132bc42edcab8eeecc09a087c2.whl/convert2qgis/json2qgis/json2qgis.py", line 285, in _create_layer
layer.setFlags(get_layer_flags(layer.flags(), dataset_def))
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: QgsMapLayer.setFlags(): argument 1 has unexpected type 'int'

@suricactus
Copy link
Copy Markdown
Collaborator Author

@nirvn xlsform file will be helpful. Do you reproduce this on 3.x?

@nirvn
Copy link
Copy Markdown
Member

nirvn commented May 20, 2026

@suricactus , it's fine with QGIS 3.X

Comment thread xlsformconverter/xlsform_converter_algorithms.py Outdated
@suricactus
Copy link
Copy Markdown
Collaborator Author

suricactus commented May 20, 2026

Hitting this bug when trying the alg on QGIS 4:

~~~~~~~~~~~~~~~~~~~~^^
File "/home/webmaster/.local/share/QGIS/QGIS4/profiles/default/python/plugins/xlsformconverter/convert2qgis_c2d491e9552d44132bc42edcab8eeecc09a087c2.whl/convert2qgis/json2qgis/json2qgis.py", line 118, in _create_project
self._create_layer(dataset_def)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/home/webmaster/.local/share/QGIS/QGIS4/profiles/default/python/plugins/xlsformconverter/convert2qgis_c2d491e9552d44132bc42edcab8eeecc09a087c2.whl/convert2qgis/json2qgis/json2qgis.py", line 285, in _create_layer
layer.setFlags(get_layer_flags(layer.flags(), dataset_def))
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: QgsMapLayer.setFlags(): argument 1 has unexpected type 'int'
> l = iface.activeLayer()
> flags = l.flags()
> l.setFlags(flags & QgsMapLayer.LayerFlag.Identifiable)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: QgsMapLayer.setFlags(): argument 1 has unexpected type 'int'
> l.setFlags(QgsMapLayer.LayerFlag(flags & QgsMapLayer.LayerFlag.Identifiable))

Fixes it. Will update accordingly.

@suricactus suricactus force-pushed the json2qgis branch 2 times, most recently from d22cd7b to ba4eb3e Compare May 22, 2026 20:51
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

Successfully merging this pull request may close these issues.

2 participants