diff --git a/python/plugins/processing/algs/grass7/Grass7Algorithm.py b/python/plugins/processing/algs/grass7/Grass7Algorithm.py index 06545bc1529..4e65153499f 100644 --- a/python/plugins/processing/algs/grass7/Grass7Algorithm.py +++ b/python/plugins/processing/algs/grass7/Grass7Algorithm.py @@ -63,6 +63,7 @@ from qgis.core import (Qgis, QgsProcessingUtils, QgsVectorLayer) from qgis.utils import iface +from osgeo import ogr from processing.core.ProcessingConfig import ProcessingConfig @@ -786,6 +787,17 @@ class Grass7Algorithm(QgsProcessingAlgorithm): if external is None: external = ProcessingConfig.getSetting( Grass7Utils.GRASS_USE_VEXTERNAL) + + # safety check: we can only use external for ogr layers which support random read + if external: + ds = ogr.Open(layer.source()) + if ds is not None: + ogr_layer = ds.GetLayer() + if ogr_layer is None or not ogr_layer.TestCapability(ogr.OLCRandomRead): + external = False + else: + external = False + self.inputLayers.append(layer) self.setSessionProjectionFromLayer(layer) destFilename = 'vector_{}'.format(os.path.basename(getTempFilename())) diff --git a/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.dbf b/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.dbf new file mode 100644 index 00000000000..d8e26c3d66b Binary files /dev/null and b/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.dbf differ diff --git a/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.prj b/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.prj new file mode 100644 index 00000000000..a30c00a55de --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.shp b/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.shp new file mode 100644 index 00000000000..372b6b49d01 Binary files /dev/null and b/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.shp differ diff --git a/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.shx b/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.shx new file mode 100644 index 00000000000..0ef33eecc89 Binary files /dev/null and b/python/plugins/processing/tests/testdata/expected/grass7/buffer_lines.shx differ diff --git a/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml b/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml index d753a6175b4..7d93dd1ce4c 100644 --- a/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml +++ b/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml @@ -3,18 +3,33 @@ tests: # v.* modules -# - algorithm: grass7:r.plane -# name: GRASS7 r.plane -# params: -# GRASS_REGION_PARAMETER: 344500.0,358400.0,6682800.0,6693700.0 -# azimuth: 125 -# dip: 45 -# easting: 351610 -# elevation: 50 -# northing: 6688312 -# type: 1 -# results: -# output: -# hash: a9326678c39b6f925e7f22f6e79a48217100071cc8af85d675f28462 -# type: rasterhash + - algorithm: grass7:v.buffer + name: Buffer vectors + params: + -c: false + -s: false + -t: false + GRASS_MIN_AREA_PARAMETER: 0.0001 + GRASS_OUTPUT_TYPE_PARAMETER: 0 + GRASS_SNAP_TOLERANCE_PARAMETER: -1.0 + angle: 0.0 + cats: '' + distance: 0.1 + input: + name: lines.gml + type: vector + scale: 1.0 + tolerance: 0.01 + type: + - 0 + - 1 + - 4 + where: '' + results: + output: + name: expected/grass7/buffer_lines.shp + type: vector + compare: + geometry: + precision: 7