dst_gt[4] = _skew_y;
dst_gt[5] = -1 * _scale_y;
+ /* user provided negative scale-x */
+ if (
+ (NULL != scale_x) &&
+ (*scale_x < 0.)
+ ) {
+ dst_gt[0] = src_env.MaxX;
+ dst_gt[1] = *scale_x;
+ }
+ /* user provided positive scale-y */
+ if (
+ (NULL != scale_y) &&
+ (*scale_y > 0)
+ ) {
+ dst_gt[3] = src_env.MinY;
+ dst_gt[5] = *scale_y;
+ }
+
RASTER_DEBUGF(3, "Applied extent: %f, %f, %f, %f",
src_env.MinX, src_env.MaxY, src_env.MaxX, src_env.MinY);
RASTER_DEBUGF(3, "Applied geotransform: %f, %f, %f, %f, %f, %f",
err = 1;
}
/* scales must match */
- else if (FLT_NEQ(rast1->scaleX, rast2->scaleX)) {
+ else if (FLT_NEQ(fabs(rast1->scaleX), fabs(rast2->scaleX))) {
RASTER_DEBUG(3, "The two raster provided have different scales on the X axis");
err = 1;
}
- else if (FLT_NEQ(rast1->scaleY, rast2->scaleY)) {
+ else if (FLT_NEQ(fabs(rast1->scaleY), fabs(rast2->scaleY))) {
RASTER_DEBUG(3, "The two raster provided have different scales on the Y axis");
err = 1;
}
len = sizeof(char) * (strlen("SELECT srtext FROM spatial_ref_sys WHERE srid = LIMIT 1") + MAX_INT_CHARLEN + 1);
sql = (char *) palloc(len);
if (NULL == sql) {
- elog(ERROR, "getSrtextSPI: Unable to allocate memory for sql\n");
+ elog(ERROR, "rtpg_getSRTextSPI: Unable to allocate memory for sql\n");
return NULL;
}
spi_result = SPI_connect();
if (spi_result != SPI_OK_CONNECT) {
- elog(ERROR, "getSrtextSPI: Could not connect to database using SPI\n");
+ elog(ERROR, "rtpg_getSRTextSPI: Could not connect to database using SPI\n");
pfree(sql);
return NULL;
}
spi_result = SPI_execute(sql, TRUE, 0);
pfree(sql);
if (spi_result != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
- elog(ERROR, "getSrtextSPI: Cannot find SRID (%d) in spatial_ref_sys", srid);
+ elog(ERROR, "rtpg_getSRTextSPI: Cannot find SRID (%d) in spatial_ref_sys", srid);
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
return NULL;
tmp = SPI_getvalue(tuple, tupdesc, 1);
if (NULL == tmp || !strlen(tmp)) {
- elog(ERROR, "getSrtextSPI: Cannot find SRID (%d) in spatial_ref_sys", srid);
+ elog(ERROR, "rtpg_getSRTextSPI: Cannot find SRID (%d) in spatial_ref_sys", srid);
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
return NULL;
len = strlen(tmp);
srs = (char *) palloc(sizeof(char) * (len + 1));
if (NULL == srs) {
- elog(ERROR, "getSrtextSPI: Unable to allocate memory for srtext\n");
+ elog(ERROR, "rtpg_getSRTextSPI: Unable to allocate memory for srtext\n");
return NULL;
}
srs = strncpy(srs, tmp, len + 1);
default:
elog(ERROR, "RASTER_histogram: Invalid data type for width");
rt_raster_destroy(raster);
- PG_RETURN_NULL();
+ SRF_RETURN_DONE(funcctx);
break;
}
/* column name is null, return null */
if (PG_ARGISNULL(1)) {
elog(NOTICE, "Column name must be provided");
- PG_RETURN_NULL();
+ SRF_RETURN_DONE(funcctx);
}
colnametext = PG_GETARG_TEXT_P(1);
colname = text_to_cstring(colnametext);
default:
elog(ERROR, "RASTER_quantile: Invalid data type for quantiles");
rt_raster_destroy(raster);
- PG_RETURN_NULL();
+ SRF_RETURN_DONE(funcctx);
break;
}
/* column name is null, return null */
if (PG_ARGISNULL(1)) {
elog(NOTICE, "Column name must be provided");
- PG_RETURN_NULL();
+ SRF_RETURN_DONE(funcctx);
}
colnametext = PG_GETARG_TEXT_P(1);
colname = text_to_cstring(colnametext);
default:
elog(ERROR, "RASTER_quantileCoverage: Invalid data type for quantiles");
rt_raster_destroy(raster);
- PG_RETURN_NULL();
+ SRF_RETURN_DONE(funcctx);
break;
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
elog(ERROR, "RASTER_valueCount: Could not deserialize raster");
- PG_RETURN_NULL();
+ SRF_RETURN_DONE(funcctx);
}
/* band index is 1-based */
default:
elog(ERROR, "RASTER_valueCount: Invalid data type for values");
rt_raster_destroy(raster);
- PG_RETURN_NULL();
+ SRF_RETURN_DONE(funcctx);
break;
}
/* column name is null, return null */
if (PG_ARGISNULL(1)) {
elog(NOTICE, "Column name must be provided");
- PG_RETURN_NULL();
+ SRF_RETURN_DONE(funcctx);
}
colnametext = PG_GETARG_TEXT_P(1);
colname = text_to_cstring(colnametext);
default:
elog(ERROR, "RASTER_valueCountCoverage: Invalid data type for values");
rt_raster_destroy(raster);
- PG_RETURN_NULL();
+ SRF_RETURN_DONE(funcctx);
break;
}
), (
1.2, (SELECT ST_AsRaster(
geom,
- 100., 100.
+ 100., -100.
) FROM raster_asraster_geom)
), (
1.3, (SELECT ST_AsRaster(
), (
1.4, (SELECT ST_AsRaster(
geom,
- 1000., 1000.
+ 1000., -1000.
) FROM raster_asraster_geom)
), (
1.5, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
'8BSI'
) FROM raster_asraster_geom)
), (
1.6, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
'16BUI'
) FROM raster_asraster_geom)
), (
1.7, (SELECT ST_AsRaster(
geom,
- 100., 100.,
+ 100., -100.,
'32BF'
) FROM raster_asraster_geom)
), (
1.8, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
ARRAY['8BSI']
) FROM raster_asraster_geom)
), (
1.9, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
ARRAY['16BUI']
) FROM raster_asraster_geom)
), (
1.10, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
ARRAY['32BF']
) FROM raster_asraster_geom)
), (
), (
1.17, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
ARRAY['32BF', '16BUI'],
ARRAY[255, 1],
ARRAY[NULL, 0]::double precision[]
), (
1.19, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
ARRAY['32BF', '16BUI', '64BF'],
ARRAY[255, 1, -1],
ARRAY[NULL, 0, NULL]::double precision[]
), (
1.20, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
ARRAY['1BB', '2BUI'],
ARRAY[1, 1],
ARRAY[1, 0]::double precision[]
INSERT INTO raster_asraster_dst (rid, rast) VALUES (
2.1, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
'8BUI',
255,
0,
), (
2.2, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
'8BUI',
255,
0,
), (
2.3, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
'8BUI',
255,
0,
), (
2.4, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
'8BUI',
255,
0,
), (
2.5, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
'8BUI',
255,
0,
), (
4.8, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
0, 0,
ARRAY['16BUI'],
ARRAY[13],
), (
4.9, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
-175453, 114987,
ARRAY['16BUI'],
ARRAY[13],
), (
4.10, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
-100, 100,
ARRAY['16BUI'],
ARRAY[13],
), (
4.11, (SELECT ST_AsRaster(
geom,
- 1000., 1000.,
+ 1000., -1000.,
-100, 100,
'16BUI',
13,