Fix bad dimensions when rescaling rasters with default geotransform

matrix. Ticket #2251

git-svn-id: http://svn.osgeo.org/postgis/trunk@11215 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Bborie Park 2013-03-27 13:30:42 +00:00
parent e9098aa8d7
commit 993eefd8f0
4 changed files with 32 additions and 5 deletions

2
NEWS
View file

@ -159,6 +159,8 @@ PostGIS 2.1.0
are handled when passing to GDAL Warp API
- #2215, Fixed raster exclusion constraint for conflicting name of
implicit index
- #2251, Fix bad dimensions when rescaling rasters with default
geotransform matrix
PostGIS 2.0.3
2013/MM/DD

View file

@ -2299,7 +2299,6 @@ rt_errorstate rt_band_get_pixel_line(
void **vals, uint16_t *nvals
) {
uint8_t *_vals = NULL;
rt_pixtype pixtype = PT_END;
int pixsize = 0;
uint8_t *data = NULL;
uint32_t offset = 0;
@ -2334,7 +2333,6 @@ rt_errorstate rt_band_get_pixel_line(
offset = x + (y * band->width);
RASTER_DEBUGF(4, "offset = %d", offset);
pixtype = band->pixtype;
pixsize = rt_pixtype_size(band->pixtype);
RASTER_DEBUGF(4, "pixsize = %d", pixsize);
@ -3414,7 +3412,6 @@ rt_band_get_histogram(
double tmp;
double value;
int sum = 0;
int user_minmax = 0;
double qmin;
double qmax;
@ -3452,7 +3449,6 @@ rt_band_get_histogram(
qmax = stats->max;
}
else {
user_minmax = 1;
qmin = min;
qmax = max;
if (qmin > qmax) {
@ -9595,6 +9591,9 @@ rt_raster rt_raster_gdal_warp(
FLT_EQ(gt[5], -1)
) {
double ngt[6] = {0, 10, 0, 0, 0, -10};
rtinfo("Raster has default geotransform. Adjusting metadata for use of GDAL Warp API");
GDALSetGeoTransform(arg->src.ds, ngt);
GDALFlushCache(arg->src.ds);
@ -9742,6 +9741,12 @@ rt_raster rt_raster_gdal_warp(
) {
_scale[0] = fabs(*scale_x);
_scale[1] = fabs(*scale_y);
/* special override */
if (subgt) {
_scale[0] *= 10;
_scale[1] *= 10;
}
}
else if (
((NULL != scale_x) && (NULL == scale_y)) ||
@ -10275,6 +10280,7 @@ rt_raster rt_raster_gdal_warp(
/* substitute geotransform matrix, reset back to default */
if (subgt) {
double gt[6] = {0, 1, 0, 0, 0, -1};
rt_raster_set_geotransform_matrix(rast, gt);
}

View file

@ -850,4 +850,13 @@ SELECT -- ticket #2188
), bar AS (
SELECT rid, ST_Metadata(rast) AS meta, ST_SummaryStats(rast) AS stats FROM foo
)
SELECT rid, (meta).*, (stats).* FROM bar
SELECT rid, (meta).*, (stats).* FROM bar;
-- edge case
WITH foo AS (
SELECT ST_AddBand(ST_MakeEmptyRaster(10, 10, 0, 0, 1, -1, 0, 0, 0), 1, '8BUI', 1, 0) AS rast
)
SELECT
ST_Metadata(ST_Rescale(rast, 2, 2)) AS rescale,
ST_Metadata(ST_Resize(rast, 0.5, 0.5)) AS resize
FROM foo;

View file

@ -2,6 +2,9 @@ NOTICE: table "raster_gdalwarp_src" does not exist, skipping
NOTICE: table "raster_gdalwarp_dst" does not exist, skipping
NOTICE: Values must be provided for both X and Y when specifying the scale. Returning original raster
NOTICE: Values must be provided for both X and Y when specifying the scale. Returning original raster
NOTICE: Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
NOTICE: Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
NOTICE: Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
NOTICE: Values must be provided for both X and Y when specifying the scale. Returning original raster
NOTICE: Values must be provided for both X and Y when specifying the scale. Returning original raster
0.0|||||||||||||
@ -114,7 +117,14 @@ NOTICE: Values must be provided for both X and Y when specifying the scale. Re
5.9|992163|10|11|1|1000.000|-1000.000|0.000|0.000|-500000.000|600009.000|t|t|t
NOTICE: The rasters (pixel corner coordinates) are not aligned
t|f|t
NOTICE: Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
NOTICE: Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
NOTICE: Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
NOTICE: Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
1|0|0|500|500|1|-1|0|0|0|1|250000|63750000|255|0|255|255
2|0|0|500|100|1|-1|0|0|0|1|50000|12750000|255|0|255|255
3|0|0|250|900|1|-1|0|0|0|1|225000|57375000|255|0|255|255
4|0|0|512|384|1|-1|0|0|0|1|196608|50135040|255|0|255|255
NOTICE: Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
NOTICE: Raster has default geotransform. Adjusting metadata for use of GDAL Warp API
(0,0,5,5,1,-1,0,0,0,1)|(0,0,5,5,1,-1,0,0,0,1)