@@ -127,7 +127,7 @@ def testListLayer(self):
127
127
table = tables [0 ]
128
128
self .assertEqual (table .name , 'testLayer' )
129
129
info = table .info ()
130
- expected_html = """<div class="section"><h2>General info</h2><div><table><tr><td>Relation type: </td><td>Table </td></tr><tr><td>Rows: </td><td>1 </td></tr></table></div></div><div class="section"><h2>GeoPackage</h2><div><table><tr><td>Column: </td><td>geom </td></tr><tr><td>Geometry: </td><td>LINE STRING </td></tr><tr><td>Dimension: </td><td>XY </td></tr><tr><td>Spatial ref: </td><td>Undefined (-1) </td></tr><tr><td>Extent: </td><td>1.00000, 2.00000 - 3.00000, 4.00000 </td></tr></table><p><warning> No spatial index defined (<a href="action:spatialindex/create">create it</a>)</p></div></div><div class="section"><h2>Fields</h2><div><table class="header"><tr><th># </th><th>Name </th><th>Type </th><th>Null </th><th>Default </th></tr><tr><td>0 </td><td class="underline">fid </td><td>INTEGER </td><td>Y </td><td> </td></tr><tr><td>1 </td><td>geom </td><td>LINESTRING </td><td>Y </td><td> </td></tr><tr><td>2 </td><td>text_field </td><td>TEXT </td><td>Y </td><td> </td></tr></table></div></div>"""
130
+ expected_html = """<div class="section"><h2>General info</h2><div><table><tr><td>Relation type: </td><td>Table </td></tr><tr><td>Rows: </td><td>1 </td></tr></table></div></div><div class="section"><h2>GeoPackage</h2><div><table><tr><td>Column: </td><td>geom </td></tr><tr><td>Geometry: </td><td>LINESTRING </td></tr><tr><td>Dimension: </td><td>XY </td></tr><tr><td>Spatial ref: </td><td>Undefined (-1) </td></tr><tr><td>Extent: </td><td>1.00000, 2.00000 - 3.00000, 4.00000 </td></tr></table><p><warning> No spatial index defined (<a href="action:spatialindex/create">create it</a>)</p></div></div><div class="section"><h2>Fields</h2><div><table class="header"><tr><th># </th><th>Name </th><th>Type </th><th>Null </th><th>Default </th></tr><tr><td>0 </td><td class="underline">fid </td><td>INTEGER </td><td>Y </td><td> </td></tr><tr><td>1 </td><td>geom </td><td>LINESTRING </td><td>Y </td><td> </td></tr><tr><td>2 </td><td>text_field </td><td>TEXT </td><td>Y </td><td> </td></tr></table></div></div>"""
131
131
self .assertEqual (info .toHtml (), expected_html , info .toHtml ())
132
132
133
133
connection .remove ()
@@ -389,5 +389,45 @@ def testNonSpatial(self):
389
389
390
390
connection .remove ()
391
391
392
+ def testAllGeometryTypes (self ):
393
+
394
+ connection_name = 'testAllGeometryTypes'
395
+ plugin = createDbPlugin ('gpkg' )
396
+ uri = QgsDataSourceURI ()
397
+
398
+ test_gpkg = os .path .join (self .basetestpath , 'testAllGeometryTypes.gpkg' )
399
+ ds = ogr .GetDriverByName ('GPKG' ).CreateDataSource (test_gpkg )
400
+ ds .CreateLayer ('testPoint' , geom_type = ogr .wkbPoint )
401
+ ds .CreateLayer ('testLineString' , geom_type = ogr .wkbLineString )
402
+ ds .CreateLayer ('testPolygon' , geom_type = ogr .wkbPolygon )
403
+ ds .CreateLayer ('testMultiPoint' , geom_type = ogr .wkbMultiPoint )
404
+ ds .CreateLayer ('testMultiLineString' , geom_type = ogr .wkbMultiLineString )
405
+ ds .CreateLayer ('testMultiPolygon' , geom_type = ogr .wkbMultiPolygon )
406
+ ds .CreateLayer ('testGeometryCollection' , geom_type = ogr .wkbGeometryCollection )
407
+
408
+ if int (gdal .VersionInfo ('VERSION_NUM' )) >= GDAL_COMPUTE_VERSION (2 , 0 , 0 ):
409
+ ds .CreateLayer ('testCircularString' , geom_type = ogr .wkbCircularString )
410
+ ds .CreateLayer ('testCompoundCurve' , geom_type = ogr .wkbCompoundCurve )
411
+ ds .CreateLayer ('testCurvePolygon' , geom_type = ogr .wkbCurvePolygon )
412
+ ds .CreateLayer ('testMultiCurve' , geom_type = ogr .wkbMultiCurve )
413
+ ds .CreateLayer ('testMultiSurface' , geom_type = ogr .wkbMultiSurface )
414
+ ds = None
415
+
416
+ uri .setDatabase (test_gpkg )
417
+ self .assertTrue (plugin .addConnection (connection_name , uri ))
418
+
419
+ connection = createDbPlugin ('gpkg' , connection_name )
420
+ connection .connect ()
421
+
422
+ db = connection .database ()
423
+ self .assertIsNotNone (db )
424
+
425
+ tables = db .tables ()
426
+ for i in range (len (tables )):
427
+ table = tables [i ]
428
+ info = table .info ()
429
+
430
+ connection .remove ()
431
+
392
432
if __name__ == '__main__' :
393
433
unittest .main ()
0 commit comments