Skip to content

Commit

Permalink
Allow postgresraster layers as gdal processing tools input
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros committed Jul 11, 2024
1 parent 2de0bd8 commit 277a2f0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,29 @@ def gdal_connection_details_from_layer(layer: QgsMapLayer) -> GdalConnectionDeta
connection_string=parts['path'],
open_options=parts.get('openOptions', None)
)
elif provider == 'postgresraster':
gdal_source = ''
uri = layer.dataProvider().uri()
gdal_source = f"PG: {uri.connectionInfo()}"
schema = uri.schema()
if schema:
gdal_source += f" schema='{schema}'"
table = uri.table()
gdal_source += f" table='{table}'"
column = uri.param('column') or uri.geometryColumn()
if column:
gdal_source += f" column='{column}'"
is_tiled = any([layer.dataProvider().xSize() != layer.dataProvider().xBlockSize(),
layer.dataProvider().ySize() != layer.dataProvider().yBlockSize()])
gdal_source += f" mode={2 if is_tiled else 1}"
where = layer.dataProvider().subsetString()
if where:
gdal_source += f" where='{where}'"

return GdalConnectionDetails(
connection_string=gdal_source,
format='"PostGISRaster"'
)

ogrstr = str(layer.source()).split("|")[0]
path, ext = os.path.splitext(ogrstr)
Expand Down

0 comments on commit 277a2f0

Please sign in to comment.