Skip to content
Permalink
Browse files

[processing][grass] Fix use of v.external with ogr layers which

do not support random read

These layers are not compatible with v.external, so we have to
use v.in.ogr for them
  • Loading branch information
nyalldawson committed Apr 9, 2018
1 parent 8ba762a commit aca75cfa6e16c021882f395844780d78670652e7
@@ -63,6 +63,7 @@
QgsProcessingUtils,
QgsVectorLayer)
from qgis.utils import iface
from osgeo import ogr

from processing.core.ProcessingConfig import ProcessingConfig

@@ -786,6 +787,17 @@ def loadVectorLayer(self, name, layer, external=False):
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()))
Binary file not shown.
@@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
Binary file not shown.
Binary file not shown.
@@ -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

0 comments on commit aca75cf

Please sign in to comment.
You can’t perform that action at this time.