@@ -67,9 +67,12 @@ def _checkGeometryColumnsTable(self):
67
67
try :
68
68
c = self ._get_cursor ()
69
69
self ._execute (c , u"SELECT CheckSpatialMetaData()" )
70
- self .has_geometry_columns = c .fetchone ()[0 ] == 1
70
+ v = c .fetchone ()[0 ]
71
+ self .has_geometry_columns = v == 1 or v == 3
72
+ self .has_spatialite4 = v == 3
71
73
except Exception , e :
72
74
self .has_geometry_columns = False
75
+ self .has_spatialite4 = False
73
76
74
77
self .has_geometry_columns_access = self .has_geometry_columns
75
78
return self .has_geometry_columns
@@ -206,11 +209,31 @@ def getVectorTables(self, schema=None):
206
209
207
210
c = self ._get_cursor ()
208
211
212
+ if self .has_spatialite4 :
213
+ cols = """CASE geometry_type % 10
214
+ WHEN 1 THEN 'POINT'
215
+ WHEN 2 THEN 'LINESTRING'
216
+ WHEN 3 THEN 'POLYGON'
217
+ WHEN 4 THEN 'MULTIPOINT'
218
+ WHEN 5 THEN 'MULTILINESTRING'
219
+ WHEN 6 THEN 'MULTIPOLYGON'
220
+ WHEN 7 THEN 'GEOMETRYCOLLECTION'
221
+ END AS gtype,
222
+ CASE geometry_type / 1000
223
+ WHEN 0 THEN 'XY'
224
+ WHEN 1 THEN 'XYZ'
225
+ WHEN 2 THEN 'XYM'
226
+ WHEN 3 THEN 'XYZM'
227
+ ELSE NULL
228
+ END AS coord_dimension"""
229
+ else :
230
+ cols = "g.type,g.coord_dimension"
231
+
209
232
# get geometry info from geometry_columns if exists
210
- sql = u"""SELECT m.name, m.type = 'view', g.f_table_name, g.f_geometry_column, g.type, g.coord_dimension , g.srid
233
+ sql = u"""SELECT m.name, m.type = 'view', g.f_table_name, g.f_geometry_column, %s , g.srid
211
234
FROM sqlite_master AS m JOIN geometry_columns AS g ON upper(m.name) = upper(g.f_table_name)
212
235
WHERE m.type in ('table', 'view')
213
- ORDER BY m.name, g.f_geometry_column"""
236
+ ORDER BY m.name, g.f_geometry_column""" % cols
214
237
215
238
self ._execute (c , sql )
216
239
0 commit comments