]> granicus.if.org Git - postgis/commitdiff
Added ST_NotSameAlignmentReason(raster, raster). Ticket #1709
authorBborie Park <bkpark at ucdavis.edu>
Tue, 27 Nov 2012 00:58:36 +0000 (00:58 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Tue, 27 Nov 2012 00:58:36 +0000 (00:58 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10742 b70326c6-7e19-0410-871a-916f4a2858ee

12 files changed:
NEWS
doc/reference_raster.xml
raster/loader/raster2pgsql.c
raster/rt_core/rt_api.c
raster/rt_core/rt_api.h
raster/rt_pg/rt_pg.c
raster/rt_pg/rtpostgis.sql.in.c
raster/test/core/testapi.c
raster/test/regress/rt_asraster_expected
raster/test/regress/rt_resample_expected
raster/test/regress/rt_samealignment.sql
raster/test/regress/rt_samealignment_expected

diff --git a/NEWS b/NEWS
index dd0f3ddc941fc7d2d0a53509248d2492d5a08d6c..06798ab9bb2feaf9fd2a79864dda904b6afa3b80 100644 (file)
--- 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 
index b1429cdda7901f7f7e9192efb3cf1428236b2934..7b44b2d2e0a850b562bafb4afe69cc04fd9f28ea 100644 (file)
@@ -12034,7 +12034,70 @@ NOTICE:  The two rasters provided have different SRIDs
                  </refsection> 
                        <refsection>
                                <title>See Also</title>
-                               <para><xref linkend="RT_Loading_Rasters" />, <xref linkend="RT_ST_MakeEmptyRaster" /></para>
+                               <para>
+                                       <xref linkend="RT_Loading_Rasters" />, 
+                                       <xref linkend="RT_ST_NotSameAlignmentReason" />, 
+                                       <xref linkend="RT_ST_MakeEmptyRaster" />
+                               </para>
+                       </refsection>
+               </refentry>
+
+               <refentry id="RT_ST_NotSameAlignmentReason">
+                       <refnamediv>
+                               <refname>ST_NotSameAlignmentReason</refname>
+                               <refpurpose>Returns text stating if rasters are aligned and if not aligned, a reason why.</refpurpose>
+                       </refnamediv>
+
+                       <refsynopsisdiv>
+                               <funcsynopsis>
+                                       <funcprototype>
+                                               <funcdef>boolean <function>ST_SameAlignment</function></funcdef>
+                                               <paramdef><type>raster </type><parameter>rastA</parameter></paramdef>
+                                               <paramdef><type>raster </type><parameter>rastB</parameter></paramdef>
+                                       </funcprototype>
+                               </funcsynopsis>
+                       </refsynopsisdiv>
+
+                       <refsection>
+                               <title>Description</title>
+                               <para>Returns text stating if rasters are aligned and if not aligned, a reason why.</para>
+
+                               <note>
+                                       <para>
+                                               If there are several reasons why the rasters are not aligned, only one reason (the first test to fail) will be returned.
+                                       </para>
+                               </note>
+
+                               <para>Availability: 2.1.0</para>
+                       </refsection>
+
+                       <refsection>
+                               <title>Examples</title>
+                               <programlisting>
+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)
+                               </programlisting>
+                       </refsection>
+
+                       <refsection>
+                               <title>See Also</title>
+                               <para>
+                                       <xref linkend="RT_Loading_Rasters" />, 
+                                       <xref linkend="RT_ST_SameAlignment" />
+                               </para>
                        </refsection>
                </refentry>
 
index 020ab5456439ca2054bb847e3472646ca8379d22..599eb2eb27a749a393369f0ca84b5e7a2b7e0746 100644 (file)
@@ -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) {
index c2badcc649b3c55b4667b4d96f83c13179a1476c..68b392b7129272e3cdfccbcdcb7485d91836b310 100644 (file)
@@ -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);
index aee353867ad9b78a1acee853de571d09a9c1d956..838c3c9d281f1bfeffdf40e16d2e7245182c61bf 100644 (file)
@@ -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
 );
 
 /*
index 558fc20fdadf5daa19f7ab317ea1f63a2bf0a08d..1dcce26c8798a9561394eb5c67fb301e484a007a 100644 (file)
@@ -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)
index 4256fe688e94657a68b93158998d7db72bfcf610..62654dd490389376ee1311ff7af2f3875f44c411 100644 (file)
@@ -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)
 -----------------------------------------------------------------------
index 135509ba9a6a69ccd0738595180a0428297fd9c3..3b89ad204db130c590e4a761ded9cb1c75099063 100644 (file)
@@ -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);
index dafd25e0641c9dcd01f3d84498af21379f5c5aaf..8fde45d6c72c16154b157775fb1b47a8c23ffe19 100644 (file)
@@ -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|
index aef8d650a48070ac5435eb716e230d07e0ee333c..85846654ee44505af24e682d07f9f3b9d2980059 100644 (file)
@@ -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
index 307d080d3574ac63f84fcf517e27eb229699684b..5522b29c0bfbb80f310ecc284452a876622b90d1 100644 (file)
-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
index 1569c1f14dcd6c45a40d803e7fb795fb11132ed5..5764b3ea92c1f0efffc7cd38e49c42515f3492c9 100644 (file)
@@ -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