* -a function got an invalid argument ('3BUI' as pixel type) so that no row can
* be processed
*
+ * *** IMPORTANT: elog(ERROR, ...) does NOT return to calling function ***
+ *
* Send a NOTICE like:
*
* elog(NOTICE, "Invalid band index (must use 1-based). Returning NULL");
spi_result = SPI_connect();
if (spi_result != SPI_OK_CONNECT) {
- elog(ERROR, "rtpg_getSR: Could not connect to database using SPI\n");
pfree(sql);
+ elog(ERROR, "rtpg_getSR: Could not connect to database using SPI\n");
return NULL;
}
spi_result = SPI_execute(sql, TRUE, 0);
SPI_pfree(sql);
if (spi_result != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
- elog(ERROR, "rtpg_getSR: Cannot find SRID (%d) in spatial_ref_sys", srid);
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
+ elog(ERROR, "rtpg_getSR: Cannot find SRID (%d) in spatial_ref_sys", srid);
return NULL;
}
len = strlen(tmp) + 1;
srs = SPI_palloc(sizeof(char) * len);
if (NULL == srs) {
- elog(ERROR, "rtpg_getSR: Could not allocate memory for spatial reference text\n");
pfree(tmp);
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
+ elog(ERROR, "rtpg_getSR: Could not allocate memory for spatial reference text\n");
return NULL;
}
strncpy(srs, tmp, len);
/* unable to get SR info */
if (srs == NULL) {
- elog(ERROR, "rtpg_getSR: Could not find a viable spatial reference for SRID (%d)", srid);
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
+ elog(ERROR, "rtpg_getSR: Could not find a viable spatial reference for SRID (%d)", srid);
return NULL;
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_out: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_out: Could not deserialize raster");
PG_RETURN_NULL();
}
hexwkb = rt_raster_to_hexwkb(raster, FALSE, &hexwkbsize);
if (!hexwkb) {
- elog(ERROR, "RASTER_out: Could not HEX-WKBize raster");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_out: Could not HEX-WKBize raster");
PG_RETURN_NULL();
}
/* Get raster object */
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_to_bytea: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_to_bytea: Could not deserialize raster");
PG_RETURN_NULL();
}
/* Parse raster to wkb object */
wkb = rt_raster_to_wkb(raster, FALSE, &wkb_size);
if (!wkb) {
- elog(ERROR, "RASTER_to_bytea: Could not allocate and generate WKB data");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_to_bytea: Could not allocate and generate WKB data");
PG_RETURN_NULL();
}
/* Get raster object */
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_to_binary: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_to_binary: Could not deserialize raster");
PG_RETURN_NULL();
}
/* Parse raster to wkb object */
wkb = rt_raster_to_wkb(raster, outasin, &wkb_size);
if (!wkb) {
- elog(ERROR, "RASTER_to_binary: Could not allocate and generate WKB data");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_to_binary: Could not allocate and generate WKB data");
PG_RETURN_NULL();
}
}
if (!raster) {
- elog(ERROR, "RASTER_convex_hull: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_convex_hull: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getSRID: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getSRID: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_setSRID: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setSRID: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getWidth: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getWidth: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getHeight: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getHeight: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getNumBands: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getNumBands: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getXScale: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getXScale: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getYScale: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getYScale: Could not deserialize raster");
PG_RETURN_NULL();
}
pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_setScale: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setScale: Could not deserialize raster");
PG_RETURN_NULL();
}
pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_setScaleXY: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setScaleXY: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getXSkew: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getXSkew: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getYSkew: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getYSkew: Could not deserialize raster");
PG_RETURN_NULL();
}
pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_setSkew: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setSkew: Could not deserialize raster");
PG_RETURN_NULL();
}
pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_setSkewXY: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setSkewXY: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getXUpperLeft: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getXUpperLeft: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getYUpperLeft: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getYUpperLeft: Could not deserialize raster");
PG_RETURN_NULL();
}
pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_setUpperLeftXY: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setUpperLeftXY: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if (!raster) {
- elog(ERROR, "RASTER_getPixelWidth: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getPixelWidth: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if (!raster) {
- elog(ERROR, "RASTER_getPixelHeight: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getPixelHeight: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, TRUE);
if (!raster) {
- elog(ERROR, "RASTER_setGeotransform: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setGeotransform: Could not deserialize raster");
PG_RETURN_NULL();
}
/* raster */
raster = rt_raster_deserialize(pgraster, TRUE);
if (!raster) {
- elog(ERROR, "RASTER_getGeotransform: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getGeotransform: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (! raster ) {
- elog(ERROR, "RASTER_setRotation: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setRotation: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getBandPixelType: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getBandPixelType: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getBandPixelTypeName: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getBandPixelTypeName: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getBandNoDataValue: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getBandNoDataValue: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_setBandNoDataValue: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setBandNoDataValue: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_setBandIsNoData: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setBandIsNoData: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if ( ! raster ) {
- elog(ERROR, "RASTER_bandIsNoData: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_bandIsNoData: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if ( ! raster ) {
- elog(ERROR, "RASTER_getBandPath: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getBandPath: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_getPixelValue: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getPixelValue: Could not deserialize raster");
PG_RETURN_NULL();
}
/* initialize arg1 */
arg1 = rtpg_dumpvalues_arg_init();
if (arg1 == NULL) {
- elog(ERROR, "RASTER_dumpValues: Could not initialize argument structure");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_dumpValues: Could not initialize argument structure");
SRF_RETURN_DONE(funcctx);
}
case INT4OID:
break;
default:
- elog(ERROR, "RASTER_dumpValues: Invalid data type for band indexes");
rtpg_dumpvalues_arg_destroy(arg1);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_dumpValues: Invalid data type for band indexes");
SRF_RETURN_DONE(funcctx);
break;
}
arg1->nbands = palloc(sizeof(int) * arg1->numbands);
if (arg1->nbands == NULL) {
- elog(ERROR, "RASTER_dumpValues: Could not allocate memory for band indexes");
rtpg_dumpvalues_arg_destroy(arg1);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_dumpValues: Could not allocate memory for band indexes");
SRF_RETURN_DONE(funcctx);
}
if (j < arg1->numbands) {
arg1->nbands = repalloc(arg1->nbands, sizeof(int) * j);
if (arg1->nbands == NULL) {
- elog(ERROR, "RASTER_dumpValues: Could not reallocate memory for band indexes");
rtpg_dumpvalues_arg_destroy(arg1);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_dumpValues: Could not reallocate memory for band indexes");
SRF_RETURN_DONE(funcctx);
}
arg1->nbands = palloc(sizeof(int) * arg1->numbands);
if (arg1->nbands == NULL) {
- elog(ERROR, "RASTER_dumpValues: Could not allocate memory for band indexes");
rtpg_dumpvalues_arg_destroy(arg1);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_dumpValues: Could not allocate memory for band indexes");
SRF_RETURN_DONE(funcctx);
}
arg1->values = palloc(sizeof(Datum *) * arg1->numbands);
arg1->nodata = palloc(sizeof(bool *) * arg1->numbands);
if (arg1->values == NULL || arg1->nodata == NULL) {
- elog(ERROR, "RASTER_dumpValues: Could not allocate memory for pixel values");
rtpg_dumpvalues_arg_destroy(arg1);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_dumpValues: Could not allocate memory for pixel values");
SRF_RETURN_DONE(funcctx);
}
memset(arg1->values, 0, sizeof(Datum *) * arg1->numbands);
for (z = 0; z < arg1->numbands; z++) {
band = rt_raster_get_band(raster, arg1->nbands[z]);
if (!band) {
- elog(ERROR, "RASTER_dumpValues: Could not get band at index %d", arg1->nbands[z] + 1);
+ int nband = arg1->nbands[z] + 1;
rtpg_dumpvalues_arg_destroy(arg1);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_dumpValues: Could not get band at index %d", nband);
SRF_RETURN_DONE(funcctx);
}
arg1->values[z] = palloc(sizeof(Datum) * arg1->rows * arg1->columns);
arg1->nodata[z] = palloc(sizeof(bool) * arg1->rows * arg1->columns);
if (arg1->values[z] == NULL || arg1->nodata[z] == NULL) {
- elog(ERROR, "RASTER_dumpValues: Could not allocate memory for pixel values");
rtpg_dumpvalues_arg_destroy(arg1);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_dumpValues: Could not allocate memory for pixel values");
SRF_RETURN_DONE(funcctx);
}
memset(arg1->values[z], 0, sizeof(Datum) * arg1->rows * arg1->columns);
for (x = 0; x < arg1->columns; x++) {
/* get pixel */
if (rt_band_get_pixel(band, x, y, &val, &isnodata) != ES_NONE) {
- elog(ERROR, "RASTER_dumpValues: Could not pixel (%d, %d) of band %d", x, y, arg1->nbands[z] + 1);
+ int nband = arg1->nbands[z] + 1;
rtpg_dumpvalues_arg_destroy(arg1);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_dumpValues: Could not pixel (%d, %d) of band %d", x, y, nband);
SRF_RETURN_DONE(funcctx);
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
+ PG_FREE_IF_COPY(pgraster, 0);
elog(ERROR, "RASTER_setPixelValue: Could not deserialize raster");
- pfree(pgraster);
PG_RETURN_NULL();
}
/* raster */
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_setPixelValuesArray: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesArray: Could not deserialize raster");
PG_RETURN_NULL();
}
case FLOAT8OID:
break;
default:
- elog(ERROR, "RASTER_setPixelValuesArray: Invalid data type for new values");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesArray: Invalid data type for new values");
PG_RETURN_NULL();
break;
}
/* # of elements doesn't match dims */
if (num < 1 || num != (dimpixval[0] * dimpixval[1])) {
- elog(ERROR, "RASTER_setPixelValuesArray: Could not deconstruct new values array");
if (num) {
pfree(elements);
pfree(nulls);
}
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesArray: Could not deconstruct new values array");
PG_RETURN_NULL();
}
numpixval = num;
pixval = palloc(sizeof(struct pixelvalue) * numpixval);
if (pixval == NULL) {
- elog(ERROR, "RASTER_setPixelValuesArray: Could not allocate memory for new pixel values");
pfree(elements);
pfree(nulls);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesArray: Could not allocate memory for new pixel values");
PG_RETURN_NULL();
}
case BOOLOID:
break;
default:
- elog(ERROR, "RASTER_setPixelValuesArray: Invalid data type for noset flags");
pfree(pixval);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesArray: Invalid data type for noset flags");
PG_RETURN_NULL();
break;
}
/* # of elements doesn't match dims */
if (num < 1 || num != (dimnoset[0] * dimnoset[1])) {
- elog(ERROR, "RASTER_setPixelValuesArray: Could not deconstruct noset flags array");
pfree(pixval);
if (num) {
pfree(elements);
}
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesArray: Could not deconstruct noset flags array");
PG_RETURN_NULL();
}
if (hasnodata && keepnodata) {
rtn = rt_band_get_pixel(band, pixval[i].x, pixval[i].y, &val, &isnodata);
if (rtn != ES_NONE) {
- elog(ERROR, "Cannot get value of pixel. Returning NULL");
pfree(pixval);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "Cannot get value of pixel");
PG_RETURN_NULL();
}
/* raster */
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not deserialize raster");
PG_RETURN_NULL();
}
/* init arg */
arg = rtpg_setvaluesgv_arg_init();
if (arg == NULL) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not intialize argument structure");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not intialize argument structure");
PG_RETURN_NULL();
}
arg->gv = palloc(sizeof(struct rtpg_setvaluesgv_geomval_t) * n);
if (arg->gv == NULL) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not allocate memory for geomval array");
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not allocate memory for geomval array");
PG_RETURN_NULL();
}
/* each element is a tuple */
tup = (HeapTupleHeader) DatumGetPointer(e[i]);
if (NULL == tup) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Invalid argument for geomval at index %d", i);
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Invalid argument for geomval at index %d", i);
PG_RETURN_NULL();
}
gser = (GSERIALIZED *) PG_DETOAST_DATUM(tupv);
arg->gv[arg->ngv].geom = lwgeom_from_gserialized(gser);
if (arg->gv[arg->ngv].geom == NULL) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not deserialize geometry of geomval at index %d", i);
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not deserialize geometry of geomval at index %d", i);
PG_RETURN_NULL();
}
}
if (arg->gv[arg->ngv].mask == NULL) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not rasterize geometry of geomval at index %d", i);
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not rasterize geometry of geomval at index %d", i);
PG_RETURN_NULL();
}
if (arg->ngv < n) {
arg->gv = repalloc(arg->gv, sizeof(struct rtpg_setvaluesgv_geomval_t) * arg->ngv);
if (arg->gv == NULL) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not reallocate memory for geomval array");
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not reallocate memory for geomval array");
PG_RETURN_NULL();
}
}
getPoint2d_p(point->point, 0, &p);
if (rt_raster_geopoint_to_cell(raster, p.x, p.y, &(xy[0]), &(xy[1]), igt) != ES_NONE) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not process coordinates of point");
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not process coordinates of point");
PG_RETURN_NULL();
}
/* get pixel value */
if (rt_band_get_pixel(band, xy[0], xy[1], &value, &isnodata) != ES_NONE) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not get pixel value");
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not get pixel value");
PG_RETURN_NULL();
}
noerr = rt_band_set_pixel(band, xy[0], xy[1], arg->gv[i].pixval.value, NULL);
if (noerr != ES_NONE) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not set pixel value");
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not set pixel value");
PG_RETURN_NULL();
}
}
/* init itrset */
itrset = palloc(sizeof(struct rt_iterator_t) * (arg->ngv + 1));
if (itrset == NULL) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not allocate memory for iterator arguments");
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not allocate memory for iterator arguments");
PG_RETURN_NULL();
}
pfree(itrset);
if (noerr != ES_NONE) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not run raster iterator function");
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not run raster iterator function");
PG_RETURN_NULL();
}
/* copy band from _raster to raster */
_band = rt_raster_get_band(_raster, 0);
if (_band == NULL) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not get band from working raster");
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(_raster);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not get band from working raster");
PG_RETURN_NULL();
}
_band = rt_raster_replace_band(raster, _band, nband - 1);
if (_band == NULL) {
- elog(ERROR, "RASTER_setPixelValuesGeomval: Could not replace band in output raster");
rtpg_setvaluesgv_arg_destroy(arg);
rt_raster_destroy(_raster);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_setPixelValuesGeomval: Could not replace band in output raster");
PG_RETURN_NULL();
}
/* geometry */
poly = rt_raster_pixel_as_polygon(raster, x - 1, y - 1);
if (!poly) {
- elog(ERROR, "RASTER_getPixelPolygons: Could not get pixel polygon");
-
for (i = 0; i < pixcount; i++)
lwgeom_free(pix[i].geom);
if (pixcount) pfree(pix);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_getPixelPolygons: Could not get pixel polygon");
SRF_RETURN_DONE(funcctx);
}
else
pix = repalloc(pix, sizeof(struct rt_pixel_t) * (pixcount + 1));
if (pix == NULL) {
- elog(ERROR, "RASTER_getPixelPolygons: Could not allocate memory for storing pixel polygons");
lwpoly_free(poly);
if (!noband) rt_band_destroy(band);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_getPixelPolygons: Could not allocate memory for storing pixel polygons");
SRF_RETURN_DONE(funcctx);
}
pix[pixcount].geom = (LWGEOM *) poly;
/* value, NODATA flag */
if (!noband) {
if (rt_band_get_pixel(band, x - 1, y - 1, &(pix[pixcount].value), &isnodata) != ES_NONE) {
- elog(ERROR, "RASTER_getPixelPolygons: Could not get pixel value");
for (i = 0; i < pixcount; i++)
lwgeom_free(pix[i].geom);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_getPixelPolygons: Could not get pixel value");
SRF_RETURN_DONE(funcctx);
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_getPolygon: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_getPolygon: Could not deserialize raster");
PG_RETURN_NULL();
}
pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_pixelOfValue: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_pixelOfValue: Could not deserialize raster");
SRF_RETURN_DONE(funcctx);
}
case FLOAT8OID:
break;
default:
- elog(ERROR, "RASTER_pixelOfValue: Invalid data type for pixel values");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_pixelOfValue: Invalid data type for pixel values");
SRF_RETURN_DONE(funcctx);
break;
}
pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_nearestValue: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_nearestValue: Could not deserialize raster");
PG_RETURN_NULL();
}
&x, &y,
NULL
) != ES_NONE) {
- elog(ERROR, "RASTER_nearestValue: Could not compute pixel coordinates from spatial coordinates");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
lwgeom_free(lwgeom);
PG_FREE_IF_COPY(geom, 2);
+ elog(ERROR, "RASTER_nearestValue: Could not compute pixel coordinates from spatial coordinates");
PG_RETURN_NULL();
}
(y >= 0 && y < rt_raster_get_height(raster))
) {
if (rt_band_get_pixel(band, x, y, &value, &isnodata) != ES_NONE) {
- elog(ERROR, "RASTER_nearestValue: Could not get pixel value for band at index %d", bandindex);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
lwgeom_free(lwgeom);
PG_FREE_IF_COPY(geom, 2);
+ elog(ERROR, "RASTER_nearestValue: Could not get pixel value for band at index %d", bandindex);
PG_RETURN_NULL();
}
/* convex-hull of pixel */
poly = rt_raster_pixel_as_polygon(raster, npixels[i].x, npixels[i].y);
if (!poly) {
- elog(ERROR, "RASTER_nearestValue: Could not get polygon of neighboring pixel");
lwgeom_free(lwgeom);
PG_FREE_IF_COPY(geom, 2);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_nearestValue: Could not get polygon of neighboring pixel");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_neighborhood: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_neighborhood: Could not deserialize raster");
PG_RETURN_NULL();
}
else
npixels = (rt_pixel) palloc(sizeof(struct rt_pixel_t));
if (npixels == NULL) {
- elog(ERROR, "RASTER_neighborhood: Could not reallocate memory for neighborhood");
rt_band_destroy(band);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_neighborhood: Could not reallocate memory for neighborhood");
PG_RETURN_NULL();
}
npixels[count - 1].x = _x;
nodata1D = palloc(sizeof(bool) * dim[0] * dim[1]);
if (value1D == NULL || nodata1D == NULL) {
- elog(ERROR, "RASTER_neighborhood: Could not allocate memory for return 2D array");
for (i = 0; i < dim[0]; i++) {
pfree(value2D[i]);
pfree(value2D);
pfree(nodata2D);
+ elog(ERROR, "RASTER_neighborhood: Could not allocate memory for return 2D array");
PG_RETURN_NULL();
}
/* raster */
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_addBand: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBand: Could not deserialize raster");
PG_RETURN_NULL();
}
&nulls, &n);
if (!n) {
- elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset");
PG_RETURN_NULL();
}
/* allocate addbandarg */
arg = (struct addbandarg *) palloc(sizeof(struct addbandarg) * n);
if (arg == NULL) {
- elog(ERROR, "RASTER_addBand: Could not allocate memory for addbandarg");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBand: Could not allocate memory for addbandarg");
PG_RETURN_NULL();
}
/* each element is a tuple */
tup = (HeapTupleHeader) DatumGetPointer(e[i]);
if (NULL == tup) {
- elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset");
pfree(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset");
PG_RETURN_NULL();
}
/* for now, only check that band index is 1-based */
if (!arg[i].append && arg[i].index < 1) {
- elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset. Invalid band index (must be 1-based) for addbandarg of index %d", i);
pfree(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset. Invalid band index (must be 1-based) for addbandarg of index %d", i);
PG_RETURN_NULL();
}
arg[i].pixtype = PT_END;
tupv = GetAttributeByName(tup, "pixeltype", &isnull);
if (isnull) {
- elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset. Pixel type cannot be NULL for addbandarg of index %d", i);
pfree(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset. Pixel type cannot be NULL for addbandarg of index %d", i);
PG_RETURN_NULL();
}
text_pixtype = (text *) DatumGetPointer(tupv);
if (text_pixtype == NULL) {
- elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset. Pixel type cannot be NULL for addbandarg of index %d", i);
pfree(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset. Pixel type cannot be NULL for addbandarg of index %d", i);
PG_RETURN_NULL();
}
char_pixtype = text_to_cstring(text_pixtype);
arg[i].pixtype = rt_pixtype_index_from_name(char_pixtype);
pfree(char_pixtype);
if (arg[i].pixtype == PT_END) {
- elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset. Invalid pixel type for addbandarg of index %d", i);
pfree(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBand: Invalid argument for addbandargset. Invalid pixel type for addbandarg of index %d", i);
PG_RETURN_NULL();
}
numbands = rt_raster_get_num_bands(raster);
if (numbands == lastnumbands || bandindex == -1) {
- elog(ERROR, "RASTER_addBand: Could not add band defined by addbandarg of index %d to raster", i);
pfree(arg);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBand: Could not add band defined by addbandarg of index %d to raster", i);
PG_RETURN_NULL();
}
/* raster */
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_addBandRasterArray: Could not deserialize destination raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBandRasterArray: Could not deserialize destination raster");
PG_RETURN_NULL();
}
pgsrc = (rt_pgraster *) PG_DETOAST_DATUM(e[i]);
src = rt_raster_deserialize(pgsrc, FALSE);
if (src == NULL) {
- elog(ERROR, "RASTER_addBandRasterArray: Could not deserialize source raster at index %d", i + 1);
pfree(nulls);
pfree(e);
if (raster != NULL)
rt_raster_destroy(raster);
if (pgraster != NULL)
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBandRasterArray: Could not deserialize source raster at index %d", i + 1);
PG_RETURN_NULL();
}
raster = rt_raster_from_band(src, srcnbands, 1);
rt_raster_destroy(src);
if (raster == NULL) {
- elog(ERROR, "RASTER_addBandRasterArray: Could not create raster from source raster at index %d", i + 1);
pfree(nulls);
pfree(e);
if (pgraster != NULL)
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBandRasterArray: Could not create raster from source raster at index %d", i + 1);
PG_RETURN_NULL();
}
}
/* raster */
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_addBandOutDB: Could not deserialize destination raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBandOutDB: Could not deserialize destination raster");
PG_RETURN_NULL();
}
case INT4OID:
break;
default:
- elog(ERROR, "RASTER_addBandOutDB: Invalid data type for band indexes");
if (pgraster != NULL) {
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
}
+ elog(ERROR, "RASTER_addBandOutDB: Invalid data type for band indexes");
PG_RETURN_NULL();
break;
}
srcnband = palloc(sizeof(int) * numsrcnband);
if (srcnband == NULL) {
- elog(ERROR, "RASTER_addBandOutDB: Could not allocate memory for band indexes");
if (pgraster != NULL) {
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
}
+ elog(ERROR, "RASTER_addBandOutDB: Could not allocate memory for band indexes");
PG_RETURN_NULL();
}
if (j < numsrcnband) {
srcnband = repalloc(srcnband, sizeof(int) * j);
if (srcnband == NULL) {
- elog(ERROR, "RASTER_addBandOutDB: Could not reallocate memory for band indexes");
if (pgraster != NULL) {
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
}
+ elog(ERROR, "RASTER_addBandOutDB: Could not reallocate memory for band indexes");
PG_RETURN_NULL();
}
rt_util_gdal_register_all();
hdsOut = GDALOpenShared(outdbfile, GA_ReadOnly);
if (hdsOut == NULL) {
- elog(ERROR, "RASTER_addBandOutDB: Could not open out-db file with GDAL");
if (pgraster != NULL) {
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
}
+ elog(ERROR, "RASTER_addBandOutDB: Could not open out-db file with GDAL");
PG_RETURN_NULL();
}
rt_raster_destroy(_rast);
if (err != ES_NONE) {
- elog(ERROR, "RASTER_addBandOutDB: Could not test alignment of out-db file");
GDALClose(hdsOut);
if (raster != NULL)
rt_raster_destroy(raster);
if (pgraster != NULL)
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBandOutDB: Could not test alignment of out-db file");
return ES_ERROR;
}
else if (!aligned)
numsrcnband = numbands;
srcnband = palloc(sizeof(int) * numsrcnband);
if (srcnband == NULL) {
- elog(ERROR, "RASTER_addBandOutDB: Could not allocate memory for band indexes");
GDALClose(hdsOut);
if (raster != NULL)
rt_raster_destroy(raster);
if (pgraster != NULL)
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBandOutDB: Could not allocate memory for band indexes");
PG_RETURN_NULL();
}
hbandOut = NULL;
hbandOut = GDALGetRasterBand(hdsOut, srcnband[i]);
if (NULL == hbandOut) {
- elog(ERROR, "RASTER_addBandOutDB: Could not get band %d from GDAL dataset", srcnband[i]);
GDALClose(hdsOut);
if (raster != NULL)
rt_raster_destroy(raster);
if (pgraster != NULL)
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBandOutDB: Could not get band %d from GDAL dataset", srcnband[i]);
PG_RETURN_NULL();
}
srcnband[i] - 1, outdbfile
);
if (band == NULL) {
- elog(ERROR, "RASTER_addBandOutDB: Could not create new out-db band");
GDALClose(hdsOut);
if (raster != NULL)
rt_raster_destroy(raster);
if (pgraster != NULL)
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBandOutDB: Could not create new out-db band");
PG_RETURN_NULL();
}
if (rt_raster_add_band(raster, band, j) < 0) {
- elog(ERROR, "RASTER_addBandOutDB: Could not add new out-db band to raster");
GDALClose(hdsOut);
if (raster != NULL)
rt_raster_destroy(raster);
if (pgraster != NULL)
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_addBandOutDB: Could not add new out-db band to raster");
PG_RETURN_NULL();
}
}
/* allocate arg1 */
arg1 = palloc(sizeof(struct tile_arg_t));
if (arg1 == NULL) {
- elog(ERROR, "RASTER_tile: Could not allocate memory for arguments");
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_tile: Could not allocate memory for arguments");
SRF_RETURN_DONE(funcctx);
}
case INT4OID:
break;
default:
- elog(ERROR, "RASTER_tile: Invalid data type for band indexes");
rt_raster_destroy(arg1->raster.raster);
pfree(arg1);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_tile: Invalid data type for band indexes");
SRF_RETURN_DONE(funcctx);
break;
}
arg1->nbands = palloc(sizeof(int) * arg1->numbands);
if (arg1->nbands == NULL) {
- elog(ERROR, "RASTER_tile: Could not allocate memory for band indexes");
rt_raster_destroy(arg1->raster.raster);
pfree(arg1);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_tile: Could not allocate memory for band indexes");
SRF_RETURN_DONE(funcctx);
}
if (j < arg1->numbands) {
arg1->nbands = repalloc(arg1->nbands, sizeof(int) * j);
if (arg1->nbands == NULL) {
- elog(ERROR, "RASTER_tile: Could not reallocate memory for band indexes");
rt_raster_destroy(arg1->raster.raster);
pfree(arg1);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_tile: Could not reallocate memory for band indexes");
SRF_RETURN_DONE(funcctx);
}
arg1->nbands = palloc(sizeof(int) * arg1->numbands);
if (arg1->nbands == NULL) {
- elog(ERROR, "RASTER_dumpValues: Could not allocate memory for pixel values");
rt_raster_destroy(arg1->raster.raster);
pfree(arg1);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_dumpValues: Could not allocate memory for pixel values");
SRF_RETURN_DONE(funcctx);
}
/* upper-left of tile in spatial coordinates */
if (rt_raster_cell_to_geopoint(arg2->raster.raster, rx, ry, &ulx, &uly, arg2->raster.gt) != ES_NONE) {
- elog(ERROR, "RASTER_tile: Could not compute the coordinates of the upper-left corner of the output tile");
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
if (arg2->numbands) pfree(arg2->nbands);
pfree(arg2);
+ elog(ERROR, "RASTER_tile: Could not compute the coordinates of the upper-left corner of the output tile");
SRF_RETURN_DONE(funcctx);
}
rt_raster_set_offsets(tile, ulx, uly);
_band = rt_raster_get_band(arg2->raster.raster, arg2->nbands[i]);
if (_band == NULL) {
- elog(ERROR, "RASTER_tile: Could not get band %d from source raster", arg2->nbands[i] + 1);
+ int nband = arg2->nbands[i] + 1;
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
if (arg2->numbands) pfree(arg2->nbands);
pfree(arg2);
+ elog(ERROR, "RASTER_tile: Could not get band %d from source raster", nband);
SRF_RETURN_DONE(funcctx);
}
/* inline band */
if (!rt_band_is_offline(_band)) {
if (rt_raster_generate_new_band(tile, pixtype, nodataval, hasnodata, nodataval, i) < 0) {
- elog(ERROR, "RASTER_tile: Could not add new band to output tile");
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
pfree(arg2->nbands);
pfree(arg2);
+ elog(ERROR, "RASTER_tile: Could not add new band to output tile");
SRF_RETURN_DONE(funcctx);
}
band = rt_raster_get_band(tile, i);
if (band == NULL) {
- elog(ERROR, "RASTER_tile: Could not get newly added band from output tile");
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
if (arg2->numbands) pfree(arg2->nbands);
pfree(arg2);
+ elog(ERROR, "RASTER_tile: Could not get newly added band from output tile");
SRF_RETURN_DONE(funcctx);
}
POSTGIS_RT_DEBUGF(4, "getting pixel line %d, %d for %d pixels", rx, k, len);
if (rt_band_get_pixel_line(_band, rx, k, len, &vals, &nvals) != ES_NONE) {
- elog(ERROR, "RASTER_tile: Could not get pixel line from source raster");
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
if (arg2->numbands) pfree(arg2->nbands);
pfree(arg2);
+ elog(ERROR, "RASTER_tile: Could not get pixel line from source raster");
SRF_RETURN_DONE(funcctx);
}
if (nvals && rt_band_set_pixel_line(band, 0, j, vals, nvals) != ES_NONE) {
- elog(ERROR, "RASTER_tile: Could not set pixel line of output tile");
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
if (arg2->numbands) pfree(arg2->nbands);
pfree(arg2);
+ elog(ERROR, "RASTER_tile: Could not set pixel line of output tile");
SRF_RETURN_DONE(funcctx);
}
}
);
if (band == NULL) {
- elog(ERROR, "RASTER_tile: Could not create new offline band for output tile");
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
if (arg2->numbands) pfree(arg2->nbands);
pfree(arg2);
+ elog(ERROR, "RASTER_tile: Could not create new offline band for output tile");
SRF_RETURN_DONE(funcctx);
}
if (rt_raster_add_band(tile, band, i) < 0) {
- elog(ERROR, "RASTER_tile: Could not add new offline band to output tile");
rt_band_destroy(band);
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
if (arg2->numbands) pfree(arg2->nbands);
pfree(arg2);
+ elog(ERROR, "RASTER_tile: Could not add new offline band to output tile");
SRF_RETURN_DONE(funcctx);
}
}
torast = rt_raster_deserialize(pgto, FALSE);
if (!torast) {
- elog(ERROR, "RASTER_copyBand: Could not deserialize first raster");
PG_FREE_IF_COPY(pgto, 0);
+ elog(ERROR, "RASTER_copyBand: Could not deserialize first raster");
PG_RETURN_NULL();
}
fromrast = rt_raster_deserialize(pgfrom, FALSE);
if (!fromrast) {
- elog(ERROR, "RASTER_copyBand: Could not deserialize second raster");
rt_raster_destroy(torast);
PG_FREE_IF_COPY(pgfrom, 1);
PG_FREE_IF_COPY(pgto, 0);
+ elog(ERROR, "RASTER_copyBand: Could not deserialize second raster");
PG_RETURN_NULL();
}
pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
raster = rt_raster_deserialize(pgraster, FALSE);
if (NULL == raster) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not deserialize raster");
PG_RETURN_NULL();
}
newrast = rt_raster_new(width, height);
if ( NULL == newrast ) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not create a new raster. "
- "Returning NULL");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not create a new raster");
PG_RETURN_NULL();
}
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster");
PG_RETURN_NULL();
}
}
if (newpixeltype == PT_END) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Invalid pixeltype. Returning NULL");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_mapAlgebraExpr: Invalid pixeltype");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster");
PG_RETURN_NULL();
}
if (initexpr != NULL && strstr(initexpr, "[rast") == NULL) {
ret = SPI_connect();
if (ret != SPI_OK_CONNECT) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not connect to the SPI manager."
- " Aborting");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not connect to the SPI manager");
PG_RETURN_NULL();
};
ret = SPI_execute(initexpr, FALSE, 0);
if (ret != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Invalid construction for expression."
- " Aborting");
/* Free memory allocated out of the current context */
if (SPI_tuptable)
PG_FREE_IF_COPY(pgraster, 0);
SPI_finish();
+ elog(ERROR, "RASTER_mapAlgebraExpr: Invalid construction for expression");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster. "
- "Returning NULL");
-
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster. "
- "Returning NULL");
-
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not serialize raster");
PG_RETURN_NULL();
}
/* define values */
values = (Datum *) palloc(sizeof(Datum) * argcount);
if (values == NULL) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not allocate memory for value parameters of prepared statement");
SPI_finish();
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not allocate memory for value parameters of prepared statement");
PG_RETURN_NULL();
}
/* define nulls */
nulls = (char *)palloc(argcount);
if (nulls == NULL) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not allocate memory for null parameters of prepared statement");
SPI_finish();
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not allocate memory for null parameters of prepared statement");
PG_RETURN_NULL();
}
/* Connect to SPI and prepare the expression */
ret = SPI_connect();
if (ret != SPI_OK_CONNECT) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not connect to the SPI manager."
- " Aborting");
if (initexpr)
pfree(initexpr);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not connect to the SPI manager");
PG_RETURN_NULL();
};
spi_plan = SPI_prepare(initexpr, argcount, argtype);
if (spi_plan == NULL) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Could not prepare expression."
- " Aborting");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
pfree(initexpr);
+ elog(ERROR, "RASTER_mapAlgebraExpr: Could not prepare expression");
PG_RETURN_NULL();
}
}
ret = SPI_execute_plan(spi_plan, values, nulls, FALSE, 0);
if (ret != SPI_OK_SELECT || SPI_tuptable == NULL ||
SPI_processed != 1) {
- elog(ERROR, "RASTER_mapAlgebraExpr: Error executing prepared plan."
- " Aborting");
-
if (SPI_tuptable)
SPI_freetuptable(tuptable);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraExpr: Error executing prepared plan");
+
PG_RETURN_NULL();
}
/* Deserialize raster */
pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
raster = rt_raster_deserialize(pgraster, FALSE);
- if (NULL == raster)
- {
- elog(ERROR, "RASTER_mapAlgebraFct: Could not deserialize raster");
- PG_FREE_IF_COPY(pgraster, 0);
- PG_RETURN_NULL();
+ if (NULL == raster) {
+ PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_mapAlgebraFct: Could not deserialize raster");
+ PG_RETURN_NULL();
}
POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFct: Getting arguments...");
newrast = rt_raster_new(width, height);
if ( NULL == newrast ) {
- elog(ERROR, "RASTER_mapAlgebraFct: Could not create a new raster. "
- "Returning NULL");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_mapAlgebraFct: Could not create a new raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFct: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraFct: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFct: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraFct: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFct: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraFct: Could not serialize raster");
PG_RETURN_NULL();
}
}
if (newpixeltype == PT_END) {
- elog(ERROR, "RASTER_mapAlgebraFct: Invalid pixeltype. Returning NULL");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFct: Invalid pixeltype");
PG_RETURN_NULL();
}
/* Get the name of the callback user function for raster values */
if (PG_ARGISNULL(3)) {
- elog(ERROR, "RASTER_mapAlgebraFct: Required function is missing. Returning NULL");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFct: Required function is missing. Returning NULL");
PG_RETURN_NULL();
}
oid = PG_GETARG_OID(3);
if (oid == InvalidOid) {
- elog(ERROR, "RASTER_mapAlgebraFct: Got invalid function object id. Returning NULL");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFct: Got invalid function object id. Returning NULL");
PG_RETURN_NULL();
}
/* function cannot return set */
if (cbinfo.fn_retset) {
- elog(ERROR, "RASTER_mapAlgebraFct: Function provided must return double precision not resultset");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFct: Function provided must return double precision not resultset");
PG_RETURN_NULL();
}
/* function should have correct # of args */
else if (cbinfo.fn_nargs < 2 || cbinfo.fn_nargs > 3) {
- elog(ERROR, "RASTER_mapAlgebraFct: Function does not have two or three input parameters");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFct: Function does not have two or three input parameters");
PG_RETURN_NULL();
}
/* check that the function isn't strict if the args are null. */
if (PG_ARGISNULL(4)) {
if (cbinfo.fn_strict) {
- elog(ERROR, "RASTER_mapAlgebraFct: Strict callback functions cannot have null parameters");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFct: Strict callback functions cannot have null parameters");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFct: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraFct: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFct: Could not serialize raster. "
- "Returning NULL");
-
+ elog(ERROR, "RASTER_mapAlgebraFct: Could not serialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_band: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_band: Could not deserialize raster");
PG_RETURN_NULL();
}
case INT4OID:
break;
default:
- elog(ERROR, "RASTER_band: Invalid data type for band number(s)");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_band: Invalid data type for band number(s)");
PG_RETURN_NULL();
break;
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_summaryStats: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_summaryStats: Could not deserialize raster");
PG_RETURN_NULL();
}
/* connect to database */
spi_result = SPI_connect();
if (spi_result != SPI_OK_CONNECT) {
- elog(ERROR, "RASTER_summaryStatsCoverage: Could not connect to database using SPI\n");
pfree(sql);
+ elog(ERROR, "RASTER_summaryStatsCoverage: Could not connect to database using SPI");
PG_RETURN_NULL();
}
len = sizeof(char) * (strlen("SELECT \"\" FROM \"\" WHERE \"\" IS NOT NULL") + (strlen(colname) * 2) + strlen(tablename) + 1);
sql = (char *) palloc(len);
if (NULL == sql) {
- elog(ERROR, "RASTER_summaryStatsCoverage: Could not allocate memory for sql\n");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
+ elog(ERROR, "RASTER_summaryStatsCoverage: Could not allocate memory for sql");
PG_RETURN_NULL();
}
datum = SPI_getbinval(tuple, tupdesc, 1, &isNull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
- elog(ERROR, "RASTER_summaryStatsCoverage: Could not get raster of coverage\n");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_cursor_close(portal);
SPI_finish();
if (NULL != rtn) pfree(rtn);
+ elog(ERROR, "RASTER_summaryStatsCoverage: Could not get raster of coverage");
PG_RETURN_NULL();
}
else if (isNull) {
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_summaryStatsCoverage: Could not deserialize raster");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_cursor_close(portal);
SPI_finish();
if (NULL != rtn) pfree(rtn);
+ elog(ERROR, "RASTER_summaryStatsCoverage: Could not deserialize raster");
PG_RETURN_NULL();
}
if (NULL == rtn) {
rtn = (rt_bandstats) SPI_palloc(sizeof(struct rt_bandstats_t));
if (NULL == rtn) {
- elog(ERROR, "RASTER_summaryStatsCoverage: Could not allocate memory for summary stats of coverage\n");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_cursor_close(portal);
SPI_finish();
+ elog(ERROR, "RASTER_summaryStatsCoverage: Could not allocate memory for summary stats of coverage");
PG_RETURN_NULL();
}
SPI_finish();
if (NULL == rtn) {
- elog(ERROR, "RASTER_summaryStatsCoverage: Could not compute coverage summary stats\n");
+ elog(ERROR, "RASTER_summaryStatsCoverage: Could not compute coverage summary stats");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_histogram: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogram: Could not deserialize raster");
SRF_RETURN_DONE(funcctx);
}
case FLOAT8OID:
break;
default:
- elog(ERROR, "RASTER_histogram: Invalid data type for width");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogram: Invalid data type for width");
SRF_RETURN_DONE(funcctx);
break;
}
case FLOAT8OID:
break;
default:
- elog(ERROR, "RASTER_histogramCoverage: Invalid data type for width");
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogramCoverage: Invalid data type for width");
SRF_RETURN_DONE(funcctx);
break;
}
/* connect to database */
spi_result = SPI_connect();
if (spi_result != SPI_OK_CONNECT) {
- elog(ERROR, "RASTER_histogramCoverage: Could not connect to database using SPI\n");
if (bin_width_count) pfree(bin_width);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogramCoverage: Could not connect to database using SPI");
SRF_RETURN_DONE(funcctx);
}
len = sizeof(char) * (strlen("SELECT min, max FROM _st_summarystats('','',,::boolean,)") + strlen(tablename) + strlen(colname) + (MAX_INT_CHARLEN * 2) + MAX_DBL_CHARLEN + 1);
sql = (char *) palloc(len);
if (NULL == sql) {
- elog(ERROR, "RASTER_histogramCoverage: Could not allocate memory for sql\n");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
if (bin_width_count) pfree(bin_width);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogramCoverage: Could not allocate memory for sql");
SRF_RETURN_DONE(funcctx);
}
spi_result = SPI_execute(sql, TRUE, 0);
pfree(sql);
if (spi_result != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
- elog(ERROR, "RASTER_histogramCoverage: Could not get summary stats of coverage");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
if (bin_width_count) pfree(bin_width);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogramCoverage: Could not get summary stats of coverage");
SRF_RETURN_DONE(funcctx);
}
tmp = SPI_getvalue(tuple, tupdesc, 1);
if (NULL == tmp || !strlen(tmp)) {
- elog(ERROR, "RASTER_histogramCoverage: Could not get summary stats of coverage");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
if (bin_width_count) pfree(bin_width);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogramCoverage: Could not get summary stats of coverage");
SRF_RETURN_DONE(funcctx);
}
min = strtod(tmp, NULL);
tmp = SPI_getvalue(tuple, tupdesc, 2);
if (NULL == tmp || !strlen(tmp)) {
- elog(ERROR, "RASTER_histogramCoverage: Could not get summary stats of coverage");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
if (bin_width_count) pfree(bin_width);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogramCoverage: Could not get summary stats of coverage");
SRF_RETURN_DONE(funcctx);
}
max = strtod(tmp, NULL);
len = sizeof(char) * (strlen("SELECT \"\" FROM \"\" WHERE \"\" IS NOT NULL") + (strlen(colname) * 2) + strlen(tablename) + 1);
sql = (char *) palloc(len);
if (NULL == sql) {
- elog(ERROR, "RASTER_histogramCoverage: Could not allocate memory for sql\n");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
if (bin_width_count) pfree(bin_width);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogramCoverage: Could not allocate memory for sql");
SRF_RETURN_DONE(funcctx);
}
datum = SPI_getbinval(tuple, tupdesc, 1, &isNull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
- elog(ERROR, "RASTER_histogramCoverage: Could not get raster of coverage\n");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_cursor_close(portal);
if (bin_width_count) pfree(bin_width);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogramCoverage: Could not get raster of coverage");
SRF_RETURN_DONE(funcctx);
}
else if (isNull) {
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_histogramCoverage: Could not deserialize raster");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_cursor_close(portal);
if (bin_width_count) pfree(bin_width);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogramCoverage: Could not deserialize raster");
SRF_RETURN_DONE(funcctx);
}
if (NULL == covhist) {
covhist = (rt_histogram) SPI_palloc(sizeof(struct rt_histogram_t) * count);
if (NULL == covhist) {
- elog(ERROR, "RASTER_histogramCoverage: Could not allocate memory for histogram of coverage");
pfree(hist);
if (SPI_tuptable) SPI_freetuptable(tuptable);
if (bin_width_count) pfree(bin_width);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_histogramCoverage: Could not allocate memory for histogram of coverage");
SRF_RETURN_DONE(funcctx);
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_quantile: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_quantile: Could not deserialize raster");
SRF_RETURN_DONE(funcctx);
}
case FLOAT8OID:
break;
default:
- elog(ERROR, "RASTER_quantile: Invalid data type for quantiles");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_quantile: Invalid data type for quantiles");
SRF_RETURN_DONE(funcctx);
break;
}
case FLOAT8OID:
break;
default:
- elog(ERROR, "RASTER_quantileCoverage: Invalid data type for quantiles");
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_quantileCoverage: Invalid data type for quantiles");
SRF_RETURN_DONE(funcctx);
break;
}
/* connect to database */
spi_result = SPI_connect();
if (spi_result != SPI_OK_CONNECT) {
- elog(ERROR, "RASTER_quantileCoverage: Could not connect to database using SPI\n");
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_quantileCoverage: Could not connect to database using SPI");
SRF_RETURN_DONE(funcctx);
}
len = sizeof(char) * (strlen("SELECT count FROM _st_summarystats('','',,::boolean,)") + strlen(tablename) + strlen(colname) + (MAX_INT_CHARLEN * 2) + MAX_DBL_CHARLEN + 1);
sql = (char *) palloc(len);
if (NULL == sql) {
- elog(ERROR, "RASTER_quantileCoverage: Could not allocate memory for sql\n");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_quantileCoverage: Could not allocate memory for sql");
SRF_RETURN_DONE(funcctx);
}
spi_result = SPI_execute(sql, TRUE, 0);
pfree(sql);
if (spi_result != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
- elog(ERROR, "RASTER_quantileCoverage: Could not get summary stats of coverage");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_quantileCoverage: Could not get summary stats of coverage");
SRF_RETURN_DONE(funcctx);
}
tmp = SPI_getvalue(tuple, tupdesc, 1);
if (NULL == tmp || !strlen(tmp)) {
- elog(ERROR, "RASTER_quantileCoverage: Could not get summary stats of coverage");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_quantileCoverage: Could not get summary stats of coverage");
SRF_RETURN_DONE(funcctx);
}
cov_count = strtol(tmp, NULL, 10);
len = sizeof(char) * (strlen("SELECT \"\" FROM \"\" WHERE \"\" IS NOT NULL") + (strlen(colname) * 2) + strlen(tablename) + 1);
sql = (char *) palloc(len);
if (NULL == sql) {
- elog(ERROR, "RASTER_quantileCoverage: Could not allocate memory for sql\n");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_quantileCoverage: Could not allocate memory for sql");
SRF_RETURN_DONE(funcctx);
}
datum = SPI_getbinval(tuple, tupdesc, 1, &isNull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
- elog(ERROR, "RASTER_quantileCoverage: Could not get raster of coverage\n");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_cursor_close(portal);
SPI_finish();
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_quantileCoverage: Could not get raster of coverage");
SRF_RETURN_DONE(funcctx);
}
else if (isNull) {
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_quantileCoverage: Could not deserialize raster");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_cursor_close(portal);
SPI_finish();
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_quantileCoverage: Could not deserialize raster");
SRF_RETURN_DONE(funcctx);
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_valueCount: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_valueCount: Could not deserialize raster");
SRF_RETURN_DONE(funcctx);
}
case FLOAT8OID:
break;
default:
- elog(ERROR, "RASTER_valueCount: Invalid data type for values");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_valueCount: Invalid data type for values");
SRF_RETURN_DONE(funcctx);
break;
}
case FLOAT8OID:
break;
default:
- elog(ERROR, "RASTER_valueCountCoverage: Invalid data type for values");
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_valueCountCoverage: Invalid data type for values");
SRF_RETURN_DONE(funcctx);
break;
}
/* connect to database */
spi_result = SPI_connect();
if (spi_result != SPI_OK_CONNECT) {
- elog(ERROR, "RASTER_valueCountCoverage: Could not connect to database using SPI\n");
if (search_values_count) pfree(search_values);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_valueCountCoverage: Could not connect to database using SPI");
SRF_RETURN_DONE(funcctx);
}
len = sizeof(char) * (strlen("SELECT \"\" FROM \"\" WHERE \"\" IS NOT NULL") + (strlen(colname) * 2) + strlen(tablename) + 1);
sql = (char *) palloc(len);
if (NULL == sql) {
- elog(ERROR, "RASTER_valueCountCoverage: Could not allocate memory for sql\n");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_finish();
if (search_values_count) pfree(search_values);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_valueCountCoverage: Could not allocate memory for sql");
SRF_RETURN_DONE(funcctx);
}
datum = SPI_getbinval(tuple, tupdesc, 1, &isNull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
- elog(ERROR, "RASTER_valueCountCoverage: Could not get raster of coverage\n");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_cursor_close(portal);
if (search_values_count) pfree(search_values);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_valueCountCoverage: Could not get raster of coverage");
SRF_RETURN_DONE(funcctx);
}
else if (isNull) {
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_valueCountCoverage: Could not deserialize raster");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_cursor_close(portal);
if (search_values_count) pfree(search_values);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_valueCountCoverage: Could not deserialize raster");
SRF_RETURN_DONE(funcctx);
}
if (NULL == covvcnts) {
covvcnts = (rt_valuecount) SPI_palloc(sizeof(struct rt_valuecount_t) * count);
if (NULL == covvcnts) {
- elog(ERROR, "RASTER_valueCountCoverage: Could not allocate memory for value counts of coverage");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_cursor_close(portal);
if (search_values_count) pfree(search_values);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_valueCountCoverage: Could not allocate memory for value counts of coverage");
SRF_RETURN_DONE(funcctx);
}
covcount++;
covvcnts = SPI_repalloc(covvcnts, sizeof(struct rt_valuecount_t) * covcount);
if (NULL == covvcnts) {
- elog(ERROR, "RASTER_valueCountCoverage: Could not change allocated memory for value counts of coverage");
if (SPI_tuptable) SPI_freetuptable(tuptable);
SPI_cursor_close(portal);
if (NULL != covvcnts) free(covvcnts);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_valueCountCoverage: Could not change allocated memory for value counts of coverage");
SRF_RETURN_DONE(funcctx);
}
/* raster */
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_reclass: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_reclass: Could not deserialize raster");
PG_RETURN_NULL();
}
numBands = rt_raster_get_num_bands(raster);
) {
junk = palloc(sizeof(char) * (strlen(dash_set[c + 1]) + 2));
if (NULL == junk) {
- elog(ERROR, "RASTER_reclass: Insufficient memory. Returning NULL");
for (k = 0; k <= j; k++) pfree(exprset[k]);
pfree(exprset);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_reclass: Could not allocate memory");
PG_RETURN_NULL();
}
}
newband = rt_band_reclass(band, pixtype, hasnodata, nodataval, exprset, j);
if (!newband) {
- elog(ERROR, "RASTER_reclass: Could not reclassify raster band of index %d. Returning NULL", nband);
for (k = 0; k < j; k++) pfree(exprset[k]);
pfree(exprset);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_reclass: Could not reclassify raster band of index %d", nband);
PG_RETURN_NULL();
}
/* replace old band with new band */
if (rt_raster_replace_band(raster, newband, nband - 1) == NULL) {
- elog(ERROR, "RASTER_reclass: Could not replace raster band of index %d with reclassified band. Returning NULL", nband);
for (k = 0; k < j; k++) pfree(exprset[k]);
pfree(exprset);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_reclass: Could not replace raster band of index %d with reclassified band", nband);
PG_RETURN_NULL();
}
/* raster object */
arg->raster = rt_raster_deserialize(pgraster, FALSE);
if (!arg->raster) {
- elog(ERROR, "RASTER_colorMap: Could not deserialize raster");
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not deserialize raster");
PG_RETURN_NULL();
}
raster = rt_raster_clone(arg->raster, 0);
if (raster == NULL) {
- elog(ERROR, "RASTER_colorMap: Could not create empty raster");
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not create empty raster");
PG_RETURN_NULL();
}
/* get band */
arg->band = rt_raster_get_band(arg->raster, arg->nband - 1);
if (arg->band == NULL) {
- elog(ERROR, "RASTER_colorMap: Could not get band at index %d", arg->nband);
+ int nband = arg->nband;
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not get band at index %d", nband);
PG_RETURN_NULL();
}
/* colormap (2) */
if (PG_ARGISNULL(2)) {
- elog(ERROR, "RASTER_colorMap: Value must be provided for colormap");
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Value must be provided for colormap");
PG_RETURN_NULL();
}
else {
/* empty string */
if (!strlen(colormap)) {
- elog(ERROR, "RASTER_colorMap: Value must be provided for colormap");
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Value must be provided for colormap");
PG_RETURN_NULL();
}
arg->entry = rtpg_strsplit(colormap, "\n", &(arg->nentry));
pfree(colormap);
if (arg->nentry < 1) {
- elog(ERROR, "RASTER_colorMap: Could not process the value provided for colormap");
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not process the value provided for colormap");
PG_RETURN_NULL();
}
/* allocate the max # of colormap entries */
arg->colormap->entry = palloc(sizeof(struct rt_colormap_entry_t) * arg->nentry);
if (arg->colormap->entry == NULL) {
- elog(ERROR, "RASTER_colorMap: Could not allocate memory for colormap entries");
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not allocate memory for colormap entries");
PG_RETURN_NULL();
}
memset(arg->colormap->entry, 0, sizeof(struct rt_colormap_entry_t) * arg->nentry);
arg->element = rtpg_strsplit(_entry, " ", &(arg->nelement));
pfree(_entry);
if (arg->nelement < 2) {
- elog(ERROR, "RASTER_colorMap: Could not process colormap entry %d", i + 1);
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not process colormap entry %d", i + 1);
PG_RETURN_NULL();
}
else if (arg->nelement > 5) {
arg->bandstats = rt_band_get_summary_stats(arg->band, 1, 1, 0, NULL, NULL, NULL);
if (arg->bandstats == NULL) {
- elog(ERROR, "RASTER_colorMap: Could not get band's summary stats to process percentages");
pfree(_element);
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not get band's summary stats to process percentages");
PG_RETURN_NULL();
}
}
/* get the string before the percent char */
tmp = palloc(sizeof(char) * (percent - _element + 1));
if (tmp == NULL) {
- elog(ERROR, "RASTER_colorMap: Could not allocate memory for value of percentage");
pfree(_element);
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not allocate memory for value of percentage");
PG_RETURN_NULL();
}
value = strtod(tmp, NULL);
pfree(tmp);
if (errno != 0 || _element == junk) {
- elog(ERROR, "RASTER_colorMap: Could not process percent string to value");
pfree(_element);
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not process percent string to value");
PG_RETURN_NULL();
}
errno = 0;
arg->colormap->entry[arg->colormap->nentry].value = strtod(_element, &junk);
if (errno != 0 || _element == junk) {
- elog(ERROR, "RASTER_colorMap: Could not process string to value");
pfree(_element);
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not process string to value");
PG_RETURN_NULL();
}
}
errno = 0;
value = (int) strtod(_element, &junk);
if (errno != 0 || _element == junk) {
- elog(ERROR, "RASTER_colorMap: Could not process string to value");
pfree(_element);
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not process string to value");
PG_RETURN_NULL();
}
/* call colormap */
raster = rt_raster_colormap(arg->raster, arg->nband - 1, arg->colormap);
if (raster == NULL) {
- elog(ERROR, "RASTER_colorMap: Could not create new raster with applied colormap");
rtpg_colormap_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_colorMap: Could not create new raster with applied colormap");
PG_RETURN_NULL();
}
/* create memory "file" */
vsifp = VSIFileFromMemBuffer("/vsimem/in.dat", data, data_len, FALSE);
if (vsifp == NULL) {
- elog(ERROR, "RASTER_fromGDALRaster: Could not load bytea into memory file for use by GDAL");
PG_FREE_IF_COPY(bytea_data, 0);
+ elog(ERROR, "RASTER_fromGDALRaster: Could not load bytea into memory file for use by GDAL");
PG_RETURN_NULL();
}
/* open GDAL raster */
hdsSrc = GDALOpenShared("/vsimem/in.dat", GA_ReadOnly);
if (hdsSrc == NULL) {
- elog(ERROR, "RASTER_fromGDALRaster: Could not open bytea with GDAL. Check that the bytea is of a GDAL supported format");
VSIFCloseL(vsifp);
PG_FREE_IF_COPY(bytea_data, 0);
+ elog(ERROR, "RASTER_fromGDALRaster: Could not open bytea with GDAL. Check that the bytea is of a GDAL supported format");
PG_RETURN_NULL();
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_asGDALRaster: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_asGDALRaster: Could not deserialize raster");
PG_RETURN_NULL();
}
case TEXTOID:
break;
default:
- elog(ERROR, "RASTER_asGDALRaster: Invalid data type for options");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_asGDALRaster: Invalid data type for options");
PG_RETURN_NULL();
break;
}
if (n) {
options = (char **) palloc(sizeof(char *) * (n + 1));
if (options == NULL) {
- elog(ERROR, "RASTER_asGDALRaster: Could not allocate memory for options");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_asGDALRaster: Could not allocate memory for options");
PG_RETURN_NULL();
}
if (clamp_srid(srid) != SRID_UNKNOWN) {
srs = rtpg_getSR(srid);
if (NULL == srs) {
- elog(ERROR, "RASTER_asGDALRaster: Could not find srtext for SRID (%d)", srid);
if (NULL != options) {
for (i = j - 1; i >= 0; i--) pfree(options[i]);
pfree(options);
}
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_asGDALRaster: Could not find srtext for SRID (%d)", srid);
PG_RETURN_NULL();
}
POSTGIS_RT_DEBUGF(3, "RASTER_asGDALRaster: Arg 3 (srs) is %s", srs);
case TEXTOID:
break;
default:
- elog(ERROR, "RASTER_asRaster: Invalid data type for pixeltype");
lwgeom_free(geom);
PG_FREE_IF_COPY(gser, 0);
+ elog(ERROR, "RASTER_asRaster: Invalid data type for pixeltype");
PG_RETURN_NULL();
break;
}
if (strlen(pixeltype)) {
pixtype = rt_pixtype_index_from_name(pixeltype);
if (pixtype == PT_END) {
- elog(ERROR, "RASTER_asRaster: Invalid pixel type provided: %s", pixeltype);
pfree(pixtypes);
lwgeom_free(geom);
PG_FREE_IF_COPY(gser, 0);
+ elog(ERROR, "RASTER_asRaster: Invalid pixel type provided: %s", pixeltype);
PG_RETURN_NULL();
}
case FLOAT8OID:
break;
default:
- elog(ERROR, "RASTER_asRaster: Invalid data type for value");
if (pixtypes_len) pfree(pixtypes);
lwgeom_free(geom);
PG_FREE_IF_COPY(gser, 0);
+ elog(ERROR, "RASTER_asRaster: Invalid data type for value");
PG_RETURN_NULL();
break;
}
case FLOAT8OID:
break;
default:
- elog(ERROR, "RASTER_asRaster: Invalid data type for nodataval");
if (pixtypes_len) pfree(pixtypes);
if (values_len) pfree(values);
lwgeom_free(geom);
PG_FREE_IF_COPY(gser, 0);
+ elog(ERROR, "RASTER_asRaster: Invalid data type for nodataval");
PG_RETURN_NULL();
break;
}
if (clamp_srid(srid) != SRID_UNKNOWN) {
srs = rtpg_getSR(srid);
if (NULL == srs) {
- elog(ERROR, "RASTER_asRaster: Could not find srtext for SRID (%d)", srid);
if (pixtypes_len) pfree(pixtypes);
if (values_len) pfree(values);
lwgeom_free(geom);
PG_FREE_IF_COPY(gser, 0);
+ elog(ERROR, "RASTER_asRaster: Could not find srtext for SRID (%d)", srid);
PG_RETURN_NULL();
}
POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: srs is %s", srs);
/* raster */
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_GDALWarp: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_GDALWarp: Could not deserialize raster");
PG_RETURN_NULL();
}
if (!PG_ARGISNULL(3)) {
dst_srid = clamp_srid(PG_GETARG_INT32(3));
if (dst_srid == SRID_UNKNOWN) {
- elog(ERROR, "RASTER_GDALWarp: %d is an invalid target SRID", dst_srid);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_GDALWarp: %d is an invalid target SRID", dst_srid);
PG_RETURN_NULL();
}
}
/* target SRID != src SRID, error */
if (src_srid == SRID_UNKNOWN && dst_srid != src_srid) {
- elog(ERROR, "RASTER_GDALWarp: Input raster has unknown (%d) SRID", src_srid);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_GDALWarp: Input raster has unknown (%d) SRID", src_srid);
PG_RETURN_NULL();
}
/* target SRID == src SRID, no reprojection */
/* source srs */
src_srs = rtpg_getSR(src_srid);
if (NULL == src_srs) {
- elog(ERROR, "RASTER_GDALWarp: Input raster has unknown SRID (%d)", src_srid);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_GDALWarp: Input raster has unknown SRID (%d)", src_srid);
PG_RETURN_NULL();
}
POSTGIS_RT_DEBUGF(4, "src srs: %s", src_srs);
dst_srs = rtpg_getSR(dst_srid);
if (NULL == dst_srs) {
- elog(ERROR, "RASTER_GDALWarp: Target SRID (%d) is unknown", dst_srid);
if (!no_srid) pfree(src_srs);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_GDALWarp: Target SRID (%d) is unknown", dst_srid);
PG_RETURN_NULL();
}
POSTGIS_RT_DEBUGF(4, "dst srs: %s", dst_srs);
/* raster */
raster = rt_raster_deserialize(pgraster, TRUE);
if (!raster) {
- elog(ERROR, "RASTER_metadata; Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_metadata; Could not deserialize raster");
PG_RETURN_NULL();
}
/* raster */
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- elog(ERROR, "RASTER_bandmetadata: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_bandmetadata: Could not deserialize raster");
SRF_RETURN_DONE(funcctx);
}
case INT4OID:
break;
default:
- elog(ERROR, "RASTER_bandmetadata: Invalid data type for band number(s)");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_bandmetadata: Invalid data type for band number(s)");
SRF_RETURN_DONE(funcctx);
break;
}
/* raster */
raster = rt_raster_deserialize(pgraster, TRUE);
if (!raster) {
- elog(ERROR, "RASTER_rasterToWorldCoord: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_rasterToWorldCoord: Could not deserialize raster");
PG_RETURN_NULL();
}
&(cw[0]), &(cw[1]),
NULL
) != ES_NONE) {
- elog(ERROR, "RASTER_rasterToWorldCoord: Could not compute longitude and latitude from pixel row and column");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_rasterToWorldCoord: Could not compute longitude and latitude from pixel row and column");
PG_RETURN_NULL();
}
rt_raster_destroy(raster);
/* raster */
raster = rt_raster_deserialize(pgraster, TRUE);
if (!raster) {
- elog(ERROR, "RASTER_worldToRasterCoord: Could not deserialize raster");
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_worldToRasterCoord: Could not deserialize raster");
PG_RETURN_NULL();
}
&(_cr[0]), &(_cr[1]),
NULL
) != ES_NONE) {
- elog(ERROR, "RASTER_worldToRasterCoord: Could not compute pixel row and column from longitude and latitude");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_worldToRasterCoord: Could not compute pixel row and column from longitude and latitude");
PG_RETURN_NULL();
}
rt_raster_destroy(raster);
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], FALSE);
if (!rast[i]) {
- elog(ERROR, "RASTER_intersects: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i)
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_intersects: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
/* SRID must match */
if (rt_raster_get_srid(rast[0]) != rt_raster_get_srid(rast[1])) {
- elog(ERROR, "The two rasters provided have different SRIDs");
for (k = 0; k < set_count; k++) {
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "The two rasters provided have different SRIDs");
PG_RETURN_NULL();
}
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], FALSE);
if (!rast[i]) {
- elog(ERROR, "RASTER_overlaps: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i)
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_overlaps: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
/* SRID must match */
if (rt_raster_get_srid(rast[0]) != rt_raster_get_srid(rast[1])) {
- elog(ERROR, "The two rasters provided have different SRIDs");
for (k = 0; k < set_count; k++) {
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "The two rasters provided have different SRIDs");
PG_RETURN_NULL();
}
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], FALSE);
if (!rast[i]) {
- elog(ERROR, "RASTER_touches: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i)
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_touches: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
/* SRID must match */
if (rt_raster_get_srid(rast[0]) != rt_raster_get_srid(rast[1])) {
- elog(ERROR, "The two rasters provided have different SRIDs");
for (k = 0; k < set_count; k++) {
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "The two rasters provided have different SRIDs");
PG_RETURN_NULL();
}
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], FALSE);
if (!rast[i]) {
- elog(ERROR, "RASTER_contains: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i)
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_contains: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
/* SRID must match */
if (rt_raster_get_srid(rast[0]) != rt_raster_get_srid(rast[1])) {
- elog(ERROR, "The two rasters provided have different SRIDs");
for (k = 0; k < set_count; k++) {
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "The two rasters provided have different SRIDs");
PG_RETURN_NULL();
}
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], FALSE);
if (!rast[i]) {
- elog(ERROR, "RASTER_containsProperly: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i)
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_containsProperly: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
/* SRID must match */
if (rt_raster_get_srid(rast[0]) != rt_raster_get_srid(rast[1])) {
- elog(ERROR, "The two rasters provided have different SRIDs");
for (k = 0; k < set_count; k++) {
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "The two rasters provided have different SRIDs");
PG_RETURN_NULL();
}
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], FALSE);
if (!rast[i]) {
- elog(ERROR, "RASTER_covers: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i)
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_covers: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
/* SRID must match */
if (rt_raster_get_srid(rast[0]) != rt_raster_get_srid(rast[1])) {
- elog(ERROR, "The two rasters provided have different SRIDs");
for (k = 0; k < set_count; k++) {
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "The two rasters provided have different SRIDs");
PG_RETURN_NULL();
}
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], FALSE);
if (!rast[i]) {
- elog(ERROR, "RASTER_coveredby: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i)
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_coveredby: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
/* SRID must match */
if (rt_raster_get_srid(rast[0]) != rt_raster_get_srid(rast[1])) {
- elog(ERROR, "The two rasters provided have different SRIDs");
for (k = 0; k < set_count; k++) {
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "The two rasters provided have different SRIDs");
PG_RETURN_NULL();
}
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], FALSE);
if (!rast[i]) {
- elog(ERROR, "RASTER_dwithin: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i)
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_dwithin: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
/* SRID must match */
if (rt_raster_get_srid(rast[0]) != rt_raster_get_srid(rast[1])) {
- elog(ERROR, "The two rasters provided have different SRIDs");
for (k = 0; k < set_count; k++) {
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "The two rasters provided have different SRIDs");
PG_RETURN_NULL();
}
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], FALSE);
if (!rast[i]) {
- elog(ERROR, "RASTER_dfullywithin: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i)
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_dfullywithin: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
/* SRID must match */
if (rt_raster_get_srid(rast[0]) != rt_raster_get_srid(rast[1])) {
- elog(ERROR, "The two rasters provided have different SRIDs");
for (k = 0; k < set_count; k++) {
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "The two rasters provided have different SRIDs");
PG_RETURN_NULL();
}
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], TRUE);
if (!rast[i]) {
- elog(ERROR, "RASTER_sameAlignment: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i)
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_sameAlignment: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
}
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], TRUE);
if (!rast[i]) {
- elog(ERROR, "RASTER_notSameAlignmentReason: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i)
rt_raster_destroy(rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_notSameAlignmentReason: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
}
/* raster */
rast[i] = rt_raster_deserialize(pgrast[i], FALSE);
if (!rast[i]) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not deserialize the %s raster", i < 1 ? "first" : "second");
for (k = 0; k <= i; k++) {
if (k < i && rast[k] != NULL)
rt_raster_destroy(rast[k]);
if (pgrastpos[k] != -1)
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_mapAlgebra2: Could not deserialize the %s raster", i < 1 ? "first" : "second");
PG_RETURN_NULL();
}
raster = rt_raster_new(0, 0);
if (raster == NULL) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not create empty raster");
for (k = 0; k < set_count; k++) {
if (rast[k] != NULL)
rt_raster_destroy(rast[k]);
if (pgrastpos[k] != -1)
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_mapAlgebra2: Could not create empty raster");
PG_RETURN_NULL();
}
rt_raster_set_scale(raster, 0, 0);
_dim[j][1]
);
if (_rast[i] == NULL) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not create nodata raster");
rt_raster_destroy(_rast[j]);
for (k = 0; k < set_count; k++) {
if (pgrastpos[k] != -1)
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_mapAlgebra2: Could not create NODATA raster");
PG_RETURN_NULL();
}
rt_raster_set_srid(_rast[i], rt_raster_get_srid(_rast[j]));
/* same alignment */
if (rt_raster_same_alignment(_rast[0], _rast[1], &aligned, NULL) != ES_NONE) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not test for alignment on the two rasters");
for (k = 0; k < set_count; k++) {
if (_rast[k] != NULL)
rt_raster_destroy(_rast[k]);
if (pgrastpos[k] != -1)
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_mapAlgebra2: Could not test for alignment on the two rasters");
PG_RETURN_NULL();
}
if (!aligned) {
/* Get the pixel type index */
pixtype = rt_pixtype_index_from_name(pixtypename);
if (pixtype == PT_END ) {
- elog(ERROR, "RASTER_mapAlgebra2: Invalid pixel type: %s", pixtypename);
for (k = 0; k < set_count; k++) {
if (_rast[k] != NULL)
rt_raster_destroy(_rast[k]);
if (pgrastpos[k] != -1)
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_mapAlgebra2: Invalid pixel type: %s", pixtypename);
PG_RETURN_NULL();
}
}
&raster, _offset
);
if (err != ES_NONE) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not get output raster of correct extent");
for (k = 0; k < set_count; k++) {
if (_rast[k] != NULL)
rt_raster_destroy(_rast[k]);
if (pgrastpos[k] != -1)
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_mapAlgebra2: Could not get output raster of correct extent");
PG_RETURN_NULL();
}
raster = rt_raster_new(0, 0);
if (raster == NULL) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not create no band raster");
for (k = 0; k < set_count; k++) {
if (_rast[k] != NULL)
rt_raster_destroy(_rast[k]);
if (pgrastpos[k] != -1)
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_mapAlgebra2: Could not create no band raster");
PG_RETURN_NULL();
}
break;
case ET_LAST:
case ET_CUSTOM:
- elog(ERROR, "RASTER_mapAlgebra2: ET_LAST and ET_CUSTOM are not implemented");
for (k = 0; k < set_count; k++) {
if (_rast[k] != NULL)
rt_raster_destroy(_rast[k]);
if (pgrastpos[k] != -1)
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
+ elog(ERROR, "RASTER_mapAlgebra2: ET_LAST and ET_CUSTOM are not implemented");
PG_RETURN_NULL();
break;
}
_band[i] = rt_raster_get_band(_rast[i], bandindex[i] - 1);
if (_band[i] == NULL) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not get band %d of the %s raster",
- bandindex[i],
- (i < 1 ? "FIRST" : "SECOND")
- );
for (k = 0; k < set_count; k++) {
if (_rast[k] != NULL)
rt_raster_destroy(_rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not get band %d of the %s raster",
+ bandindex[i],
+ (i < 1 ? "FIRST" : "SECOND")
+ );
PG_RETURN_NULL();
}
1, nodataval,
0
) < 0) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not add new band to output raster");
for (k = 0; k < set_count; k++) {
if (_rast[k] != NULL)
rt_raster_destroy(_rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not add new band to output raster");
PG_RETURN_NULL();
}
/* get output band */
band = rt_raster_get_band(raster, 0);
if (band == NULL) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not get newly added band of output raster");
for (k = 0; k < set_count; k++) {
if (_rast[k] != NULL)
rt_raster_destroy(_rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not get newly added band of output raster");
PG_RETURN_NULL();
}
/* connect SPI */
if (SPI_connect() != SPI_OK_CONNECT) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not connect to the SPI manager");
for (k = 0; k < set_count; k++) {
if (_rast[k] != NULL)
rt_raster_destroy(_rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not connect to the SPI manager");
PG_RETURN_NULL();
}
len = strlen("SELECT (") + strlen(expr) + strlen(")::double precision");
sql = (char *) palloc(len + 1);
if (sql == NULL) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not allocate memory for expression parameter %d", spi_exprpos[i]);
for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
SPI_finish();
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not allocate memory for expression parameter %d", spi_exprpos[i]);
PG_RETURN_NULL();
}
if (spi_argcount[i]) {
argtype = (Oid *) palloc(spi_argcount[i] * sizeof(Oid));
if (argtype == NULL) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not allocate memory for prepared plan argtypes of expression parameter %d", spi_exprpos[i]);
pfree(sql);
for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not allocate memory for prepared plan argtypes of expression parameter %d", spi_exprpos[i]);
PG_RETURN_NULL();
}
pfree(argtype);
if (spi_plan[i] == NULL) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not create prepared plan of expression parameter %d", spi_exprpos[i]);
pfree(sql);
for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not create prepared plan of expression parameter %d", spi_exprpos[i]);
PG_RETURN_NULL();
}
}
else {
err = SPI_execute(sql, TRUE, 0);
if (err != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not evaluate expression parameter %d", spi_exprpos[i]);
pfree(sql);
for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not evaluate expression parameter %d", spi_exprpos[i]);
PG_RETURN_NULL();
}
datum = SPI_getbinval(tuple, tupdesc, 1, &isnull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not get result of expression parameter %d", spi_exprpos[i]);
pfree(sql);
if (SPI_tuptable) SPI_freetuptable(tuptable);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not get result of expression parameter %d", spi_exprpos[i]);
PG_RETURN_NULL();
}
case REGPROCEDUREOID: {
POSTGIS_RT_DEBUG(3, "arg 4 is \"userfunction\"!");
if (!PG_ARGISNULL(4)) {
+
ufc_nullcount = 0;
ufc_noid = PG_GETARG_OID(4);
/* function cannot return set */
err = 0;
if (ufl_info.fn_retset) {
- elog(ERROR, "RASTER_mapAlgebra2: Function provided must return double precision not resultset");
err = 1;
}
/* function should have correct # of args */
else if (ufl_info.fn_nargs < 3 || ufl_info.fn_nargs > 4) {
- elog(ERROR, "RASTER_mapAlgebra2: Function provided must have three or four input parameters");
- err = 1;
+ err = 2;
}
/*
should be able to use get_fn_expr_argtype() of fmgr.c
*/
- if (err) {
+ if (err > 0) {
for (k = 0; k < set_count; k++) {
if (_rast[k] != NULL)
rt_raster_destroy(_rast[k]);
}
rt_raster_destroy(raster);
+ if (err > 1)
+ elog(ERROR, "RASTER_mapAlgebra2: Function provided must have three or four input parameters");
+ else
+ elog(ERROR, "RASTER_mapAlgebra2: Function provided must return double precision not resultset");
PG_RETURN_NULL();
}
break;
}
default:
- elog(ERROR, "RASTER_mapAlgebra2: Invalid data type for expression or userfunction");
for (k = 0; k < set_count; k++) {
if (_rast[k] != NULL)
rt_raster_destroy(_rast[k]);
PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Invalid data type for expression or userfunction");
PG_RETURN_NULL();
break;
}
) {
err = rt_band_get_pixel(_band[i], _x, _y, &(_pixel[i]), &isnodata);
if (err != ES_NONE) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not get pixel of %s raster", (i < 1 ? "FIRST" : "SECOND"));
if (calltype == TEXTOID) {
for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not get pixel of %s raster", (i < 1 ? "FIRST" : "SECOND"));
PG_RETURN_NULL();
}
/* run prepared plan */
err = SPI_execute_plan(spi_plan[i], values, nulls, TRUE, 1);
if (err != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
- elog(ERROR, "RASTER_mapAlgebra2: Unexpected error when running prepared statement %d", i);
for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
SPI_finish();
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Unexpected error when running prepared statement %d", i);
PG_RETURN_NULL();
}
datum = SPI_getbinval(tuple, tupdesc, 1, &isnull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not get result of prepared statement %d", i);
if (SPI_tuptable) SPI_freetuptable(tuptable);
for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not get result of prepared statement %d", i);
PG_RETURN_NULL();
}
/* burn pixel if haspixel != 0 */
if (haspixel) {
if (rt_band_set_pixel(band, x, y, pixel, NULL) != ES_NONE) {
- elog(ERROR, "RASTER_mapAlgebra2: Could not set pixel value of output raster");
if (calltype == TEXTOID) {
for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
}
rt_raster_destroy(raster);
+ elog(ERROR, "RASTER_mapAlgebra2: Could not set pixel value of output raster");
PG_RETURN_NULL();
}
}
raster = rt_raster_deserialize(pgraster, FALSE);
if (NULL == raster)
{
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not deserialize raster");
- PG_FREE_IF_COPY(pgraster, 0);
- PG_RETURN_NULL();
+ PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not deserialize raster");
+ PG_RETURN_NULL();
}
POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Getting arguments...");
newrast = rt_raster_new(width, height);
if ( NULL == newrast ) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not create a new raster. "
- "Returning NULL");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not create a new raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
PG_RETURN_NULL();
}
}
if (newpixeltype == PT_END) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Invalid pixeltype. Returning NULL");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Invalid pixeltype");
PG_RETURN_NULL();
}
/* Get the name of the callback userfunction */
if (PG_ARGISNULL(5)) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Required function is missing. Returning NULL");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Required function is missing");
PG_RETURN_NULL();
}
oid = PG_GETARG_OID(5);
if (oid == InvalidOid) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Got invalid function object id. Returning NULL");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Got invalid function object id");
PG_RETURN_NULL();
}
/* function cannot return set */
if (cbinfo.fn_retset) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Function provided must return double precision not resultset. Returning NULL");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Function provided must return double precision not resultset");
PG_RETURN_NULL();
}
/* function should have correct # of args */
else if (cbinfo.fn_nargs != 3) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Function does not have three input parameters. Returning NULL");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Function does not have three input parameters");
PG_RETURN_NULL();
}
/* check that the function isn't strict if the args are null. */
if (PG_ARGISNULL(7)) {
if (cbinfo.fn_strict) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Strict callback functions cannot have null parameters. Returning NULL");
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
rt_raster_destroy(newrast);
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Strict callback functions cannot have NULL parameters");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster. "
- "Returning NULL");
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster. "
- "Returning NULL");
-
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster. "
- "Returning NULL");
-
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster. "
- "Returning NULL");
-
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
PG_RETURN_NULL();
}
pgrtn = rt_raster_serialize(newrast);
rt_raster_destroy(newrast);
if (NULL == pgrtn) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster. "
- "Returning NULL");
-
+ elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
PG_RETURN_NULL();
}
arg = palloc(sizeof(struct rtpg_nmapalgebra_arg_t));
if (arg == NULL) {
elog(ERROR, "rtpg_nmapalgebra_arg_init: Could not allocate memory for arguments");
- return 0;
+ return NULL;
}
arg->numraster = 0;
_pos = palloc(sizeof(Datum) * (arg->rasters + 1) * 2);
_null = palloc(sizeof(bool) * (arg->rasters + 1) * 2);
if (_pos == NULL || _null == NULL) {
- elog(ERROR, "rtpg_nmapalgebra_callback: Could not allocate memory for position array");
pfree(mdValues);
+ elog(ERROR, "rtpg_nmapalgebra_callback: Could not allocate memory for position array");
return 0;
}
memset(_null, 0, sizeof(bool) * (arg->rasters + 1) * 2);
/* let helper function process rastbandarg (0) */
if (!rtpg_nmapalgebra_rastbandarg_process(arg, PG_GETARG_ARRAYTYPE_P(0), &allnull, &allempty, &noband)) {
- elog(ERROR, "RASTER_nMapAlgebra: Could not process rastbandarg");
rtpg_nmapalgebra_arg_destroy(arg);
+ elog(ERROR, "RASTER_nMapAlgebra: Could not process rastbandarg");
PG_RETURN_NULL();
}
/* Get the pixel type index */
arg->pixtype = rt_pixtype_index_from_name(pixtypename);
if (arg->pixtype == PT_END) {
- elog(ERROR, "RASTER_nMapAlgebra: Invalid pixel type: %s", pixtypename);
rtpg_nmapalgebra_arg_destroy(arg);
+ elog(ERROR, "RASTER_nMapAlgebra: Invalid pixel type: %s", pixtypename);
PG_RETURN_NULL();
}
}
arg->distance[1] = PG_GETARG_INT32(4);
if (arg->distance[0] < 0 || arg->distance[1] < 0) {
- elog(ERROR, "RASTER_nMapAlgebra: Distance for X and Y axis must be greater than or equal to zero");
rtpg_nmapalgebra_arg_destroy(arg);
+ elog(ERROR, "RASTER_nMapAlgebra: Distance for X and Y axis must be greater than or equal to zero");
PG_RETURN_NULL();
}
/* only need the raster header */
arg->cextent = rt_raster_deserialize(arg->pgcextent, TRUE);
if (arg->cextent == NULL) {
- elog(ERROR, "RASTER_nMapAlgebra: Could not deserialize custom extent");
rtpg_nmapalgebra_arg_destroy(arg);
+ elog(ERROR, "RASTER_nMapAlgebra: Could not deserialize custom extent");
PG_RETURN_NULL();
}
else if (rt_raster_is_empty(arg->cextent)) {
- elog(ERROR, "RASTER_nMapAlgebra: Custom extent is an empty raster. Returning empty raster");
+ elog(NOTICE, "Custom extent is an empty raster. Returning empty raster");
rtpg_nmapalgebra_arg_destroy(arg);
raster = rt_raster_new(0, 0);
fmgr_info(arg->callback.ufc_noid, &(arg->callback.ufl_info));
/* function cannot return set */
- noerr = 1;
+ noerr = 0;
if (arg->callback.ufl_info.fn_retset) {
- elog(ERROR, "RASTER_nMapAlgebra: Function provided must return double precision, not resultset");
- noerr = 0;
+ noerr = 1;
}
/* function should have correct # of args */
else if (arg->callback.ufl_info.fn_nargs != 3) {
- elog(ERROR, "RASTER_nMapAlgebra: Function provided must have three input parameters");
- noerr = 0;
+ noerr = 2;
}
/*
should be able to use get_fn_expr_argtype() of fmgr.c
*/
- if (!noerr) {
+ if (noerr > 0) {
rtpg_nmapalgebra_arg_destroy(arg);
+ if (noerr > 1)
+ elog(ERROR, "RASTER_nMapAlgebra: Function provided must have three input parameters");
+ else
+ elog(ERROR, "RASTER_nMapAlgebra: Function provided must return double precision, not resultset");
PG_RETURN_NULL();
}
}
}
else {
- elog(ERROR, "RASTER_nMapAlgebra: callbackfunc must be provided");
rtpg_nmapalgebra_arg_destroy(arg);
+ elog(ERROR, "RASTER_nMapAlgebra: callbackfunc must be provided");
PG_RETURN_NULL();
}
/* init itrset */
itrset = palloc(sizeof(struct rt_iterator_t) * arg->numraster);
if (itrset == NULL) {
- elog(ERROR, "RASTER_nMapAlgebra: Could not allocate memory for iterator arguments");
rtpg_nmapalgebra_arg_destroy(arg);
+ elog(ERROR, "RASTER_nMapAlgebra: Could not allocate memory for iterator arguments");
PG_RETURN_NULL();
}
datum = SPI_getbinval(tuple, tupdesc, 1, &isnull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
- elog(ERROR, "rtpg_nmapalgebraexpr_callback: Could not get result of prepared statement %d", id);
if (SPI_tuptable) SPI_freetuptable(tuptable);
+ elog(ERROR, "rtpg_nmapalgebraexpr_callback: Could not get result of prepared statement %d", id);
return 0;
}
/* let helper function process rastbandarg (0) */
if (!rtpg_nmapalgebra_rastbandarg_process(arg->bandarg, PG_GETARG_ARRAYTYPE_P(0), &allnull, &allempty, &noband)) {
- elog(ERROR, "RASTER_nMapAlgebra: Could not process rastbandarg");
rtpg_nmapalgebraexpr_arg_destroy(arg);
+ elog(ERROR, "RASTER_nMapAlgebra: Could not process rastbandarg");
PG_RETURN_NULL();
}
/* Get the pixel type index */
arg->bandarg->pixtype = rt_pixtype_index_from_name(pixtypename);
if (arg->bandarg->pixtype == PT_END) {
- elog(ERROR, "RASTER_nMapAlgebraExpr: Invalid pixel type: %s", pixtypename);
rtpg_nmapalgebraexpr_arg_destroy(arg);
+ elog(ERROR, "RASTER_nMapAlgebraExpr: Invalid pixel type: %s", pixtypename);
PG_RETURN_NULL();
}
}
/* connect SPI */
if (SPI_connect() != SPI_OK_CONNECT) {
- elog(ERROR, "RASTER_nMapAlgebraExpr: Could not connect to the SPI manager");
rtpg_nmapalgebraexpr_arg_destroy(arg);
+ elog(ERROR, "RASTER_nMapAlgebraExpr: Could not connect to the SPI manager");
PG_RETURN_NULL();
}
len = strlen("SELECT (") + strlen(expr) + strlen(")::double precision");
sql = (char *) palloc(len + 1);
if (sql == NULL) {
- elog(ERROR, "RASTER_nMapAlgebraExpr: Could not allocate memory for expression parameter %d", exprpos[i]);
rtpg_nmapalgebraexpr_arg_destroy(arg);
SPI_finish();
+ elog(ERROR, "RASTER_nMapAlgebraExpr: Could not allocate memory for expression parameter %d", exprpos[i]);
PG_RETURN_NULL();
}
Oid *argtype = (Oid *) palloc(arg->callback.expr[i].spi_argcount * sizeof(Oid));
POSTGIS_RT_DEBUGF(3, "expression parameter %d is a prepared plan", exprpos[i]);
if (argtype == NULL) {
- elog(ERROR, "RASTER_nMapAlgebraExpr: Could not allocate memory for prepared plan argtypes of expression parameter %d", exprpos[i]);
pfree(sql);
rtpg_nmapalgebraexpr_arg_destroy(arg);
SPI_finish();
+ elog(ERROR, "RASTER_nMapAlgebraExpr: Could not allocate memory for prepared plan argtypes of expression parameter %d", exprpos[i]);
PG_RETURN_NULL();
}
pfree(sql);
if (arg->callback.expr[i].spi_plan == NULL) {
- elog(ERROR, "RASTER_nMapAlgebraExpr: Could not create prepared plan of expression parameter %d", exprpos[i]);
rtpg_nmapalgebraexpr_arg_destroy(arg);
SPI_finish();
+ elog(ERROR, "RASTER_nMapAlgebraExpr: Could not create prepared plan of expression parameter %d", exprpos[i]);
PG_RETURN_NULL();
}
}
pfree(sql);
if (err != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
- elog(ERROR, "RASTER_nMapAlgebraExpr: Could not evaluate expression parameter %d", exprpos[i]);
rtpg_nmapalgebraexpr_arg_destroy(arg);
SPI_finish();
+ elog(ERROR, "RASTER_nMapAlgebraExpr: Could not evaluate expression parameter %d", exprpos[i]);
PG_RETURN_NULL();
}
datum = SPI_getbinval(tuple, tupdesc, 1, &isnull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
- elog(ERROR, "RASTER_nMapAlgebraExpr: Could not get result of expression parameter %d", exprpos[i]);
if (SPI_tuptable) SPI_freetuptable(tuptable);
rtpg_nmapalgebraexpr_arg_destroy(arg);
SPI_finish();
+ elog(ERROR, "RASTER_nMapAlgebraExpr: Could not get result of expression parameter %d", exprpos[i]);
PG_RETURN_NULL();
}
/* init itrset */
itrset = palloc(sizeof(struct rt_iterator_t) * numraster);
if (itrset == NULL) {
- elog(ERROR, "RASTER_nMapAlgebra: Could not allocate memory for iterator arguments");
rtpg_nmapalgebraexpr_arg_destroy(arg);
SPI_finish();
+ elog(ERROR, "RASTER_nMapAlgebra: Could not allocate memory for iterator arguments");
PG_RETURN_NULL();
}
rtpg_nmapalgebraexpr_arg_destroy(arg);
if (err != ES_NONE) {
- elog(ERROR, "RASTER_nMapAlgebraExpr: Could not run raster iterator function");
SPI_finish();
+ elog(ERROR, "RASTER_nMapAlgebraExpr: Could not run raster iterator function");
PG_RETURN_NULL();
}
else if (raster == NULL) {
/* allocate container in aggcontext */
iwr = palloc(sizeof(struct rtpg_union_arg_t));
if (iwr == NULL) {
- elog(ERROR, "RASTER_union_transfn: Could not allocate memory for state variable");
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not allocate memory for state variable");
PG_RETURN_NULL();
}
/* Get raster object */
raster = rt_raster_deserialize(pgraster, FALSE);
if (raster == NULL) {
- elog(ERROR, "RASTER_union_transfn: Could not deserialize raster");
rtpg_union_arg_destroy(iwr);
PG_FREE_IF_COPY(pgraster, 1);
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not deserialize raster");
PG_RETURN_NULL();
}
}
iwr->bandarg = palloc(sizeof(struct rtpg_union_band_arg_t) * iwr->numband);
}
if (iwr->bandarg == NULL) {
- elog(ERROR, "RASTER_union_transfn: Could not allocate memory for band information");
rtpg_union_arg_destroy(iwr);
if (raster != NULL) {
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not allocate memory for band information");
PG_RETURN_NULL();
}
POSTGIS_RT_DEBUG(4, "Processing arg 3 as band number");
nband = PG_GETARG_INT32(2);
if (nband < 1) {
- elog(ERROR, "RASTER_union_transfn: Band number must be greater than zero (1-based)");
rtpg_union_arg_destroy(iwr);
if (raster != NULL) {
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Band number must be greater than zero (1-based)");
PG_RETURN_NULL();
}
iwr->numband = 1;
iwr->bandarg = palloc(sizeof(struct rtpg_union_band_arg_t) * iwr->numband);
if (iwr->bandarg == NULL) {
- elog(ERROR, "RASTER_union_transfn: Could not allocate memory for band information");
rtpg_union_arg_destroy(iwr);
if (raster != NULL) {
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not allocate memory for band information");
PG_RETURN_NULL();
}
POSTGIS_RT_DEBUG(4, "Processing arg 3 as unionarg");
if (!rtpg_union_unionarg_process(iwr, PG_GETARG_ARRAYTYPE_P(2))) {
- elog(ERROR, "RASTER_union_transfn: Could not process unionarg");
rtpg_union_arg_destroy(iwr);
if (raster != NULL) {
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not process unionarg");
PG_RETURN_NULL();
}
iwr->bandarg[i].raster = (rt_raster *) palloc(sizeof(rt_raster) * iwr->bandarg[i].numraster);
if (iwr->bandarg[i].raster == NULL) {
- elog(ERROR, "RASTER_union_transfn: Could not allocate memory for working raster(s)");
rtpg_union_arg_destroy(iwr);
if (raster != NULL) {
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not allocate memory for working raster(s)");
PG_RETURN_NULL();
}
for (j = 0; j < iwr->bandarg[i].numraster; j++) {
iwr->bandarg[i].raster[j] = rt_raster_clone(iwr->bandarg[0].raster[0], 0); /* shallow clone */
if (iwr->bandarg[i].raster[j] == NULL) {
- elog(ERROR, "RASTER_union_transfn: Could not create working raster");
rtpg_union_arg_destroy(iwr);
if (raster != NULL) {
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not create working raster");
PG_RETURN_NULL();
}
}
POSTGIS_RT_DEBUG(4, "no additional args, checking input raster");
nbnodata = 1;
if (!rtpg_union_noarg(iwr, raster)) {
- elog(ERROR, "RASTER_union_transfn: Could not check and balance number of bands");
rtpg_union_arg_destroy(iwr);
if (raster != NULL) {
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not check and balance number of bands");
PG_RETURN_NULL();
}
}
/* init itrset */
itrset = palloc(sizeof(struct rt_iterator_t) * 2);
if (itrset == NULL) {
- elog(ERROR, "RASTER_union_transfn: Could not allocate memory for iterator arguments");
rtpg_union_arg_destroy(iwr);
if (raster != NULL) {
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not allocate memory for iterator arguments");
PG_RETURN_NULL();
}
ET_UNION,
&iraster, _offset
) != ES_NONE) {
- elog(ERROR, "RASTER_union_transfn: Could not create internal raster");
pfree(itrset);
rtpg_union_arg_destroy(iwr);
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not create internal raster");
PG_RETURN_NULL();
}
POSTGIS_RT_DEBUGF(4, "_offset = %f, %f, %f, %f",
hasnodata, nodataval,
0
) == -1) {
- elog(ERROR, "RASTER_union_transfn: Could not add new band to internal raster");
pfree(itrset);
rtpg_union_arg_destroy(iwr);
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not add new band to internal raster");
PG_RETURN_NULL();
}
iband = rt_raster_get_band(iraster, 0);
_dim[0],
&vals, &nvals
) != ES_NONE) {
- elog(ERROR, "RASTER_union_transfn: Could not get pixel line from band of working raster");
pfree(itrset);
rtpg_union_arg_destroy(iwr);
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not get pixel line from band of working raster");
PG_RETURN_NULL();
}
(int) _offset[0], (int) _offset[1] + y,
vals, nvals
) != ES_NONE) {
- elog(ERROR, "RASTER_union_transfn: Could not set pixel line to band of internal raster");
pfree(itrset);
rtpg_union_arg_destroy(iwr);
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not set pixel line to band of internal raster");
PG_RETURN_NULL();
}
}
&_raster
);
if (noerr != ES_NONE) {
- elog(ERROR, "RASTER_union_transfn: Could not run raster iterator function");
pfree(itrset);
rtpg_union_arg_destroy(iwr);
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not run raster iterator function");
PG_RETURN_NULL();
}
_dim[0],
&vals, &nvals
) != ES_NONE) {
- elog(ERROR, "RASTER_union_transfn: Could not get pixel line from band of working raster");
pfree(itrset);
rtpg_union_arg_destroy(iwr);
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not get pixel line from band of working raster");
PG_RETURN_NULL();
}
(int) _offset[2], (int) _offset[3] + y,
vals, nvals
) != ES_NONE) {
- elog(ERROR, "RASTER_union_transfn: Could not set pixel line to band of internal raster");
pfree(itrset);
rtpg_union_arg_destroy(iwr);
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not set pixel line to band of internal raster");
PG_RETURN_NULL();
}
}
);
if (noerr != ES_NONE) {
- elog(ERROR, "RASTER_union_transfn: Could not run raster iterator function");
pfree(itrset);
rtpg_union_arg_destroy(iwr);
}
MemoryContextSwitchTo(oldcontext);
+ elog(ERROR, "RASTER_union_transfn: Could not run raster iterator function");
PG_RETURN_NULL();
}
}
/* init itrset */
itrset = palloc(sizeof(struct rt_iterator_t) * 2);
if (itrset == NULL) {
- elog(ERROR, "RASTER_union_finalfn: Could not allocate memory for iterator arguments");
rtpg_union_arg_destroy(iwr);
+ elog(ERROR, "RASTER_union_finalfn: Could not allocate memory for iterator arguments");
PG_RETURN_NULL();
}
}
if (noerr != ES_NONE) {
- elog(ERROR, "RASTER_union_finalfn: Could not run raster iterator function");
pfree(itrset);
rtpg_union_arg_destroy(iwr);
if (_rtn != NULL)
rt_raster_destroy(_rtn);
+ elog(ERROR, "RASTER_union_finalfn: Could not run raster iterator function");
PG_RETURN_NULL();
}
}
}
if (status < 0) {
- elog(ERROR, "RASTER_union_finalfn: Could not add band to final raster");
rtpg_union_arg_destroy(iwr);
rt_raster_destroy(_rtn);
+ elog(ERROR, "RASTER_union_finalfn: Could not add band to final raster");
PG_RETURN_NULL();
}
}
/* Get raster object */
arg->raster = rt_raster_deserialize(pgraster, FALSE);
if (arg->raster == NULL) {
- elog(ERROR, "RASTER_clip: Could not deserialize raster");
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_clip: Could not deserialize raster");
PG_RETURN_NULL();
}
/* get intersection geometry of input raster and input geometry */
if (rt_raster_get_convex_hull(arg->raster, &rastgeom) != ES_NONE) {
- elog(ERROR, "RASTER_clip: Could not get convex hull of raster");
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
lwgeom_free(geom);
PG_FREE_IF_COPY(gser, 2);
+ elog(ERROR, "RASTER_clip: Could not get convex hull of raster");
PG_RETURN_NULL();
}
case INT4OID:
break;
default:
- elog(ERROR, "RASTER_clip: Invalid data type for band indexes");
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
lwgeom_free(geom);
+ elog(ERROR, "RASTER_clip: Invalid data type for band indexes");
PG_RETURN_NULL();
break;
}
arg->band = palloc(sizeof(struct rtpg_clip_band_t) * arg->numbands);
if (arg->band == NULL) {
- elog(ERROR, "RASTER_clip: Could not allocate memory for band arguments");
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
lwgeom_free(geom);
+ elog(ERROR, "RASTER_clip: Could not allocate memory for band arguments");
PG_RETURN_NULL();
}
if (j < arg->numbands) {
arg->band = repalloc(arg->band, sizeof(struct rtpg_clip_band_t) * j);
if (arg->band == NULL) {
- elog(ERROR, "RASTER_clip: Could not reallocate memory for band arguments");
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
lwgeom_free(geom);
+ elog(ERROR, "RASTER_clip: Could not reallocate memory for band arguments");
PG_RETURN_NULL();
}
if (arg->numbands) {
arg->band = palloc(sizeof(struct rtpg_clip_band_t) * arg->numbands);
if (arg->band == NULL) {
- elog(ERROR, "RASTER_clip: Could not allocate memory for band arguments");
-
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
lwgeom_free(geom);
+ elog(ERROR, "RASTER_clip: Could not allocate memory for band arguments");
PG_RETURN_NULL();
}
case FLOAT8OID:
break;
default:
- elog(ERROR, "RASTER_clip: Invalid data type for NODATA values");
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
lwgeom_free(geom);
+ elog(ERROR, "RASTER_clip: Invalid data type for NODATA values");
PG_RETURN_NULL();
break;
}
pfree(wkb);
if (arg->mask == NULL) {
- elog(ERROR, "RASTER_clip: Could not rasterize intersection geometry");
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_clip: Could not rasterize intersection geometry");
PG_RETURN_NULL();
}
/* init itrset */
itrset = palloc(sizeof(struct rt_iterator_t) * 2);
if (itrset == NULL) {
- elog(ERROR, "RASTER_clip: Could not allocate memory for iterator arguments");
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_clip: Could not allocate memory for iterator arguments");
PG_RETURN_NULL();
}
if (rtn == NULL) {
noerr = rt_raster_from_two_rasters(arg->raster, arg->mask, arg->extenttype, &rtn, NULL);
if (noerr != ES_NONE) {
- elog(ERROR, "RASTER_clip: Could not create output raster");
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_clip: Could not create output raster");
PG_RETURN_NULL();
}
}
/* create NODATA band */
if (rt_raster_generate_new_band(rtn, pixtype, nodataval, hasnodata, nodataval, i) < 0) {
- elog(ERROR, "RASTER_clip: Could not add NODATA band to output raster");
rt_raster_destroy(rtn);
rtpg_clip_arg_destroy(arg);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_clip: Could not add NODATA band to output raster");
PG_RETURN_NULL();
}
);
if (noerr != ES_NONE) {
- elog(ERROR, "RASTER_clip: Could not run raster iterator function");
pfree(itrset);
rtpg_clip_arg_destroy(arg);
if (rtn != NULL) rt_raster_destroy(rtn);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_clip: Could not run raster iterator function");
PG_RETURN_NULL();
}
else {
band = rt_raster_get_band(_raster, 0);
if (band == NULL) {
- elog(ERROR, "RASTER_clip: Could not get band from working raster");
pfree(itrset);
rtpg_clip_arg_destroy(arg);
rt_raster_destroy(_raster);
rt_raster_destroy(rtn);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_clip: Could not get band from working raster");
PG_RETURN_NULL();
}
if (rt_raster_add_band(rtn, band, i) < 0) {
- elog(ERROR, "RASTER_clip: Could not add new band to output raster");
pfree(itrset);
rtpg_clip_arg_destroy(arg);
rt_raster_destroy(_raster);
rt_raster_destroy(rtn);
PG_FREE_IF_COPY(pgraster, 0);
+ elog(ERROR, "RASTER_clip: Could not add new band to output raster");
PG_RETURN_NULL();
}