Skip to content

Commit

Permalink
fix postgresraster provider in grass algorithm r.in.gdal
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCaha committed Jan 8, 2025
1 parent 33bb9d5 commit 63524b1
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion python/plugins/grassprovider/grass_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,9 +923,35 @@ def loadRasterLayer(
if not destName:
destName = f"rast_{os.path.basename(getTempFilename(context=context))}"
self.exportedLayers[name] = destName

if layer.providerType() == "postgresraster":
source = ""
uri = layer.dataProvider().uri()
source = f"PG: {uri.connectionInfo()}"
schema = uri.schema()
if schema:
source += f" schema='{schema}'"
table = uri.table()
source += f" table='{table}'"
column = uri.param("column") or uri.geometryColumn()
if column:
source += f" column='{column}'"
is_tiled = any(
[
layer.dataProvider().xSize() != layer.dataProvider().xBlockSize(),
layer.dataProvider().ySize() != layer.dataProvider().yBlockSize(),
]
)
source += f" mode={2 if is_tiled else 1}"
where = layer.dataProvider().subsetString()
if where:
source += f" where='{where}'"
else:
source = os.path.normpath(layer.source())

command = '{} input="{}" {}output="{}" --overwrite -o'.format(
"r.external" if external else "r.in.gdal",
os.path.normpath(layer.source()),
source,
f"band={band} " if band else "",
destName,
)
Expand Down

0 comments on commit 63524b1

Please sign in to comment.