4141from processing .algs .gdal .GridInverseDistanceNearestNeighbor import GridInverseDistanceNearestNeighbor
4242from processing .algs .gdal .GridLinear import GridLinear
4343from processing .algs .gdal .GridNearestNeighbor import GridNearestNeighbor
44+ from processing .algs .gdal .ogr2ogr import ogr2ogr
4445from processing .algs .gdal .proximity import proximity
4546from processing .algs .gdal .rasterize import rasterize
4647from processing .algs .gdal .retile import retile
@@ -233,10 +234,10 @@ def _copyFile(dst):
233234 def testOgrConnectionStringAndFormat (self ):
234235 context = QgsProcessingContext ()
235236 output , outputFormat = GdalUtils .ogrConnectionStringAndFormat ('d:/test/test.shp' , context )
236- self .assertEqual (output , '" d:/test/test.shp" ' )
237+ self .assertEqual (output , 'd:/test/test.shp' )
237238 self .assertEqual (outputFormat , '"ESRI Shapefile"' )
238239 output , outputFormat = GdalUtils .ogrConnectionStringAndFormat ('d:/test/test.mif' , context )
239- self .assertEqual (output , '" d:/test/test.mif" ' )
240+ self .assertEqual (output , 'd:/test/test.mif' )
240241 self .assertEqual (outputFormat , '"MapInfo File"' )
241242
242243 def testCrsConversion (self ):
@@ -479,7 +480,7 @@ def testContour(self):
479480 ['gdal_contour' ,
480481 '-b 1 -a elev -i 5.0 -f "ESRI Shapefile" ' +
481482 source + ' ' +
482- '" d:/temp/check.shp" ' ])
483+ 'd:/temp/check.shp' ])
483484 # with NODATA value
484485 self .assertEqual (
485486 alg .getConsoleCommands ({'INPUT' : source ,
@@ -491,7 +492,7 @@ def testContour(self):
491492 ['gdal_contour' ,
492493 '-b 1 -a elev -i 5.0 -snodata 9999.0 -f "ESRI Shapefile" ' +
493494 source + ' ' +
494- '" d:/temp/check.shp" ' ])
495+ 'd:/temp/check.shp' ])
495496 # with "0" NODATA value
496497 self .assertEqual (
497498 alg .getConsoleCommands ({'INPUT' : source ,
@@ -503,7 +504,7 @@ def testContour(self):
503504 ['gdal_contour' ,
504505 '-b 1 -a elev -i 5.0 -snodata 0.0 -f "GPKG" ' +
505506 source + ' ' +
506- '" d:/temp/check.gpkg" ' ])
507+ 'd:/temp/check.gpkg' ])
507508
508509 def testGdal2Tiles (self ):
509510 context = QgsProcessingContext ()
@@ -648,7 +649,7 @@ def testGdalTindex(self):
648649 'OUTPUT' : 'd:/temp/test.shp' }, context , feedback ),
649650 ['gdaltindex' ,
650651 '-tileindex location -f "ESRI Shapefile" ' +
651- '" d:/temp/test.shp" ' +
652+ 'd:/temp/test.shp ' +
652653 source ])
653654
654655 # with input srs
@@ -658,7 +659,7 @@ def testGdalTindex(self):
658659 'OUTPUT' : 'd:/temp/test.shp' }, context , feedback ),
659660 ['gdaltindex' ,
660661 '-tileindex location -t_srs EPSG:3111 -f "ESRI Shapefile" ' +
661- '" d:/temp/test.shp" ' +
662+ 'd:/temp/test.shp ' +
662663 source ])
663664
664665 # with target using proj string
@@ -669,7 +670,7 @@ def testGdalTindex(self):
669670 'OUTPUT' : 'd:/temp/test.shp' }, context , feedback ),
670671 ['gdaltindex' ,
671672 '-tileindex location -t_srs EPSG:20936 -f "ESRI Shapefile" ' +
672- '" d:/temp/test.shp" ' +
673+ 'd:/temp/test.shp ' +
673674 source ])
674675
675676 # with target using custom projection
@@ -680,7 +681,7 @@ def testGdalTindex(self):
680681 'OUTPUT' : 'd:/temp/test.shp' }, context , feedback ),
681682 ['gdaltindex' ,
682683 '-tileindex location -t_srs "+proj=utm +zone=36 +south +a=63785 +b=6357 +towgs84=-143,-90,-294,0,0,0,0 +units=m +no_defs" -f "ESRI Shapefile" ' +
683- '" d:/temp/test.shp" ' +
684+ 'd:/temp/test.shp ' +
684685 source ])
685686
686687 # with non-EPSG crs code
@@ -690,7 +691,7 @@ def testGdalTindex(self):
690691 'OUTPUT' : 'd:/temp/test.shp' }, context , feedback ),
691692 ['gdaltindex' ,
692693 '-tileindex location -t_srs EPSG:3111 -f "ESRI Shapefile" ' +
693- '" d:/temp/test.shp" ' +
694+ 'd:/temp/test.shp ' +
694695 source ])
695696
696697 def testGridAverage (self ):
@@ -897,6 +898,34 @@ def testGridNearestNeighbour(self):
897898 source + ' ' +
898899 'd:/temp/check.jpg' ])
899900
901+ def testOgr2Ogr (self ):
902+ context = QgsProcessingContext ()
903+ feedback = QgsProcessingFeedback ()
904+ source = os .path .join (testDataPath , 'polys.gml' )
905+ alg = ogr2ogr ()
906+ alg .initAlgorithm ()
907+
908+ self .assertEqual (
909+ alg .getConsoleCommands ({'INPUT' : source ,
910+ 'OUTPUT' : 'd:/temp/check.shp' }, context , feedback ),
911+ ['ogr2ogr' ,
912+ '-f "ESRI Shapefile" d:/temp/check.shp ' +
913+ source + ' polys2' ])
914+
915+ self .assertEqual (
916+ alg .getConsoleCommands ({'INPUT' : source ,
917+ 'OUTPUT' : 'd:/temp/check.kml' }, context , feedback ),
918+ ['ogr2ogr' ,
919+ '-f "LIBKML" d:/temp/check.kml ' +
920+ source + ' polys2' ])
921+
922+ self .assertEqual (
923+ alg .getConsoleCommands ({'INPUT' : source ,
924+ 'OUTPUT' : 'd:/temp/my out/check.kml' }, context , feedback ),
925+ ['ogr2ogr' ,
926+ '-f "LIBKML" "d:/temp/my out/check.kml" ' +
927+ source + ' polys2' ])
928+
900929 def testProximity (self ):
901930 context = QgsProcessingContext ()
902931 feedback = QgsProcessingFeedback ()
0 commit comments