From 224492f6fa6654d2fcb258c849e705757732ed47 Mon Sep 17 00:00:00 2001 From: Bborie Park Date: Tue, 27 Nov 2012 00:58:36 +0000 Subject: [PATCH] Added ST_NotSameAlignmentReason(raster, raster). Ticket #1709 git-svn-id: http://svn.osgeo.org/postgis/trunk@10742 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 1 + doc/reference_raster.xml | 65 +++++++- raster/loader/raster2pgsql.c | 2 +- raster/rt_core/rt_api.c | 27 ++-- raster/rt_core/rt_api.h | 5 +- raster/rt_pg/rt_pg.c | 101 +++++++++---- raster/rt_pg/rtpostgis.sql.in.c | 9 ++ raster/test/core/testapi.c | 16 +- raster/test/regress/rt_asraster_expected | 15 +- raster/test/regress/rt_resample_expected | 17 +++ raster/test/regress/rt_samealignment.sql | 142 +++++++++++++----- raster/test/regress/rt_samealignment_expected | 30 ++-- 12 files changed, 312 insertions(+), 118 deletions(-) diff --git a/NEWS b/NEWS index dd0f3ddc9..06798ab9b 100644 --- a/NEWS +++ b/NEWS @@ -53,6 +53,7 @@ PostGIS 2.1.0 - ST_Tile(raster) to break up a raster into tiles (Bborie Park / UC Davis) - #739, UpdateRasterSRID() - #1895, new r-tree node splitting algorithm (Alex Korotkov) + - #1709, ST_NotSameAlignmentReason(raster, raster) * Enhancements * - #823, tiger geocoder: Make loader_generate_script download portion diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index b1429cdda..7b44b2d2e 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -12034,7 +12034,70 @@ NOTICE: The two rasters provided have different SRIDs See Also - , + + , + , + + + + + + + + ST_NotSameAlignmentReason + Returns text stating if rasters are aligned and if not aligned, a reason why. + + + + + + boolean ST_SameAlignment + raster rastA + raster rastB + + + + + + Description + Returns text stating if rasters are aligned and if not aligned, a reason why. + + + + If there are several reasons why the rasters are not aligned, only one reason (the first test to fail) will be returned. + + + + Availability: 2.1.0 + + + + Examples + +SELECT + ST_SameAlignment( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1.1, 1.1, 0, 0) + ), + ST_NotSameAlignmentReason( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1.1, 1.1, 0, 0) + ) +; + + st_samealignment | st_notsamealignmentreason +------------------+------------------------------------------------- + f | The rasters have different scales on the X axis +(1 row) + + + + + See Also + + , + + diff --git a/raster/loader/raster2pgsql.c b/raster/loader/raster2pgsql.c index 020ab5456..599eb2eb2 100644 --- a/raster/loader/raster2pgsql.c +++ b/raster/loader/raster2pgsql.c @@ -646,7 +646,7 @@ diff_rastinfo(RASTERINFO *x, RASTERINFO *ref) { rt_raster_set_geotransform_matrix(rx, x->gt); rt_raster_set_geotransform_matrix(rref, ref->gt); - err = rt_raster_same_alignment(rx, rref, &aligned); + err = rt_raster_same_alignment(rx, rref, &aligned, NULL); rt_raster_destroy(rx); rt_raster_destroy(rref); if (!err) { diff --git a/raster/rt_core/rt_api.c b/raster/rt_core/rt_api.c index c2badcc64..68b392b71 100644 --- a/raster/rt_core/rt_api.c +++ b/raster/rt_core/rt_api.c @@ -12351,7 +12351,8 @@ rt_errorstate rt_raster_fully_within_distance( * * @param rast1 : the first raster for alignment test * @param rast2 : the second raster for alignment test - * @param aligned : non-zero value if the two rasters are aligned + * @param *aligned : non-zero value if the two rasters are aligned + * @param *reason : reason why rasters are not aligned * * @return ES_NONE if success, ES_ERROR if error */ @@ -12359,7 +12360,7 @@ rt_errorstate rt_raster_same_alignment( rt_raster rast1, rt_raster rast2, - int *aligned + int *aligned, char **reason ) { double xr; double yr; @@ -12369,29 +12370,30 @@ rt_raster_same_alignment( assert(NULL != rast1); assert(NULL != rast2); + assert(NULL != aligned); err = 0; /* same srid */ if (rt_raster_get_srid(rast1) != rt_raster_get_srid(rast2)) { - RASTER_DEBUG(3, "The two rasters provided have different SRIDs"); + if (reason != NULL) *reason = "The rasters have different SRIDs"; err = 1; } /* scales must match */ else if (FLT_NEQ(fabs(rast1->scaleX), fabs(rast2->scaleX))) { - RASTER_DEBUG(3, "The two raster provided have different scales on the X axis"); + if (reason != NULL) *reason = "The rasters have different scales on the X axis"; err = 1; } else if (FLT_NEQ(fabs(rast1->scaleY), fabs(rast2->scaleY))) { - RASTER_DEBUG(3, "The two raster provided have different scales on the Y axis"); + if (reason != NULL) *reason = "The rasters have different scales on the Y axis"; err = 1; } /* skews must match */ else if (FLT_NEQ(rast1->skewX, rast2->skewX)) { - RASTER_DEBUG(3, "The two raster provided have different skews on the X axis"); + if (reason != NULL) *reason = "The rasters have different skews on the X axis"; err = 1; } else if (FLT_NEQ(rast1->skewY, rast2->skewY)) { - RASTER_DEBUG(3, "The two raster provided have different skews on the Y axis"); + if (reason != NULL) *reason = "The rasters have different skews on the Y axis"; err = 1; } @@ -12430,13 +12432,14 @@ rt_raster_same_alignment( /* spatial coordinates are identical to that of first raster's upper-left corner */ if (FLT_EQ(xw, rast1->ipX) && FLT_EQ(yw, rast1->ipY)) { - RASTER_DEBUG(3, "The two rasters are aligned"); + if (reason != NULL) *reason = "The rasters are aligned"; *aligned = 1; return ES_NONE; } /* no alignment */ - RASTER_DEBUG(3, "The two rasters are NOT aligned"); + if (reason != NULL) *reason = "The rasters (pixel corner coordinates) are not aligned"; + *aligned = 0; return ES_NONE; } @@ -12478,7 +12481,7 @@ rt_raster_from_two_rasters( *noerr = 0; /* rasters must be aligned */ - if (rt_raster_same_alignment(rast1, rast2, &aligned) != ES_NONE) { + if (rt_raster_same_alignment(rast1, rast2, &aligned, NULL) != ES_NONE) { rterror("rt_raster_from_two_rasters: Unable to test for alignment on the two rasters"); return NULL; } @@ -13654,7 +13657,7 @@ rt_raster_iterator( /* check custom first if set. also skip if rasters are the same */ if (extenttype == ET_CUSTOM && rast != customextent) { - if (rt_raster_same_alignment(rast, customextent, &aligned) != ES_NONE) { + if (rt_raster_same_alignment(rast, customextent, &aligned, NULL) != ES_NONE) { rterror("rt_raster_iterator: Unable to test for alignment between reference raster and custom extent"); _rti_iterator_arg_destroy(_param); @@ -13672,7 +13675,7 @@ rt_raster_iterator( if (_param->isempty[i] || rast == _param->raster[i]) continue; - if (rt_raster_same_alignment(rast, _param->raster[i], &aligned) != ES_NONE) { + if (rt_raster_same_alignment(rast, _param->raster[i], &aligned, NULL) != ES_NONE) { rterror("rt_raster_iterator: Unable to test for alignment between reference raster and raster %d", i); _rti_iterator_arg_destroy(_param); diff --git a/raster/rt_core/rt_api.h b/raster/rt_core/rt_api.h index aee353867..838c3c9d2 100644 --- a/raster/rt_core/rt_api.h +++ b/raster/rt_core/rt_api.h @@ -1851,14 +1851,15 @@ rt_errorstate rt_raster_fully_within_distance( * * @param rast1 : the first raster for alignment test * @param rast2 : the second raster for alignment test - * @param aligned : non-zero value if the two rasters are aligned + * @param *aligned : non-zero value if the two rasters are aligned + * @param *reason : reason why rasters are not aligned * * @return ES_NONE if success, ES_ERROR if error */ rt_errorstate rt_raster_same_alignment( rt_raster rast1, rt_raster rast2, - int *aligned + int *aligned, char **reason ); /* diff --git a/raster/rt_pg/rt_pg.c b/raster/rt_pg/rt_pg.c index 558fc20fd..1dcce26c8 100644 --- a/raster/rt_pg/rt_pg.c +++ b/raster/rt_pg/rt_pg.c @@ -344,6 +344,7 @@ Datum RASTER_dfullywithin(PG_FUNCTION_ARGS); /* determine if two rasters are aligned */ Datum RASTER_sameAlignment(PG_FUNCTION_ARGS); +Datum RASTER_notSameAlignmentReason(PG_FUNCTION_ARGS); /* one-raster MapAlgebra */ Datum RASTER_mapAlgebraExpr(PG_FUNCTION_ARGS); @@ -13104,7 +13105,7 @@ Datum RASTER_sameAlignment(PG_FUNCTION_ARGS) uint32_t k; int rtn; int aligned = 0; - int err = 0; + char *reason = NULL; for (i = 0, j = 0; i < set_count; i++) { /* pgrast is null, return null */ @@ -13132,43 +13133,78 @@ Datum RASTER_sameAlignment(PG_FUNCTION_ARGS) } } - err = 0; - /* SRID must match */ - if (rt_raster_get_srid(rast[0]) != rt_raster_get_srid(rast[1])) { - elog(NOTICE, "The two rasters provided have different SRIDs"); - err = 1; - } - /* scales must match */ - else if (FLT_NEQ(fabs(rt_raster_get_x_scale(rast[0])), fabs(rt_raster_get_x_scale(rast[1])))) { - elog(NOTICE, "The two rasters provided have different scales on the X axis"); - err = 1; - } - else if (FLT_NEQ(fabs(rt_raster_get_y_scale(rast[0])), fabs(rt_raster_get_y_scale(rast[1])))) { - elog(NOTICE, "The two rasters provided have different scales on the Y axis"); - err = 1; - } - /* skews must match */ - else if (FLT_NEQ(rt_raster_get_x_skew(rast[0]), rt_raster_get_x_skew(rast[1]))) { - elog(NOTICE, "The two rasters provided have different skews on the X axis"); - err = 1; + rtn = rt_raster_same_alignment( + rast[0], + rast[1], + &aligned, + &reason + ); + for (k = 0; k < set_count; k++) { + rt_raster_destroy(rast[k]); + PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]); } - else if (FLT_NEQ(rt_raster_get_y_skew(rast[0]), rt_raster_get_y_skew(rast[1]))) { - elog(NOTICE, "The two rasters provided have different skews on the Y axis"); - err = 1; + + if (rtn != ES_NONE) { + elog(ERROR, "RASTER_sameAlignment: Unable to test for alignment on the two rasters"); + PG_RETURN_NULL(); } - if (err) { - for (k = 0; k < set_count; k++) { - rt_raster_destroy(rast[k]); - PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]); + if (reason != NULL) + elog(NOTICE, "%s", reason); + + PG_RETURN_BOOL(aligned); +} + +/** + * Return a reason why two rasters are not aligned + */ +PG_FUNCTION_INFO_V1(RASTER_notSameAlignmentReason); +Datum RASTER_notSameAlignmentReason(PG_FUNCTION_ARGS) +{ + const int set_count = 2; + rt_pgraster *pgrast[2]; + int pgrastpos[2] = {-1, -1}; + rt_raster rast[2] = {NULL}; + + uint32_t i; + uint32_t j; + uint32_t k; + int rtn; + int aligned = 0; + char *reason = NULL; + text *result = NULL; + + for (i = 0, j = 0; i < set_count; i++) { + /* pgrast is null, return null */ + if (PG_ARGISNULL(j)) { + for (k = 0; k < i; k++) { + rt_raster_destroy(rast[k]); + PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]); + } + PG_RETURN_NULL(); + } + pgrast[i] = (rt_pgraster *) PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(j), 0, sizeof(struct rt_raster_serialized_t)); + pgrastpos[i] = j; + j++; + + /* 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]); + } + PG_RETURN_NULL(); } - PG_RETURN_BOOL(0); } rtn = rt_raster_same_alignment( rast[0], rast[1], - &aligned + &aligned, + &reason ); for (k = 0; k < set_count; k++) { rt_raster_destroy(rast[k]); @@ -13176,11 +13212,12 @@ Datum RASTER_sameAlignment(PG_FUNCTION_ARGS) } if (rtn != ES_NONE) { - elog(ERROR, "RASTER_sameAlignment: Unable to test for alignment on the two rasters"); + elog(ERROR, "RASTER_notSameAlignmentReason: Unable to test for alignment on the two rasters"); PG_RETURN_NULL(); } - PG_RETURN_BOOL(aligned); + result = cstring2text(reason); + PG_RETURN_TEXT_P(result); } /** @@ -13407,7 +13444,7 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS) */ /* same alignment */ - if (rt_raster_same_alignment(_rast[0], _rast[1], &aligned) != ES_NONE) { + if (rt_raster_same_alignment(_rast[0], _rast[1], &aligned, NULL) != ES_NONE) { elog(ERROR, "RASTER_mapAlgebra2: Unable to test for alignment on the two rasters"); for (k = 0; k < set_count; k++) { if (_rast[k] != NULL) diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index 4256fe688..62654dd49 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -5068,6 +5068,15 @@ CREATE AGGREGATE st_samealignment(raster) ( FINALFUNC = _st_samealignment_finalfn ); +----------------------------------------------------------------------- +-- ST_NotSameAlignmentReason +----------------------------------------------------------------------- + +CREATE OR REPLACE FUNCTION st_notsamealignmentreason(rast1 raster, rast2 raster) + RETURNS text + AS 'MODULE_PATHNAME', 'RASTER_notSameAlignmentReason' + LANGUAGE 'c' IMMUTABLE STRICT; + ----------------------------------------------------------------------- -- ST_Intersects(raster, raster) ----------------------------------------------------------------------- diff --git a/raster/test/core/testapi.c b/raster/test/core/testapi.c index 135509ba9..3b89ad204 100644 --- a/raster/test/core/testapi.c +++ b/raster/test/core/testapi.c @@ -6712,6 +6712,7 @@ static void testAlignment() { rt_raster rast2; int rtn; int aligned; + char *reason; rast1 = rt_raster_new(2, 2); assert(rast1); @@ -6721,36 +6722,39 @@ static void testAlignment() { assert(rast2); rt_raster_set_scale(rast2, 1, 1); - rtn = rt_raster_same_alignment(rast1, rast2, &aligned); + rtn = rt_raster_same_alignment(rast1, rast2, &aligned, NULL); CHECK_EQUALS(rtn, ES_NONE); CHECK((aligned != 0)); rt_raster_set_scale(rast2, 0.1, 0.1); - rtn = rt_raster_same_alignment(rast1, rast2, &aligned); + rtn = rt_raster_same_alignment(rast1, rast2, &aligned, &reason); CHECK_EQUALS(rtn, ES_NONE); CHECK((aligned == 0)); + CHECK(!strcmp(reason, "The rasters have different scales on the X axis")); rt_raster_set_scale(rast2, 1, 1); rt_raster_set_skews(rast2, -0.5, 0.5); - rtn = rt_raster_same_alignment(rast1, rast2, &aligned); + rtn = rt_raster_same_alignment(rast1, rast2, &aligned, &reason); CHECK_EQUALS(rtn, ES_NONE); CHECK((aligned == 0)); + CHECK(!strcmp(reason, "The rasters have different skews on the X axis")); rt_raster_set_skews(rast2, 0, 0); rt_raster_set_offsets(rast2, 1, 1); - rtn = rt_raster_same_alignment(rast1, rast2, &aligned); + rtn = rt_raster_same_alignment(rast1, rast2, &aligned, NULL); CHECK_EQUALS(rtn, ES_NONE); CHECK((aligned != 0)); rt_raster_set_offsets(rast2, 2, 3); - rtn = rt_raster_same_alignment(rast1, rast2, &aligned); + rtn = rt_raster_same_alignment(rast1, rast2, &aligned, NULL); CHECK_EQUALS(rtn, ES_NONE); CHECK((aligned != 0)); rt_raster_set_offsets(rast2, 0.1, 0.1); - rtn = rt_raster_same_alignment(rast1, rast2, &aligned); + rtn = rt_raster_same_alignment(rast1, rast2, &aligned, &reason); CHECK_EQUALS(rtn, ES_NONE); CHECK((aligned == 0)); + CHECK(!strcmp(reason, "The rasters (pixel corner coordinates) are not aligned")); deepRelease(rast2); deepRelease(rast1); diff --git a/raster/test/regress/rt_asraster_expected b/raster/test/regress/rt_asraster_expected index dafd25e06..8fde45d6c 100644 --- a/raster/test/regress/rt_asraster_expected +++ b/raster/test/regress/rt_asraster_expected @@ -10,10 +10,17 @@ NOTICE: The geometry's SRID (993310) is not the same as the raster's SRID (9921 NOTICE: The geometry's SRID (993310) is not the same as the raster's SRID (992163). The geometry will be transformed to the raster's projection NOTICE: The geometry's SRID (993310) is not the same as the raster's SRID (992163). The geometry will be transformed to the raster's projection NOTICE: The geometry's SRID (993310) is not the same as the raster's SRID (992163). The geometry will be transformed to the raster's projection -NOTICE: The two rasters provided have different scales on the X axis -NOTICE: The two rasters provided have different scales on the X axis -NOTICE: The two rasters provided have different scales on the X axis -NOTICE: The two rasters provided have different scales on the X axis +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters have different scales on the X axis +NOTICE: The rasters have different scales on the X axis +NOTICE: The rasters have different scales on the X axis +NOTICE: The rasters have different scales on the X axis 1.0|||||||||||||||| 1.1|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|8BUI|0.000|t|1.000|1.000| 1.10|993310|141|87|1|1000.000|-1000.000|0.000|0.000|-175453.086|114987.661|32BF|0.000|t|1.000|1.000| diff --git a/raster/test/regress/rt_resample_expected b/raster/test/regress/rt_resample_expected index aef8d650a..85846654e 100644 --- a/raster/test/regress/rt_resample_expected +++ b/raster/test/regress/rt_resample_expected @@ -88,4 +88,21 @@ NOTICE: Values must be provided for both X and Y when specifying the scale. Re 5.7|992163|10|11|1|1000.000|-1000.000|0.000|0.000|-500000.000|600991.000|t|t|t 5.8|992163|10|11|1|1000.000|-1000.000|0.000|0.000|-500000.000|600001.000|t|t|t 5.9|992163|10|11|1|1000.000|-1000.000|0.000|0.000|-500000.000|600009.000|t|t|t +NOTICE: The rasters are aligned +NOTICE: The rasters (pixel corner coordinates) are not aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned +NOTICE: The rasters are aligned t|f|t diff --git a/raster/test/regress/rt_samealignment.sql b/raster/test/regress/rt_samealignment.sql index 307d080d3..5522b29c0 100644 --- a/raster/test/regress/rt_samealignment.sql +++ b/raster/test/regress/rt_samealignment.sql @@ -1,43 +1,105 @@ -SELECT ST_SameAlignment( - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0) -); -SELECT ST_SameAlignment( - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), - ST_MakeEmptyRaster(1, 1, 0, 0, 1.1, 1.1, 0, 0) -); -SELECT ST_SameAlignment( - ST_MakeEmptyRaster(1, 1, 0, 0, 1.1, 1.1, 0, 0), - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0) -); -SELECT ST_SameAlignment( - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0) -); -SELECT ST_SameAlignment( - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0.1) -); -SELECT ST_SameAlignment( - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1) -); -SELECT ST_SameAlignment( - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), - ST_MakeEmptyRaster(1, 1, 1, 1, 1, 1, 0, 0) -); -SELECT ST_SameAlignment( - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), - ST_MakeEmptyRaster(1, 1, 0.1, 0.1, 1, 1, 0, 0) -); -SELECT ST_SameAlignment( - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1), - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1) -); -SELECT ST_SameAlignment( - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1), - ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0) -); +SET client_min_messages TO warning; + +SELECT + ST_SameAlignment( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0) + ), + ST_NotSameAlignmentReason( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0) + ) +; +SELECT + ST_SameAlignment( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1.1, 1.1, 0, 0) + ), + ST_NotSameAlignmentReason( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1.1, 1.1, 0, 0) + ) +; +SELECT + ST_SameAlignment( + ST_MakeEmptyRaster(1, 1, 0, 0, 1.1, 1.1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0) + ), + ST_NotSameAlignmentReason( + ST_MakeEmptyRaster(1, 1, 0, 0, 1.1, 1.1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0) + ) +; +SELECT + ST_SameAlignment( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0) + ), + ST_NotSameAlignmentReason( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0) + ) +; +SELECT + ST_SameAlignment( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0.1) + ), + ST_NotSameAlignmentReason( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0.1) + ) +; +SELECT + ST_SameAlignment( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1) + ), + ST_NotSameAlignmentReason( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1) + ) +; +SELECT + ST_SameAlignment( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 1, 1, 1, 1, 0, 0) + ), + ST_NotSameAlignmentReason( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 1, 1, 1, 1, 0, 0) + ) +; +SELECT + ST_SameAlignment( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0.1, 0.1, 1, 1, 0, 0) + ), + ST_NotSameAlignmentReason( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0), + ST_MakeEmptyRaster(1, 1, 0.1, 0.1, 1, 1, 0, 0) + ) +; +SELECT + ST_SameAlignment( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1) + ), + ST_NotSameAlignmentReason( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1) + ) +; +SELECT + ST_SameAlignment( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0) + ), + ST_NotSameAlignmentReason( + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0.1), + ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, -0.1, 0) + ) +; DROP TABLE IF EXISTS raster_alignment_test; CREATE TABLE raster_alignment_test AS diff --git a/raster/test/regress/rt_samealignment_expected b/raster/test/regress/rt_samealignment_expected index 1569c1f14..5764b3ea9 100644 --- a/raster/test/regress/rt_samealignment_expected +++ b/raster/test/regress/rt_samealignment_expected @@ -1,26 +1,16 @@ +t|The rasters are aligned +f|The rasters have different scales on the X axis +f|The rasters have different scales on the X axis +f|The rasters have different skews on the X axis +f|The rasters have different skews on the Y axis +f|The rasters have different skews on the X axis +t|The rasters are aligned +f|The rasters (pixel corner coordinates) are not aligned +t|The rasters are aligned +f|The rasters have different skews on the Y axis t -NOTICE: The two rasters provided have different scales on the X axis f -NOTICE: The two rasters provided have different scales on the X axis f -NOTICE: The two rasters provided have different skews on the X axis f -NOTICE: The two rasters provided have different skews on the Y axis -f -NOTICE: The two rasters provided have different skews on the X axis -f -t -f -t -NOTICE: The two rasters provided have different skews on the Y axis -f -NOTICE: table "raster_alignment_test" does not exist, skipping -t -f -NOTICE: The two rasters provided have different skews on the X axis -f -NOTICE: The two rasters provided have different skews on the X axis -f -NOTICE: The two rasters provided have different skews on the Y axis f f -- 2.40.0