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

Layer import fails when importing categorized layer with default category #23

Open
albtrentadue opened this issue May 10, 2021 · 0 comments

Comments

@albtrentadue
Copy link

First of all, I am creating this issue here, but you may decide whether it may be rather moved against QGIS Desktop.

I have made the attached QGIS project "Modena1.qgs" having a layer defined on a database table in a postgres/postGIS databsase.
Modena1.zip

Layer items are categorized by the entity field called "modello".
When categorizing the layer in QGIS Desktop (by Layer -> Layer Properies + Symbols -> Categorized and then Classify button), QGIS Desktop adds a "default" layer mapping items having field values different from those identified at creation time.
Looking into the QGIS file I can see that this "default" layer misses both "label" and "value" attributes:

    <categories>
      <category symbol="0" label="Arduino" value="Arduino" render="true"/>
      <category symbol="1" label="ESP-32" value="ESP-32" render="true"/>
      <category symbol="2" label="Raspberry" value="Raspberry" render="true"/>
      <category symbol="3" label="" value="" render="true"/>
    </categories>

When trying to import this project by means of the qwc-admin, the layer import phase will fail and the layer will not be imported. If this is the only layer in the project, the whole project will not be imported.
After investigation, I ascertained that this is caused by an exception in resources_controller.py when importing the categorized symbols as map's layers (line 442):

# add additional maps to ConfigDB
    new_maps = sorted(list(set(maps_from_config) - set(maps)))

This fails with exception when sorting the list with an item having label as None (the "default" category)

My suggestion is either to handle upfront the case of an empty labelled layer before calling sorted()
Or addressing the issue within QGIS Desktop

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

1 participant