Bug report #9282

Rule-based styling on SpatiaLite layer won't take, occasionally crashes

Added by Simon O'Keefe almost 6 years ago. Updated almost 6 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Vectors
Affected QGIS version:2.0.1 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:wontfix
Crashes QGIS or corrupts data:Yes Copied to github as #:17894

Description

When attempting to set up rule-based styling on a layer from a SpatiaLite file, I can successfully configure and test a filter, but when I apply it, the layer does not display, the styling settings are lost, and occasionally QGIS crashes.

To recreate:
  • Add vector layer > Vicmap.sqlite (from link below)
  • Layer Properties > Style > change 'Single Symbol' to 'Rule-based'
  • Modify filter with the following query: "CLASS_CODE" = 0
  • Apply, OK

The style is not displayed, and has has reverted back to 'Single Symbol'. Attempts to redo the rule-based filter usually crashes QGIS. Link to Minidump of a crash is below.

https://dl.dropboxusercontent.com/u/401098/Vicmap.zip
https://dl.dropboxusercontent.com/u/401098/qgis-20140102-164057-792-204-34139bc.zip

Note: in the Vicmap zip file, I've also included the table in MapInfo format. The desired styling can be successfully applied to this layer without incident.

History

#1 Updated by Nathan Woodrow almost 6 years ago

How did you create that SpatiaLite file?

#2 Updated by Simon O'Keefe almost 6 years ago

I translated the VMLITE_TR_ROAD MapInfo table (supplied in the zip file) to SpatiaLite using ogr2ogr:

ogr2ogr -f SQLite C:\\Temp\\Vicmap.sqlite C:\\Data\\VMLITE\\VMLITE_TR_ROAD.tab -nlt GEOMETRY -nln VMLITE_TR_ROAD -dsco SPATIALITE=YES -lco SPATIAL_INDEX=YES -lco LAUNDER=NO

#3 Updated by Simon O'Keefe almost 6 years ago

Aha.

If I recreate the layer as a plain SQLite file (not SpatiaLite), then QGIS displays it correctly, maintains the style settings, and doesn't crash.

ogr2ogr -f SQLite C:\\Temp\\Vicmap.sqlite C:\\Data\\VMLITE\\VMLITE_TR_ROAD.tab

#4 Updated by Simon O'Keefe almost 6 years ago

So I've identified that the issue does not affect straight SQLite files, but it seems serious that this bug still crashes QGIS and restricts the ability to use Spatialite files. I've already spend several hours trying to make this work, and I'm not sure what else I can contribute to help resolve this. Any suggestions?

(The procedure I described to recreate the issue seems to crash QGIS 100% of the time, instead of 'occasionally' that I wrote as part of the issue title.)

#5 Updated by Nathan Woodrow almost 6 years ago

I wonder what version of spatialite ogr, or what it is doing, because the QGIS browser doesn't seem to like the file.

#6 Updated by Simon O'Keefe almost 6 years ago

Thanks Nathan. I've tested it with two versions/distributions (GDAL 1.10.1, and release-1600-gdal-1-9-mapserver-6-2), both with the same result.

After more testing, I've concluded that QGIS doesn't cope with Spatialite layers with the geometry type of GEOMETRY (as opposed to POINT, LINESTRING, etc).

Users can overcome this by specifying the geometry type with every ogr2ogr command during import, however this rules out doing bulk imports, like when you specify a folder of MapInfo tables as the data source. It's a problem with GDAL that it doesn't recognise the geometry type of input polygon layers (or at least all the MapInfo ones I was trying to import).

So it's GDAL's fault that it generates layers of type GEOMETRY in some cases, but it is still a valid geometry type, and one that QGIS might handle more gracefully.

I'm happy for the priority of this task to be downgraded to Normal (but I can't seem to be able to change it myself), because maybe there won't be many people like who would expect to use QGIS to work specifically with bulk-loaded tables from GDAL.

#7 Updated by Bo Victor Thomsen almost 6 years ago

Simon, AFAIK QGIS generally doesn't support the "Geometry" (non specific geometry) type, so your OGR2OGR command has to be modified. Have you tried a more simple approach:

ogr2ogr -f SQLite C:\\Temp\\Vicmap.sqlite C:\\Data\\VMLITE\\VMLITE_TR_ROAD.tab -nln VMLITE_TR_ROAD -dsco SPATIALITE=YES -lco SPATIAL_INDEX=YES -lco LAUNDER=NO

i.e let OGR2OGR decide the geometry type.

If you want to ensure you don't have different types of geometries in the same Spatialite table:
ogr2ogr -where "OGR_GEOMETRY='LineString'" -f SQLite C:\\Temp\\Vicmap.sqlite C:\\Data\\VMLITE\\VMLITE_TR_ROAD.tab -nlt LINESTRING -nln VMLITE_TR_ROAD -dsco SPATIALITE=YES -lco SPATIAL_INDEX=YES -lco LAUNDER=NO

If the tab file contains different types of geomtries, you can convert it to spatialite by repeating the above command on the same inputfile but change the "LineString/LINESTRING" parts with another geometrytypes. The different ogr2ogr commands can be packed into a bat file. The bat file can at last be used to traverse af directory with tab files.

The result in spatialite will be multiple tables originated from the same tab file. Some or most of these tables will be empty. These can be removed by some kind of post processing in python

#8 Updated by Simon O'Keefe almost 6 years ago

Thanks Bo. That is a very creative solution!

Every layer I'm trying to work with in QGIS contains only points or only lines or only polygons, but ogr2ogr doesn't correctly identify the polygon layers for some reason, so I'm now doing separate ogr2ogr commands for every layer I'm importing. So I'm good now, thanks. (Here's an example of a table that ogr2ogr can't figure out correctly: https://dl.dropboxusercontent.com/u/401098/VMLITE_LGA.zip)

I think it's still important that QGIS warn users that it can't handle layers with GEOMETRY types, because it was a frustrating few hours for me having QGIS crash all the time and not know why.

(By the way, it seems that QGIS may actually be capable of working with GEOMETRY layers; the Add Vector Layer function manages to display them OK, but just crashes when trying to do rule-based styling. Someone smarter that me may be able to find out why it crashes at that point.)

#9 Updated by Giovanni Manghi almost 6 years ago

  • Target version changed from Version 2.0.0 to Future Release - High Priority
  • Category set to Vectors
  • Status changed from Open to Feedback
  • Operating System deleted (Windows 64bit, also Mac)

I think it's still important that QGIS warn users that it can't handle layers with GEOMETRY types, because it was a frustrating few hours for me having QGIS crash all the time and not know why.

(ideally) QGIS should never crash, even when (try) handle not supported formats or data types.

So this issue would need a separate ticket, or eventually change the title and description of this one.

#10 Updated by Giovanni Manghi almost 6 years ago

  • Priority changed from High to Normal
  • Status changed from Feedback to Closed
  • Resolution set to wontfix

So this issue would need a separate ticket, or eventually change the title and description of this one.

I'm closing this ticket instead because for I can see on Linux/Windows with qgis 2/master, the geometry type layers seems are already correctly handled by qgis, they do now show in the canvas and properties like style, labels and diagrams are disabled. The user can still manage the table of attributes and edit it.

Also available in: Atom PDF