rt_band_set_pixel_line(
rt_band band,
int x, int y,
- void *vals, uint16_t len
+ void *vals, uint32_t len
) {
rt_pixtype pixtype = PT_END;
int size = 0;
assert(NULL != band);
+ RASTER_DEBUGF(3, "length of values = %d", len);
+
if (band->offline) {
rterror("rt_band_set_pixel_line not implemented yet for OFFDB bands");
return ES_ERROR;
data = rt_band_get_data(band);
offset = x + (y * band->width);
- RASTER_DEBUGF(5, "offset = %d", offset);
+ RASTER_DEBUGF(4, "offset = %d", offset);
/* make sure len of values to copy don't exceed end of data */
if (len > (band->width * band->height) - offset) {
rtwarn("rt_raster_to_gdal_mem: Could not set nodata value for band");
RASTER_DEBUGF(3, "nodata value set to %f", GDALGetRasterNoDataValue(band, NULL));
}
+
+#if POSTGIS_DEBUG_LEVEL > 3
+ {
+ GDALRasterBandH _grb = NULL;
+ double _min;
+ double _max;
+ double _mean;
+ double _stddev;
+
+ _grb = GDALGetRasterBand(ds, i + 1);
+ GDALComputeRasterStatistics(_grb, FALSE, &_min, &_max, &_mean, &_stddev, NULL, NULL);
+ RASTER_DEBUGF(4, "GDAL Band %d stats: %f, %f, %f, %f", i + 1, _min, _max, _mean, _stddev);
+ }
+#endif
+
}
/* necessary??? */
rt_raster_destroy(rast);
return NULL;
}
- RASTER_DEBUGF(3, "Raster geotransform (%f, %f, %f, %f, %f, %f)",
- gt[0], gt[1], gt[2], gt[3], gt[4], gt[5]);
/* apply raster attributes */
rt_raster_set_geotransform_matrix(rast, gt);
+ RASTER_DEBUGF(3, "Raster geotransform (%f, %f, %f, %f, %f, %f)",
+ gt[0], gt[1], gt[2], gt[3], gt[4], gt[5]);
+
/* srid */
srs = GDALGetProjectionRef(ds);
if (srs != NULL && srs[0] != '\0') {
pszAuthorityCode != NULL
) {
rt_raster_set_srid(rast, atoi(pszAuthorityCode));
+ RASTER_DEBUGF(3, "New raster's SRID = %d", rast->srid);
}
}
OSRDestroySpatialReference(hSRS);
}
- /* copy bands */
numBands = GDALGetRasterCount(ds);
+
+#if POSTGIS_DEBUG_LEVEL > 3
+ for (i = 1; i <= numBands; i++) {
+ GDALRasterBandH _grb = NULL;
+ double _min;
+ double _max;
+ double _mean;
+ double _stddev;
+
+ _grb = GDALGetRasterBand(ds, i);
+ GDALComputeRasterStatistics(_grb, FALSE, &_min, &_max, &_mean, &_stddev, NULL, NULL);
+ RASTER_DEBUGF(4, "GDAL Band %d stats: %f, %f, %f, %f", i, _min, _max, _mean, _stddev);
+ }
+#endif
+
+ /* copy bands */
for (i = 1; i <= numBands; i++) {
RASTER_DEBUGF(3, "Processing band %d of %d", i, numBands);
gdband = NULL;
/* size: width and height */
width = GDALGetRasterBandXSize(gdband);
height = GDALGetRasterBandYSize(gdband);
- RASTER_DEBUGF(3, "Band dimensions (width x height): %d x %d", width, height);
+ RASTER_DEBUGF(3, "GDAL band dimensions (width x height): %d x %d", width, height);
/* nodata */
nodataval = GDALGetRasterNoDataValue(gdband, &status);
rt_raster_destroy(rast);
return NULL;
}
+ RASTER_DEBUGF(3, "values len = %d", valueslen);
for (iYBlock = 0; iYBlock < nYBlocks; iYBlock++) {
for (iXBlock = 0; iXBlock < nXBlocks; iXBlock++) {
- memset(values, 0, valueslen);
-
x = iXBlock * nXBlockSize;
y = iYBlock * nYBlockSize;
RASTER_DEBUGF(4, "(iXBlock, iYBlock) = (%d, %d)", iXBlock, iYBlock);
RASTER_DEBUGF(4, "(x, y) = (%d, %d)", x, y);
+ memset(values, 0, valueslen);
+
/* valid block width */
if ((iXBlock + 1) * nXBlockSize > width)
nXValid = width - (iXBlock * nXBlockSize);
0, 0
);
if (cplerr != CE_None) {
- rterror("rt_raster_from_gdal_dataset: Unable to get data from transformed raster");
+ rterror("rt_raster_from_gdal_dataset: Unable to get data from GDAL raster");
rtdealloc(values);
rt_raster_destroy(rast);
return NULL;
return NULL;
}
RASTER_DEBUG(3, "raster loaded into GDAL MEM dataset");
- {
- GDALRasterBandH _grb = NULL;
- double _min;
- double _max;
- double _mean;
- double _stddev;
-
- _grb = GDALGetRasterBand(arg->src.ds, 1);
- GDALComputeRasterStatistics(_grb, FALSE, &_min, &_max, &_mean, &_stddev, NULL, NULL);
- RASTER_DEBUGF(4, "GDAL stats: %f, %f, %f, %f", _min, _max, _mean, _stddev);
- }
/* set transform options */
if (arg->src.srs != NULL || arg->dst.srs != NULL) {
ST_MakeEmptyRaster(1000, 1000, 0, 0, 1, -1, 0, 0, 0)
, 1, '8BUI', 255, 0
)
- , '50%', '500') AS rast
+ , '50%', '500'
+ ) AS rast
UNION ALL
SELECT
2 AS rid,
ST_MakeEmptyRaster(1000, 1000, 0, 0, 1, -1, 0, 0, 0)
, 1, '8BUI', 255, 0
)
- , 500, 100) AS rast
+ , 500, 100
+ ) AS rast
UNION ALL
SELECT
3 AS rid,
ST_MakeEmptyRaster(1000, 1000, 0, 0, 1, -1, 0, 0, 0)
, 1, '8BUI', 255, 0
)
- , 0.25, 0.9) AS rast
+ , 0.25, 0.9
+ ) AS rast
+UNION ALL
+SELECT -- ticket #2188
+ 4 AS rid,
+ ST_Resize(
+ ST_AddBand(
+ ST_MakeEmptyRaster(1024, 768, 0, 0, 1, -1, 0, 0, 0)
+ , 1, '8BUI', 255, 0
+ )
+ , 0.5, 0.5
+ ) AS rast
), bar AS (
- SELECT rid, ST_Metadata(rast) AS meta, rast FROM foo
+ SELECT rid, ST_Metadata(rast) AS meta, ST_SummaryStats(rast) AS stats FROM foo
)
-SELECT rid, (meta).* FROM bar
+SELECT rid, (meta).*, (stats).* FROM bar