41
41
from processing .algs .gdal .GridInverseDistanceNearestNeighbor import GridInverseDistanceNearestNeighbor
42
42
from processing .algs .gdal .GridLinear import GridLinear
43
43
from processing .algs .gdal .GridNearestNeighbor import GridNearestNeighbor
44
+ from processing .algs .gdal .ogr2ogr import ogr2ogr
44
45
from processing .algs .gdal .proximity import proximity
45
46
from processing .algs .gdal .rasterize import rasterize
46
47
from processing .algs .gdal .retile import retile
@@ -233,10 +234,10 @@ def _copyFile(dst):
233
234
def testOgrConnectionStringAndFormat (self ):
234
235
context = QgsProcessingContext ()
235
236
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' )
237
238
self .assertEqual (outputFormat , '"ESRI Shapefile"' )
238
239
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' )
240
241
self .assertEqual (outputFormat , '"MapInfo File"' )
241
242
242
243
def testCrsConversion (self ):
@@ -479,7 +480,7 @@ def testContour(self):
479
480
['gdal_contour' ,
480
481
'-b 1 -a elev -i 5.0 -f "ESRI Shapefile" ' +
481
482
source + ' ' +
482
- '" d:/temp/check.shp" ' ])
483
+ 'd:/temp/check.shp' ])
483
484
# with NODATA value
484
485
self .assertEqual (
485
486
alg .getConsoleCommands ({'INPUT' : source ,
@@ -491,7 +492,7 @@ def testContour(self):
491
492
['gdal_contour' ,
492
493
'-b 1 -a elev -i 5.0 -snodata 9999.0 -f "ESRI Shapefile" ' +
493
494
source + ' ' +
494
- '" d:/temp/check.shp" ' ])
495
+ 'd:/temp/check.shp' ])
495
496
# with "0" NODATA value
496
497
self .assertEqual (
497
498
alg .getConsoleCommands ({'INPUT' : source ,
@@ -503,7 +504,7 @@ def testContour(self):
503
504
['gdal_contour' ,
504
505
'-b 1 -a elev -i 5.0 -snodata 0.0 -f "GPKG" ' +
505
506
source + ' ' +
506
- '" d:/temp/check.gpkg" ' ])
507
+ 'd:/temp/check.gpkg' ])
507
508
508
509
def testGdal2Tiles (self ):
509
510
context = QgsProcessingContext ()
@@ -648,7 +649,7 @@ def testGdalTindex(self):
648
649
'OUTPUT' : 'd:/temp/test.shp' }, context , feedback ),
649
650
['gdaltindex' ,
650
651
'-tileindex location -f "ESRI Shapefile" ' +
651
- '" d:/temp/test.shp" ' +
652
+ 'd:/temp/test.shp ' +
652
653
source ])
653
654
654
655
# with input srs
@@ -658,7 +659,7 @@ def testGdalTindex(self):
658
659
'OUTPUT' : 'd:/temp/test.shp' }, context , feedback ),
659
660
['gdaltindex' ,
660
661
'-tileindex location -t_srs EPSG:3111 -f "ESRI Shapefile" ' +
661
- '" d:/temp/test.shp" ' +
662
+ 'd:/temp/test.shp ' +
662
663
source ])
663
664
664
665
# with target using proj string
@@ -669,7 +670,7 @@ def testGdalTindex(self):
669
670
'OUTPUT' : 'd:/temp/test.shp' }, context , feedback ),
670
671
['gdaltindex' ,
671
672
'-tileindex location -t_srs EPSG:20936 -f "ESRI Shapefile" ' +
672
- '" d:/temp/test.shp" ' +
673
+ 'd:/temp/test.shp ' +
673
674
source ])
674
675
675
676
# with target using custom projection
@@ -680,7 +681,7 @@ def testGdalTindex(self):
680
681
'OUTPUT' : 'd:/temp/test.shp' }, context , feedback ),
681
682
['gdaltindex' ,
682
683
'-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 ' +
684
685
source ])
685
686
686
687
# with non-EPSG crs code
@@ -690,7 +691,7 @@ def testGdalTindex(self):
690
691
'OUTPUT' : 'd:/temp/test.shp' }, context , feedback ),
691
692
['gdaltindex' ,
692
693
'-tileindex location -t_srs EPSG:3111 -f "ESRI Shapefile" ' +
693
- '" d:/temp/test.shp" ' +
694
+ 'd:/temp/test.shp ' +
694
695
source ])
695
696
696
697
def testGridAverage (self ):
@@ -897,6 +898,34 @@ def testGridNearestNeighbour(self):
897
898
source + ' ' +
898
899
'd:/temp/check.jpg' ])
899
900
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
+
900
929
def testProximity (self ):
901
930
context = QgsProcessingContext ()
902
931
feedback = QgsProcessingFeedback ()
0 commit comments