Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow postgresraster layers as grass processing tools input #60081

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading