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

1.10 pgraster column #33

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
33 changes: 19 additions & 14 deletions gdal/frmts/postgisraster/postgisrasterdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,18 @@ GBool PostGISRasterDataset::SetRasterProperties
osCommand.Printf(
"select srid, nbband, st_xmin(geom) as xmin, st_xmax(geom) as xmax, "
"st_ymin(geom) as ymin, st_ymax(geom) as ymax from (select st_srid(%s) srid, "
"st_extent(%s::geometry) geom, max(ST_NumBands(rast)) nbband from %s.%s "
"group by st_srid(%s)) foo", pszColumn, pszColumn, pszSchema,
"st_extent(%s::geometry) geom, max(ST_NumBands(%s)) nbband from %s.%s "
"group by st_srid(%s)) foo", pszColumn, pszColumn, pszColumn, pszSchema,
pszTable, pszColumn);
}

else {
osCommand.Printf(
"select srid, nbband, st_xmin(geom) as xmin, st_xmax(geom) as xmax, "
"st_ymin(geom) as ymin, st_ymax(geom) as ymax from (select st_srid(%s) srid, "
"st_extent(%s::geometry) geom, max(ST_NumBands(rast)) nbband from %s.%s "
"where %s group by st_srid(%s)) foo", pszColumn, pszColumn, pszSchema,
"st_extent(%s::geometry) geom, max(ST_NumBands(%s)) nbband from %s.%s "
"where %s group by st_srid(%s)) foo", pszColumn, pszColumn,
pszColumn, pszSchema,
pszTable, pszWhere, pszColumn);
}

Expand Down Expand Up @@ -701,21 +702,25 @@ GBool PostGISRasterDataset::SetRasterProperties

/* Create query to fetch metadata from db */
if (pszWhere == NULL) {
osCommand.Printf("select st_bandpixeltype(rast, band), "
"st_bandnodatavalue(rast, band) is null, "
"st_bandnodatavalue(rast, band) from (select %s, "
osCommand.Printf("select st_bandpixeltype(%s, band), "
"st_bandnodatavalue(%s, band) is null, "
"st_bandnodatavalue(%s, band) from (select %s, "
"generate_series(1, st_numbands(%s)) band from (select "
"rast from %s.%s limit 1) bar) foo",
pszColumn, pszColumn, pszSchema, pszTable);
"%s from %s.%s limit 1) bar) foo",
pszColumn, pszColumn, pszColumn,
pszColumn, pszColumn, pszColumn,
pszSchema, pszTable);
}

else {
osCommand.Printf("select st_bandpixeltype(rast, band), "
"st_bandnodatavalue(rast, band) is null, "
"st_bandnodatavalue(rast, band) from (select %s, "
osCommand.Printf("select st_bandpixeltype(%s, band), "
"st_bandnodatavalue(%s, band) is null, "
"st_bandnodatavalue(%s, band) from (select %s, "
"generate_series(1, st_numbands(%s)) band from (select "
"rast from %s.%s where %s limit 1) bar) foo",
pszColumn, pszColumn, pszSchema, pszTable, pszWhere);
"%s from %s.%s where %s limit 1) bar) foo",
pszColumn, pszColumn, pszColumn,
pszColumn, pszColumn, pszColumn,
pszSchema, pszTable, pszWhere);
}

CPLDebug("PostGIS_Raster", "PostGISRasterDataset::SetRasterProperties(): "
Expand Down