Tuesday, 1 December 2015

QGIS default style stored in spatialite db does not load when adding layer


I have a couple of default styles stored in a spatialite db. When I add the layer for which I have defined the default style in QGIS 2.14.22, everything looks good but trying the same in QGIS 2.18.16 sets only a generic style (cp. screenshot). The layer_styles table looks like this:


enter image description here


Added a layer with default style in QGIS 2.14.22:


enter image description here


Added the same layer in QGIS 2.18.16:


enter image description here


Note that I am able to manually load the style from the database in 2.18, and everything looks like expected, but I need to load the default style automatically when adding a layer. QGIS 2.18 can obviously load the style from the table, but does not recognize the default correctly.



The styles are created and stored with QGIS 2.14., so are there any compatibility issues that I miss?



Answer



The problem is in the f_table_catalog column which is empty in my case. QGIS 2.14.X seems to ignore this and can assign a style to its table by only the table name. QGIS 2.18.X obviously needs this column set to the path/filename where the spatialite db resides. If the field is empty, or the db has moved to another location QGIS 2.18.X is not able to assign default style to a table.


I solved this at this point by setting the f_table_catalog attribute for each dataset to the db location, which is easily done either in QGIS multi edit mode or via QGIS DB Manager/SQL Window:


update layer_styles set f_table_catalog='path/to/my/spatialite.sqlite'

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...