@@ -58,10 +58,16 @@ def setUpClass(cls):
5858
5959 cls .conn = QSqlDatabase .addDatabase ('QODBC' )
6060 cls .conn .setDatabaseName ('testsqlserver' )
61- if 'QGIS_MSSQLTEST_DB' in os .environ :
62- cls .conn .setDatabaseName ('QGIS_MSSQLTEST_DB' )
63- cls .conn .setUserName ('SA' )
64- cls .conn .setPassword ('<YourStrong!Passw0rd>' )
61+ if 'QGIS_MSSQLTEST_DB2' in os .environ :
62+ print (os .environ ['QGIS_MSSQLTEST_DB2' ])
63+ cls .conn .setDatabaseName (os .environ ['QGIS_MSSQLTEST_DB2' ])
64+ elif 'QGIS_MSSQLTEST_DB' in os .environ :
65+ print (os .environ ['QGIS_MSSQLTEST_DB' ])
66+ cls .conn .setDatabaseName (os .environ ['QGIS_MSSQLTEST_DB' ])
67+ else :
68+ cls .conn .setUserName ('SA' )
69+ cls .conn .setPassword ('<YourStrong!Passw0rd>' )
70+
6571 assert cls .conn .open (), cls .conn .lastError ().text ()
6672
6773 # Triggers a segfault in the sql server odbc driver on Travis - TODO test with more recent Ubuntu base image
@@ -351,6 +357,28 @@ def testCreateLayerMultiPoint(self):
351357 geom = [f .geometry ().asWkt () for f in new_layer .getFeatures ()]
352358 self .assertEqual (geom , ['MultiPoint ((1 2),(3 4))' , '' , 'MultiPoint ((7 8))' ])
353359
360+ @unittest .skipIf (os .environ .get ('TRAVIS' , '' ) == 'true' , 'Failing on Travis' )
361+ def testCurveGeometries (self ):
362+ geomtypes = ['CompoundCurve' , 'CurvePolygon' , 'CircularString' ]
363+ geoms = ['CompoundCurve ((0 -23.43778, 0 23.43778),CircularString (0 23.43778, -45 33.43778, -90 23.43778),(-90 23.43778, -90 -23.43778),CircularString (-90 -23.43778, -45 -23.43778, 0 -23.43778))' , 'CurvePolygon (CompoundCurve ((0 -23.43778, 0 -15.43778, 0 23.43778),CircularString (0 23.43778, -45 100, -90 23.43778),(-90 23.43778, -90 -23.43778),CircularString (-90 -23.43778, -45 -16.43778, 0 -23.43778)),CompoundCurve (CircularString (-30 0, -48 -12, -60 0, -48 -6, -30 0)))' , 'CircularString (0 0, 0.14644660940672 0.35355339059327, 0.5 0.5, 0.85355339059327 0.35355339059327, 1 0, 0.85355339059327 -0.35355339059327, 0.5 -0.5, 0.14644660940672 -0.35355339059327, 0 0)' ]
364+ for idx , t in enumerate (geoms ):
365+ f = QgsFeature ()
366+ g = QgsGeometry .fromWkt (t )
367+ f .setGeometry (g )
368+ layer = QgsVectorLayer (geomtypes [idx ] + "?crs=epsg:4326" , "addfeat" , "memory" )
369+ pr = layer .dataProvider ()
370+ pr .addFeatures ([f ])
371+ uri = self .dbconn + ' table="qgis_test"."new_table_curvegeom_' + str (idx ) + '" sql='
372+ error , message = QgsVectorLayerExporter .exportLayer (layer , uri , 'mssql' , QgsCoordinateReferenceSystem ('EPSG:4326' ))
373+ self .assertEqual (error , QgsVectorLayerExporter .NoError )
374+ new_layer = QgsVectorLayer (uri , 'new' , 'mssql' )
375+ self .assertTrue (new_layer .isValid ())
376+ self .assertEqual (new_layer .wkbType (), g .wkbType ())
377+ self .assertEqual (new_layer .crs ().authid (), 'EPSG:4326' )
378+ result_geoms = [f .geometry ().asWkt (14 ) for f in new_layer .getFeatures ()]
379+ self .assertEqual (result_geoms , [t ])
380+ self .execSQLCommand ('DROP TABLE IF EXISTS [qgis_test].[new_table_curvegeom_{}]' .format (str (idx )))
381+
354382 def testInsertPolygonInMultiPolygon (self ):
355383 layer = QgsVectorLayer ("MultiPolygon?crs=epsg:4326&field=id:integer" , "addfeat" , "memory" )
356384 pr = layer .dataProvider ()
0 commit comments