mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-07 00:02:15 -05:00
Merge pull request #31735 from alexbruy/fix-29663
[processing] add support for WFS as input (fix #29663)
This commit is contained in:
commit
27b576c794
@ -32,7 +32,8 @@ from qgis.core import (QgsApplication,
|
||||
QgsProcessingAlgorithm,
|
||||
QgsProcessingContext,
|
||||
QgsProcessingFeedback,
|
||||
QgsProviderRegistry)
|
||||
QgsProviderRegistry,
|
||||
QgsDataSourceUri)
|
||||
|
||||
from processing.algs.gdal.GdalAlgorithmDialog import GdalAlgorithmDialog
|
||||
from processing.algs.gdal.GdalUtils import GdalUtils
|
||||
@ -115,6 +116,11 @@ class GdalAlgorithm(QgsProcessingAlgorithm):
|
||||
#for the command line preview since it has no meaning outside of a QGIS session!
|
||||
ogr_data_path = GdalUtils.ogrConnectionStringAndFormatFromLayer(input_layer)[0]
|
||||
ogr_layer_name = GdalUtils.ogrLayerName(input_layer.dataProvider().dataSourceUri())
|
||||
elif input_layer.dataProvider().name().lower() == 'wfs':
|
||||
uri = QgsDataSourceUri(input_layer.source())
|
||||
baseUrl = uri.param('url').split('?')[0]
|
||||
ogr_data_path = "WFS:{}".format(baseUrl)
|
||||
ogr_layer_name = uri.param('typename')
|
||||
else:
|
||||
# vector layer, but not OGR - get OGR compatible path
|
||||
# TODO - handle "selected features only" mode!!
|
||||
|
@ -341,6 +341,11 @@ class GdalUtils:
|
||||
|
||||
ogrstr += dsUri.table()
|
||||
format = 'OCI'
|
||||
elif provider.lower() == "wfs":
|
||||
uri = QgsDataSourceUri(layer.source())
|
||||
baseUrl = uri.param('url').split('?')[0]
|
||||
ogrstr = "WFS:{}".format(baseUrl)
|
||||
format = 'WFS'
|
||||
else:
|
||||
ogrstr = str(layer.source()).split("|")[0]
|
||||
path, ext = os.path.splitext(ogrstr)
|
||||
|
@ -126,7 +126,7 @@ class Ogr2OgrTableToPostGisList(GdalAlgorithm):
|
||||
uri = GeoDB(uri=uri).uri
|
||||
|
||||
inLayer = self.getParameterValue(self.INPUT_LAYER)
|
||||
ogrLayer = GdalUtils.ogrConnectionStringFromLayer(inLayer)
|
||||
ogrLayer, layerName = self.getOgrCompatibleSource(self.INPUT, parameters, context, feedback, executing)
|
||||
shapeEncoding = self.getParameterValue(self.SHAPE_ENCODING)
|
||||
schema = str(self.getParameterValue(self.SCHEMA))
|
||||
table = str(self.getParameterValue(self.TABLE))
|
||||
@ -161,7 +161,7 @@ class Ogr2OgrTableToPostGisList(GdalAlgorithm):
|
||||
arguments.append('"')
|
||||
arguments.append(ogrLayer)
|
||||
arguments.append('-nlt NONE')
|
||||
arguments.append(GdalUtils.ogrLayerName(inLayer))
|
||||
arguments.append(layerName)
|
||||
if launder:
|
||||
arguments.append(launderstring)
|
||||
if append:
|
||||
@ -175,7 +175,7 @@ class Ogr2OgrTableToPostGisList(GdalAlgorithm):
|
||||
elif primary_key is not None:
|
||||
arguments.append("-lco FID=" + primary_key)
|
||||
if len(table) == 0:
|
||||
table = GdalUtils.ogrLayerName(inLayer).lower()
|
||||
table = layerName.lower()
|
||||
if schema:
|
||||
table = '{}.{}'.format(schema, table)
|
||||
arguments.append('-nln')
|
||||
|
@ -81,8 +81,9 @@ class ogrinfo(GdalAlgorithm):
|
||||
if inLayer is None:
|
||||
raise QgsProcessingException(self.invalidSourceError(parameters, self.INPUT))
|
||||
|
||||
connectionString = GdalUtils.ogrConnectionStringFromLayer(inLayer)
|
||||
arguments.append(connectionString)
|
||||
ogrLayer, layerName = self.getOgrCompatibleSource(self.INPUT, parameters, context, feedback, executing)
|
||||
arguments.append(ogrLayer)
|
||||
arguments.append(layerName)
|
||||
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
|
||||
|
||||
def processAlgorithm(self, parameters, context, feedback):
|
||||
|
@ -113,7 +113,7 @@ class TestGdalVectorAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsT
|
||||
'NO_METADATA': False}, context, feedback),
|
||||
['ogrinfo',
|
||||
'-al -so ' +
|
||||
source])
|
||||
source + ' polys2'])
|
||||
|
||||
source = os.path.join(testDataPath, 'filename with spaces.gml')
|
||||
self.assertEqual(
|
||||
@ -122,7 +122,7 @@ class TestGdalVectorAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsT
|
||||
'NO_METADATA': False}, context, feedback),
|
||||
['ogrinfo',
|
||||
'-al -so "' +
|
||||
source + '"'])
|
||||
source + '" filename_with_spaces'])
|
||||
|
||||
source = os.path.join(testDataPath, 'filename with spaces.gml')
|
||||
self.assertEqual(
|
||||
@ -131,7 +131,7 @@ class TestGdalVectorAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsT
|
||||
'NO_METADATA': False}, context, feedback),
|
||||
['ogrinfo',
|
||||
'-al "' +
|
||||
source + '"'])
|
||||
source + '" filename_with_spaces'])
|
||||
|
||||
source = os.path.join(testDataPath, 'filename with spaces.gml')
|
||||
self.assertEqual(
|
||||
@ -140,7 +140,7 @@ class TestGdalVectorAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsT
|
||||
'NO_METADATA': True}, context, feedback),
|
||||
['ogrinfo',
|
||||
'-al -so -nomd "' +
|
||||
source + '"'])
|
||||
source + '" filename_with_spaces'])
|
||||
|
||||
def testBuffer(self):
|
||||
context = QgsProcessingContext()
|
||||
|
Loading…
x
Reference in New Issue
Block a user