mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-23 16:42:35 +00:00
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:
parent
e9098aa8d7
commit
993eefd8f0
2
NEWS
2
NEWS
|
@ -159,6 +159,8 @@ PostGIS 2.1.0
|
||||||
are handled when passing to GDAL Warp API
|
are handled when passing to GDAL Warp API
|
||||||
- #2215, Fixed raster exclusion constraint for conflicting name of
|
- #2215, Fixed raster exclusion constraint for conflicting name of
|
||||||
implicit index
|
implicit index
|
||||||
|
- #2251, Fix bad dimensions when rescaling rasters with default
|
||||||
|
geotransform matrix
|
||||||
|
|
||||||
PostGIS 2.0.3
|
PostGIS 2.0.3
|
||||||
2013/MM/DD
|
2013/MM/DD
|
||||||
|
|
|
@ -2299,7 +2299,6 @@ rt_errorstate rt_band_get_pixel_line(
|
||||||
void **vals, uint16_t *nvals
|
void **vals, uint16_t *nvals
|
||||||
) {
|
) {
|
||||||
uint8_t *_vals = NULL;
|
uint8_t *_vals = NULL;
|
||||||
rt_pixtype pixtype = PT_END;
|
|
||||||
int pixsize = 0;
|
int pixsize = 0;
|
||||||
uint8_t *data = NULL;
|
uint8_t *data = NULL;
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
|
@ -2334,7 +2333,6 @@ rt_errorstate rt_band_get_pixel_line(
|
||||||
offset = x + (y * band->width);
|
offset = x + (y * band->width);
|
||||||
RASTER_DEBUGF(4, "offset = %d", offset);
|
RASTER_DEBUGF(4, "offset = %d", offset);
|
||||||
|
|
||||||
pixtype = band->pixtype;
|
|
||||||
pixsize = rt_pixtype_size(band->pixtype);
|
pixsize = rt_pixtype_size(band->pixtype);
|
||||||
RASTER_DEBUGF(4, "pixsize = %d", pixsize);
|
RASTER_DEBUGF(4, "pixsize = %d", pixsize);
|
||||||
|
|
||||||
|
@ -3414,7 +3412,6 @@ rt_band_get_histogram(
|
||||||
double tmp;
|
double tmp;
|
||||||
double value;
|
double value;
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
int user_minmax = 0;
|
|
||||||
double qmin;
|
double qmin;
|
||||||
double qmax;
|
double qmax;
|
||||||
|
|
||||||
|
@ -3452,7 +3449,6 @@ rt_band_get_histogram(
|
||||||
qmax = stats->max;
|
qmax = stats->max;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
user_minmax = 1;
|
|
||||||
qmin = min;
|
qmin = min;
|
||||||
qmax = max;
|
qmax = max;
|
||||||
if (qmin > qmax) {
|
if (qmin > qmax) {
|
||||||
|
@ -9595,6 +9591,9 @@ rt_raster rt_raster_gdal_warp(
|
||||||
FLT_EQ(gt[5], -1)
|
FLT_EQ(gt[5], -1)
|
||||||
) {
|
) {
|
||||||
double ngt[6] = {0, 10, 0, 0, 0, -10};
|
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);
|
GDALSetGeoTransform(arg->src.ds, ngt);
|
||||||
GDALFlushCache(arg->src.ds);
|
GDALFlushCache(arg->src.ds);
|
||||||
|
|
||||||
|
@ -9742,6 +9741,12 @@ rt_raster rt_raster_gdal_warp(
|
||||||
) {
|
) {
|
||||||
_scale[0] = fabs(*scale_x);
|
_scale[0] = fabs(*scale_x);
|
||||||
_scale[1] = fabs(*scale_y);
|
_scale[1] = fabs(*scale_y);
|
||||||
|
|
||||||
|
/* special override */
|
||||||
|
if (subgt) {
|
||||||
|
_scale[0] *= 10;
|
||||||
|
_scale[1] *= 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
((NULL != scale_x) && (NULL == scale_y)) ||
|
((NULL != scale_x) && (NULL == scale_y)) ||
|
||||||
|
@ -10275,6 +10280,7 @@ rt_raster rt_raster_gdal_warp(
|
||||||
/* substitute geotransform matrix, reset back to default */
|
/* substitute geotransform matrix, reset back to default */
|
||||||
if (subgt) {
|
if (subgt) {
|
||||||
double gt[6] = {0, 1, 0, 0, 0, -1};
|
double gt[6] = {0, 1, 0, 0, 0, -1};
|
||||||
|
|
||||||
rt_raster_set_geotransform_matrix(rast, gt);
|
rt_raster_set_geotransform_matrix(rast, gt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -850,4 +850,13 @@ SELECT -- ticket #2188
|
||||||
), bar AS (
|
), bar AS (
|
||||||
SELECT rid, ST_Metadata(rast) AS meta, ST_SummaryStats(rast) AS stats FROM foo
|
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;
|
||||||
|
|
|
@ -2,6 +2,9 @@ NOTICE: table "raster_gdalwarp_src" does not exist, skipping
|
||||||
NOTICE: table "raster_gdalwarp_dst" 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: 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
|
||||||
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|||||||||||||
|
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
|
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
|
NOTICE: The rasters (pixel corner coordinates) are not aligned
|
||||||
t|f|t
|
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
|
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
|
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
|
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
|
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)
|
||||||
|
|
Loading…
Reference in a new issue