]> granicus.if.org Git - postgis/commitdiff
Added ST_Disjoint(raster, raster), regression tests and docs. Ticket is
authorBborie Park <bkpark at ucdavis.edu>
Tue, 24 Jul 2012 18:01:31 +0000 (18:01 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Tue, 24 Jul 2012 18:01:31 +0000 (18:01 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10110 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
doc/reference_raster.xml
raster/rt_core/rt_api.h
raster/rt_pg/rtpostgis.sql.in.c
raster/test/regress/Makefile.in
raster/test/regress/rt_disjoint.sql [new file with mode: 0644]
raster/test/regress/rt_disjoint_expected [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 262f3063069b29eedc52437220292c0e33ea887e..0a2f91bc5d2fcf8bd86ad11ffe8289d37e70ee61 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,8 +14,8 @@ PostGIS 2.1.0
   - ST_PixelAsCentroid, ST_PixelAsCentroids (Bborie Park / UC Davis)
   - ST_Raster2WorldCoord, ST_World2RasterCoord (Bborie Park / UC Davis)
   - Additional raster/raster spatial relationship functions
-    (ST_Overlaps, ST_Touches, ST_Contains, ST_ContainsProperly, ST_Covers,
-    ST_CoveredBy, ST_Within)
+    (ST_Contains, ST_ContainsProperly, ST_Covers, ST_CoveredBy, ST_Disjoint,
+    ST_Overlaps, ST_Touches, ST_Within)
     (Bborie Park / UC Davis)
   - #1643, Tiger Geocoder - Tiger 2011 loader (Regina Obe / Paragon Corporation) 
     Funded by Hunter Systems Group
index 2efcefa529e5193bb518322e11554a6ef8fdce4c..e0d76d22fc72277ad1808e7823d87b2ea2087703 100644 (file)
@@ -8722,18 +8722,19 @@ a_rid | b_rid | overleft
        
        <sect1 id="Raster_Relationships">
                <title>Raster and Raster Band Spatial Relationships</title>
-               <refentry id="RT_ST_Intersects">
-               <refnamediv>
-                       <refname>ST_Intersects</refname>
-
-                       <refpurpose>Return true if raster rastA spatially intersects raster rastB.</refpurpose>
-                 </refnamediv>
 
-                 <refsynopsisdiv>
-                       <funcsynopsis>                    
+       <refentry id="RT_ST_Contains">
+               <refnamediv>
+                       <refname>ST_Contains</refname>
+                       <refpurpose>
+                               Return true if no points of raster rastB lie in the exterior of raster rastA and at least one point of the interior of rastB lies in the interior of rastA.
+                       </refpurpose>
+               </refnamediv>
 
-                         <funcprototype>
-                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
+               <refsynopsisdiv>
+                       <funcsynopsis>
+                               <funcprototype>
+                                       <funcdef>boolean <function>ST_Contains</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -8750,10 +8751,10 @@ a_rid | b_rid | overleft
                                                <type>integer </type>
                                                <parameter>nbandB</parameter>
                                        </paramdef>
-                         </funcprototype>
+                               </funcprototype>
 
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
+                                       <funcdef>boolean <function>ST_Contains</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -8762,111 +8763,154 @@ a_rid | b_rid | overleft
                                                <type>raster </type>
                                                <parameter>rastB</parameter>
                                        </paramdef>
-                         </funcprototype>
+                               </funcprototype>
+
+                       </funcsynopsis>
+               </refsynopsisdiv>
+
+               <refsection>
+                       <title>Description</title>
+
+                       <para>
+                               Raster rastA contains rastB if and only if no points of rastB lie in the exterior of rastA and at least one point of the interior of rastB lies in the interior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+                       </para>
+
+                       <note>
+                               <para>
+                                       This function will make use of any indexes that may be available on the rasters.
+                               </para>
+                       </note>
 
+                       <note>
+                               <para>
+                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Contains(ST_Polygon(raster), geometry) or ST_Contains(geometry, ST_Polygon(raster)).
+                               </para>
+                       </note>
+
+                       <note>
+                               <para>
+                                       ST_Contains() is the inverse of ST_Within().  So, ST_Contains(rastA, rastB) implies ST_Within(rastB, rastA).
+                               </para>
+                       </note>
+
+                       <para>Availability: 2.1.0</para>
+               </refsection>
+
+               <refsection>
+                       <title>Examples</title>
+
+                       <programlisting>
+-- needs an example
+                       </programlisting>
+               </refsection>
+               <refsection>
+                       <title>See Also</title>
+                       <para>
+                               <xref linkend="RT_ST_Intersects" />, 
+                               <xref linkend="RT_ST_Within" />
+                       </para>
+               </refsection>
+       </refentry>
+
+       <refentry id="RT_ST_ContainsProperly">
+               <refnamediv>
+                       <refname>ST_ContainsProperly</refname>
+                       <refpurpose>
+                               Return true if rastB intersects the interior of rastA but not the boundary or exterior of rastA.
+                       </refpurpose>
+               </refnamediv>
+
+               <refsynopsisdiv>
+                       <funcsynopsis>
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
-                                       <paramdef>
-                                         <type>raster </type>
-                                         <parameter>rast</parameter>
-                                       </paramdef>
+                                       <funcdef>boolean <function>ST_ContainsProperly</function></funcdef>
                                        <paramdef>
-                                         <type>integer </type>
-                                         <parameter>nband</parameter>
+                                               <type>raster </type>
+                                               <parameter>rastA</parameter>
                                        </paramdef>
                                        <paramdef>
-                                         <type>geometry </type>
-                                         <parameter>geommin</parameter>
+                                               <type>integer </type>
+                                               <parameter>nbandA</parameter>
                                        </paramdef>
-                         </funcprototype>
-
-                               <funcprototype>
-                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
                                        <paramdef>
-                                         <type>raster </type>
-                                         <parameter>rast</parameter>
+                                               <type>raster </type>
+                                               <parameter>rastB</parameter>
                                        </paramdef>
                                        <paramdef>
-                                         <type>geometry </type>
-                                         <parameter>geommin</parameter>
-                                       </paramdef>
-                                       <paramdef choice='opt'>
-                                         <type>integer </type>
-                                         <parameter>nband=NULL</parameter>
+                                               <type>integer </type>
+                                               <parameter>nbandB</parameter>
                                        </paramdef>
-                         </funcprototype>
+                               </funcprototype>
 
-                         <funcprototype>
-                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
+                               <funcprototype>
+                                       <funcdef>boolean <function>ST_ContainsProperly</function></funcdef>
                                        <paramdef>
-                                         <type>geometry </type>
-                                         <parameter>geommin</parameter>
+                                               <type>raster </type>
+                                               <parameter>rastA</parameter>
                                        </paramdef>
                                        <paramdef>
-                                         <type>raster </type>
-                                         <parameter>rast</parameter>
-                                       </paramdef>
-                                       <paramdef choice='opt'>
-                                         <type>integer </type>
-                                         <parameter>nband=NULL</parameter>
+                                               <type>raster </type>
+                                               <parameter>rastB</parameter>
                                        </paramdef>
-                         </funcprototype>
+                               </funcprototype>
 
                        </funcsynopsis>
-                 </refsynopsisdiv>
+               </refsynopsisdiv>
 
-                 <refsection>
+               <refsection>
                        <title>Description</title>
 
                        <para>
-                               Return true if raster rastA spatially intersects raster rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+                               Raster rastA contains properly rastB if rastB intersects the interior of rastA but not the boundary or exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+                       </para>
+
+                       <para>
+                               Raster rastA does not contain properly itself but does contain itself.
                        </para>
 
                        <note>
                                <para>
-                                       This operand will make use of any indexes that may be available on the rasters.
+                                       This function will make use of any indexes that may be available on the rasters.
                                </para>
                        </note>
-                               
-                       <para>
-                               Enhanced: 2.0.0 support raster/raster intersects was introduced.
-                       </para>
 
-                       <warning>
+                       <note>
                                <para>
-                                       Changed: 2.1.0 The behavior of the ST_Intersects(raster, geometry) variants changed to match that of ST_Intersects(geometry, raster).
+                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_ContainsProperly(ST_Polygon(raster), geometry) or ST_ContainsProperly(geometry, ST_Polygon(raster)).
                                </para>
-                       </warning>
+                       </note>
 
-                 </refsection>
+                       <para>Availability: 2.1.0</para>
+               </refsection>
 
-                 <refsection>
+               <refsection>
                        <title>Examples</title>
 
                        <programlisting>
--- needs a new example
+-- needs an example
                        </programlisting>
-                 </refsection> 
-                       <refsection>
-                               <title>See Also</title>
-                               <para>
-                                       <xref linkend="RT_ST_Intersection" />
-                               </para>
-                       </refsection>
-               </refentry>
+               </refsection>
+               <refsection>
+                       <title>See Also</title>
+                       <para>
+                               <xref linkend="RT_ST_Intersects" />, 
+                               <xref linkend="RT_ST_Contains" />
+                       </para>
+               </refsection>
+       </refentry>
 
-       <refentry id="RT_ST_Overlaps">
+       <refentry id="RT_ST_Covers">
                <refnamediv>
-                       <refname>ST_Overlaps</refname>
+                       <refname>ST_Covers</refname>
                        <refpurpose>
-                               Return true if raster rastA and rastB intersect but one does not completely contain the other.
+                               Return true if no points of raster rastB lie outside raster rastA.
                        </refpurpose>
                </refnamediv>
 
                <refsynopsisdiv>
                        <funcsynopsis>
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_Overlaps</function></funcdef>
+                                       <funcdef>boolean <function>ST_Covers</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -8886,7 +8930,7 @@ a_rid | b_rid | overleft
                                </funcprototype>
 
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_Overlaps</function></funcdef>
+                                       <funcdef>boolean <function>ST_Covers</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -8904,21 +8948,21 @@ a_rid | b_rid | overleft
                        <title>Description</title>
 
                        <para>
-                               Return true if raster rastA spatially overlaps raster rastB. This means that rastA and rastB intersect but one does not completely contain the other. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+                               Raster rastA covers rastB if and only if no points of rastB lie in the exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
                        </para>
 
                        <note>
                                <para>
-                                       This operand will make use of any indexes that may be available on the rasters.
+                                       This function will make use of any indexes that may be available on the rasters.
                                </para>
                        </note>
 
                        <note>
                                <para>
-                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Overlaps(ST_Polygon(raster), geometry).
+                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Covers(ST_Polygon(raster), geometry) or ST_Covers(geometry, ST_Polygon(raster)).
                                </para>
                        </note>
-                               
+
                        <para>Availability: 2.1.0</para>
                </refsection>
 
@@ -8932,23 +8976,24 @@ a_rid | b_rid | overleft
                <refsection>
                        <title>See Also</title>
                        <para>
-                               <xref linkend="RT_ST_Intersects" />
+                               <xref linkend="RT_ST_Intersects" />, 
+                               <xref linkend="RT_ST_CoveredBy" />
                        </para>
                </refsection>
        </refentry>
 
-       <refentry id="RT_ST_Touches">
+       <refentry id="RT_ST_CoveredBy">
                <refnamediv>
-                       <refname>ST_Touches</refname>
+                       <refname>ST_CoveredBy</refname>
                        <refpurpose>
-                               Return true if raster rastA and rastB have at least one point in common but their interiors do not intersect.
+                               Return true if no points of raster rastA lie outside raster rastB.
                        </refpurpose>
                </refnamediv>
 
                <refsynopsisdiv>
                        <funcsynopsis>
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_Touches</function></funcdef>
+                                       <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -8968,7 +9013,7 @@ a_rid | b_rid | overleft
                                </funcprototype>
 
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_Touches</function></funcdef>
+                                       <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -8986,18 +9031,18 @@ a_rid | b_rid | overleft
                        <title>Description</title>
 
                        <para>
-                               Return true if raster rastA spatially touches raster rastB. This means that rastA and rastB have at least one point in common but their interiors do not intersect. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+                               Raster rastA is covered by rastB if and only if no points of rastA lie in the exterior of rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
                        </para>
 
                        <note>
                                <para>
-                                       This operand will make use of any indexes that may be available on the rasters.
+                                       This function will make use of any indexes that may be available on the rasters.
                                </para>
                        </note>
 
                        <note>
                                <para>
-                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Touches(ST_Polygon(raster), geometry).
+                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_CoveredBy(ST_Polygon(raster), geometry) or ST_CoveredBy(geometry, ST_Polygon(raster)).
                                </para>
                        </note>
 
@@ -9014,23 +9059,24 @@ a_rid | b_rid | overleft
                <refsection>
                        <title>See Also</title>
                        <para>
-                               <xref linkend="RT_ST_Intersects" />
+                               <xref linkend="RT_ST_Intersects" />, 
+                               <xref linkend="RT_ST_Covers" />
                        </para>
                </refsection>
        </refentry>
 
-       <refentry id="RT_ST_Contains">
+       <refentry id="RT_ST_Disjoint">
                <refnamediv>
-                       <refname>ST_Contains</refname>
+                       <refname>ST_Disjoint</refname>
                        <refpurpose>
-                               Return true if no points of raster rastB lie in the exterior of raster rastA and at least one point of the interior of rastB lies in the interior of rastA.
+                               Return true if raster rastA does not spatially intersect rastB.
                        </refpurpose>
                </refnamediv>
 
                <refsynopsisdiv>
                        <funcsynopsis>
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_Contains</function></funcdef>
+                                       <funcdef>boolean <function>ST_Disjoint</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -9050,7 +9096,7 @@ a_rid | b_rid | overleft
                                </funcprototype>
 
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_Contains</function></funcdef>
+                                       <funcdef>boolean <function>ST_Disjoint</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -9068,24 +9114,18 @@ a_rid | b_rid | overleft
                        <title>Description</title>
 
                        <para>
-                               Raster rastA contains rastB if and only if no points of rastB lie in the exterior of rastA and at least one point of the interior of rastB lies in the interior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+                               Raster rastA and rastB are disjointed if they do not share any space together. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
                        </para>
 
                        <note>
                                <para>
-                                       This operand will make use of any indexes that may be available on the rasters.
-                               </para>
-                       </note>
-
-                       <note>
-                               <para>
-                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Contains(ST_Polygon(raster), geometry) or ST_Contains(geometry, ST_Polygon(raster)).
+                                       This function does NOT use any indexes.
                                </para>
                        </note>
 
                        <note>
                                <para>
-                                       ST_Contains() is the inverse of ST_Within().  So, ST_Contains(rastA, rastB) implies ST_Within(rastB, rastA).
+                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Disjoint(ST_Polygon(raster), geometry).
                                </para>
                        </note>
 
@@ -9102,24 +9142,21 @@ a_rid | b_rid | overleft
                <refsection>
                        <title>See Also</title>
                        <para>
-                               <xref linkend="RT_ST_Intersects" />, 
-                               <xref linkend="RT_ST_Within" />
+                               <xref linkend="RT_ST_Intersects" />
                        </para>
                </refsection>
        </refentry>
 
-       <refentry id="RT_ST_ContainsProperly">
+       <refentry id="RT_ST_Intersects">
                <refnamediv>
-                       <refname>ST_ContainsProperly</refname>
-                       <refpurpose>
-                               Return true if rastB intersects the interior of rastA but not the boundary or exterior of rastA.
-                       </refpurpose>
+                       <refname>ST_Intersects</refname>
+                       <refpurpose>Return true if raster rastA spatially intersects raster rastB.</refpurpose>
                </refnamediv>
 
                <refsynopsisdiv>
                        <funcsynopsis>
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_ContainsProperly</function></funcdef>
+                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -9139,7 +9176,7 @@ a_rid | b_rid | overleft
                                </funcprototype>
 
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_ContainsProperly</function></funcdef>
+                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -9150,6 +9187,54 @@ a_rid | b_rid | overleft
                                        </paramdef>
                                </funcprototype>
 
+                               <funcprototype>
+                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
+                                       <paramdef>
+                                               <type>raster </type>
+                                               <parameter>rast</parameter>
+                                       </paramdef>
+                                       <paramdef>
+                                               <type>integer </type>
+                                               <parameter>nband</parameter>
+                                       </paramdef>
+                                       <paramdef>
+                                               <type>geometry </type>
+                                               <parameter>geommin</parameter>
+                                       </paramdef>
+                               </funcprototype>
+
+                               <funcprototype>
+                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
+                                       <paramdef>
+                                               <type>raster </type>
+                                               <parameter>rast</parameter>
+                                       </paramdef>
+                                       <paramdef>
+                                               <type>geometry </type>
+                                               <parameter>geommin</parameter>
+                                       </paramdef>
+                                       <paramdef choice='opt'>
+                                               <type>integer </type>
+                                               <parameter>nband=NULL</parameter>
+                                       </paramdef>
+                               </funcprototype>
+
+                               <funcprototype>
+                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
+                                       <paramdef>
+                                               <type>geometry </type>
+                                               <parameter>geommin</parameter>
+                                       </paramdef>
+                                       <paramdef>
+                                               <type>raster </type>
+                                               <parameter>rast</parameter>
+                                       </paramdef>
+                                       <paramdef choice='opt'>
+                                               <type>integer </type>
+                                               <parameter>nband=NULL</parameter>
+                                       </paramdef>
+                               </funcprototype>
+
                        </funcsynopsis>
                </refsynopsisdiv>
 
@@ -9157,56 +9242,55 @@ a_rid | b_rid | overleft
                        <title>Description</title>
 
                        <para>
-                               Raster rastA contains properly rastB if rastB intersects the interior of rastA but not the boundary or exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
-                       </para>
-
-                       <para>
-                               Raster rastA does not contain properly itself but does contain itself.
+                               Return true if raster rastA spatially intersects raster rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
                        </para>
 
                        <note>
                                <para>
-                                       This operand will make use of any indexes that may be available on the rasters.
+                                       This function will make use of any indexes that may be available on the rasters.
                                </para>
                        </note>
 
-                       <note>
+                       <para>
+                               Enhanced: 2.0.0 support raster/raster intersects was introduced.
+                       </para>
+
+                       <warning>
                                <para>
-                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_ContainsProperly(ST_Polygon(raster), geometry) or ST_ContainsProperly(geometry, ST_Polygon(raster)).
+                                       Changed: 2.1.0 The behavior of the ST_Intersects(raster, geometry) variants changed to match that of ST_Intersects(geometry, raster).
                                </para>
-                       </note>
+                       </warning>
 
-                       <para>Availability: 2.1.0</para>
                </refsection>
 
                <refsection>
                        <title>Examples</title>
-
                        <programlisting>
--- needs an example
+-- needs a new example
                        </programlisting>
                </refsection>
+
                <refsection>
                        <title>See Also</title>
                        <para>
-                               <xref linkend="RT_ST_Intersects" />, 
-                               <xref linkend="RT_ST_Contains" />
+                               <xref linkend="RT_ST_Intersection" />, 
+                               <xref linkend="RT_ST_Disjoint" />
                        </para>
                </refsection>
        </refentry>
 
-       <refentry id="RT_ST_Covers">
+       <refentry id="RT_ST_Overlaps">
                <refnamediv>
-                       <refname>ST_Covers</refname>
+                       <refname>ST_Overlaps</refname>
                        <refpurpose>
-                               Return true if no points of raster rastB lie outside raster rastA.
+                               Return true if raster rastA and rastB intersect but one does not completely contain the other.
                        </refpurpose>
                </refnamediv>
 
                <refsynopsisdiv>
                        <funcsynopsis>
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_Covers</function></funcdef>
+                                       <funcdef>boolean <function>ST_Overlaps</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -9226,7 +9310,7 @@ a_rid | b_rid | overleft
                                </funcprototype>
 
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_Covers</function></funcdef>
+                                       <funcdef>boolean <function>ST_Overlaps</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -9244,21 +9328,21 @@ a_rid | b_rid | overleft
                        <title>Description</title>
 
                        <para>
-                               Raster rastA covers rastB if and only if no points of rastB lie in the exterior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+                               Return true if raster rastA spatially overlaps raster rastB. This means that rastA and rastB intersect but one does not completely contain the other. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
                        </para>
 
                        <note>
                                <para>
-                                       This operand will make use of any indexes that may be available on the rasters.
+                                       This function will make use of any indexes that may be available on the rasters.
                                </para>
                        </note>
 
                        <note>
                                <para>
-                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Covers(ST_Polygon(raster), geometry) or ST_Covers(geometry, ST_Polygon(raster)).
+                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Overlaps(ST_Polygon(raster), geometry).
                                </para>
                        </note>
-
+                               
                        <para>Availability: 2.1.0</para>
                </refsection>
 
@@ -9272,24 +9356,23 @@ a_rid | b_rid | overleft
                <refsection>
                        <title>See Also</title>
                        <para>
-                               <xref linkend="RT_ST_Intersects" />, 
-                               <xref linkend="RT_ST_CoveredBy" />
+                               <xref linkend="RT_ST_Intersects" />
                        </para>
                </refsection>
        </refentry>
 
-       <refentry id="RT_ST_CoveredBy">
+       <refentry id="RT_ST_Touches">
                <refnamediv>
-                       <refname>ST_CoveredBy</refname>
+                       <refname>ST_Touches</refname>
                        <refpurpose>
-                               Return true if no points of raster rastA lie outside raster rastB.
+                               Return true if raster rastA and rastB have at least one point in common but their interiors do not intersect.
                        </refpurpose>
                </refnamediv>
 
                <refsynopsisdiv>
                        <funcsynopsis>
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
+                                       <funcdef>boolean <function>ST_Touches</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -9309,7 +9392,7 @@ a_rid | b_rid | overleft
                                </funcprototype>
 
                                <funcprototype>
-                                       <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
+                                       <funcdef>boolean <function>ST_Touches</function></funcdef>
                                        <paramdef>
                                                <type>raster </type>
                                                <parameter>rastA</parameter>
@@ -9327,18 +9410,18 @@ a_rid | b_rid | overleft
                        <title>Description</title>
 
                        <para>
-                               Raster rastA is covered by rastB if and only if no points of rastA lie in the exterior of rastB. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
+                               Return true if raster rastA spatially touches raster rastB. This means that rastA and rastB have at least one point in common but their interiors do not intersect. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
                        </para>
 
                        <note>
                                <para>
-                                       This operand will make use of any indexes that may be available on the rasters.
+                                       This function will make use of any indexes that may be available on the rasters.
                                </para>
                        </note>
 
                        <note>
                                <para>
-                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_CoveredBy(ST_Polygon(raster), geometry) or ST_CoveredBy(geometry, ST_Polygon(raster)).
+                                       To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Touches(ST_Polygon(raster), geometry).
                                </para>
                        </note>
 
@@ -9355,8 +9438,7 @@ a_rid | b_rid | overleft
                <refsection>
                        <title>See Also</title>
                        <para>
-                               <xref linkend="RT_ST_Intersects" />, 
-                               <xref linkend="RT_ST_Covers" />
+                               <xref linkend="RT_ST_Intersects" />
                        </para>
                </refsection>
        </refentry>
index 7ac3f76fe1ae4ba3b825c9e6a71784603b9bd79a..73d04660c66e77870cdd1f8a11d71ed9fb9b46e4 100644 (file)
@@ -181,6 +181,11 @@ typedef enum {
 
 /**
  * GEOS spatial relationship tests available
+ *
+ * GEOS tests not available are:
+ *   intersects
+ *   crosses
+ *   disjoint
  */
 typedef enum {
        GSR_OVERLAPS = 0,
index 8dc9162a6e5269ceb263a616ebef7b437f64978f..811d59694155ec96b5d673d99e8af386b3e7cc0d 100644 (file)
@@ -3124,7 +3124,7 @@ CREATE OR REPLACE FUNCTION _st_intersects(rast1 raster, nband1 integer, rast2 ra
 
 CREATE OR REPLACE FUNCTION st_intersects(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
        RETURNS boolean
-       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_intersects(st_convexhull($1), st_convexhull($3)) ELSE _st_intersects($1, $2, $3, $4) END $$
+       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_intersects(st_convexhull($1), st_convexhull($3)) ELSE _st_intersects($1, $2, $3, $4) END $$
        LANGUAGE 'sql' IMMUTABLE
        COST 1000;
 
@@ -3302,7 +3302,7 @@ CREATE OR REPLACE FUNCTION _st_overlaps(rast1 raster, nband1 integer, rast2 rast
 
 CREATE OR REPLACE FUNCTION st_overlaps(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
        RETURNS boolean
-       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_overlaps(st_convexhull($1), st_convexhull($3)) ELSE _st_overlaps($1, $2, $3, $4) END $$
+       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_overlaps(st_convexhull($1), st_convexhull($3)) ELSE _st_overlaps($1, $2, $3, $4) END $$
        LANGUAGE 'sql' IMMUTABLE
        COST 1000;
 
@@ -3324,7 +3324,7 @@ CREATE OR REPLACE FUNCTION _st_touches(rast1 raster, nband1 integer, rast2 raste
 
 CREATE OR REPLACE FUNCTION st_touches(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
        RETURNS boolean
-       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_touches(st_convexhull($1), st_convexhull($3)) ELSE _st_touches($1, $2, $3, $4) END $$
+       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_touches(st_convexhull($1), st_convexhull($3)) ELSE _st_touches($1, $2, $3, $4) END $$
        LANGUAGE 'sql' IMMUTABLE
        COST 1000;
 
@@ -3346,7 +3346,7 @@ CREATE OR REPLACE FUNCTION _st_contains(rast1 raster, nband1 integer, rast2 rast
 
 CREATE OR REPLACE FUNCTION st_contains(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
        RETURNS boolean
-       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_contains(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($1, $2, $3, $4) END $$
+       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_contains(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($1, $2, $3, $4) END $$
        LANGUAGE 'sql' IMMUTABLE
        COST 1000;
 
@@ -3368,7 +3368,7 @@ CREATE OR REPLACE FUNCTION _st_containsproperly(rast1 raster, nband1 integer, ra
 
 CREATE OR REPLACE FUNCTION st_containsproperly(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
        RETURNS boolean
-       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_containsproperly(st_convexhull($1), st_convexhull($3)) ELSE _st_containsproperly($1, $2, $3, $4) END $$
+       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_containsproperly(st_convexhull($1), st_convexhull($3)) ELSE _st_containsproperly($1, $2, $3, $4) END $$
        LANGUAGE 'sql' IMMUTABLE
        COST 1000;
 
@@ -3390,7 +3390,7 @@ CREATE OR REPLACE FUNCTION _st_covers(rast1 raster, nband1 integer, rast2 raster
 
 CREATE OR REPLACE FUNCTION st_covers(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
        RETURNS boolean
-       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_covers(st_convexhull($1), st_convexhull($3)) ELSE _st_covers($1, $2, $3, $4) END $$
+       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_covers(st_convexhull($1), st_convexhull($3)) ELSE _st_covers($1, $2, $3, $4) END $$
        LANGUAGE 'sql' IMMUTABLE
        COST 1000;
 
@@ -3412,7 +3412,7 @@ CREATE OR REPLACE FUNCTION _st_coveredby(rast1 raster, nband1 integer, rast2 ras
 
 CREATE OR REPLACE FUNCTION st_coveredby(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
        RETURNS boolean
-       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_coveredby(st_convexhull($1), st_convexhull($3)) ELSE _st_coveredby($1, $2, $3, $4) END $$
+       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_coveredby(st_convexhull($1), st_convexhull($3)) ELSE _st_coveredby($1, $2, $3, $4) END $$
        LANGUAGE 'sql' IMMUTABLE
        COST 1000;
 
@@ -3434,7 +3434,7 @@ CREATE OR REPLACE FUNCTION _st_within(rast1 raster, nband1 integer, rast2 raster
 
 CREATE OR REPLACE FUNCTION st_within(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
        RETURNS boolean
-       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_within(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($3, $4, $1, $2) END $$
+       AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_within(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($3, $4, $1, $2) END $$
        LANGUAGE 'sql' IMMUTABLE
        COST 1000;
 
@@ -3444,6 +3444,22 @@ CREATE OR REPLACE FUNCTION st_within(rast1 raster, rast2 raster)
        LANGUAGE 'sql' IMMUTABLE
        COST 1000;
 
+-----------------------------------------------------------------------
+-- ST_Disjoint(raster, raster)
+-----------------------------------------------------------------------
+
+CREATE OR REPLACE FUNCTION st_disjoint(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
+       RETURNS boolean
+       AS $$ SELECT CASE WHEN $2 IS NULL OR $4 IS NULL THEN st_disjoint(st_convexhull($1), st_convexhull($3)) ELSE NOT _st_intersects($1, $2, $3, $4) END $$
+       LANGUAGE 'sql' IMMUTABLE
+       COST 1000;
+
+CREATE OR REPLACE FUNCTION st_disjoint(rast1 raster, rast2 raster)
+       RETURNS boolean
+       AS $$ SELECT st_disjoint($1, NULL::integer, $2, NULL::integer) $$
+       LANGUAGE 'sql' IMMUTABLE
+       COST 1000;
+
 -----------------------------------------------------------------------
 -- ST_Intersection(geometry, raster) in geometry-space
 -----------------------------------------------------------------------
index ec3e355e490b4a39d5d616c24699a350dca32e56..9e83d3f089e2e8940f808d837b7af4fd53ccf102 100644 (file)
@@ -132,6 +132,7 @@ TEST_SREL = \
        rt_covers \
        rt_coveredby \
        rt_within \
+       rt_disjoint \
        rt_samealignment
        
 TEST_BUGS = \
diff --git a/raster/test/regress/rt_disjoint.sql b/raster/test/regress/rt_disjoint.sql
new file mode 100644 (file)
index 0000000..afbc39a
--- /dev/null
@@ -0,0 +1,174 @@
+SET client_min_messages TO warning;
+
+DROP TABLE IF EXISTS raster_disjoint_rast;
+CREATE TABLE raster_disjoint_rast (
+       rid integer,
+       rast raster
+);
+CREATE OR REPLACE FUNCTION make_test_raster(rid integer, width integer DEFAULT 2, height integer DEFAULT 2, ul_x double precision DEFAULT 0, ul_y double precision DEFAULT 0, skew_x double precision DEFAULT 0, skew_y double precision DEFAULT 0)
+       RETURNS void
+       AS $$
+       DECLARE
+               x int;
+               y int;
+               rast raster;
+       BEGIN
+               rast := ST_MakeEmptyRaster(width, height, ul_x, ul_y, 1, 1, skew_x, skew_y, 0);
+               rast := ST_AddBand(rast, 1, '8BUI', 1, 0);
+
+
+               INSERT INTO raster_disjoint_rast VALUES (rid, rast);
+
+               RETURN;
+       END;
+       $$ LANGUAGE 'plpgsql';
+SELECT make_test_raster(0, 2, 2, -1, -1);
+SELECT make_test_raster(1, 2, 2);
+SELECT make_test_raster(2, 3, 3);
+DROP FUNCTION make_test_raster(integer, integer, integer, double precision, double precision, double precision, double precision);
+
+INSERT INTO raster_disjoint_rast VALUES (10, (
+       SELECT
+               ST_SetValue(rast, 1, 1, 1, 0)
+       FROM raster_disjoint_rast
+       WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (11, (
+       SELECT
+               ST_SetValue(rast, 1, 2, 1, 0)
+       FROM raster_disjoint_rast
+       WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (12, (
+       SELECT
+               ST_SetValue(
+                       ST_SetValue(
+                               ST_SetValue(rast, 1, 1, 1, 0),
+                               1, 2, 1, 0
+                       ),
+                       1, 1, 2, 0
+               )
+       FROM raster_disjoint_rast
+       WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (13, (
+       SELECT
+               ST_SetValue(
+                       ST_SetValue(
+                               ST_SetValue(
+                                       ST_SetValue(rast, 1, 1, 1, 0),
+                                       1, 2, 1, 0
+                               ),
+                               1, 1, 2, 0
+                       ),
+                       1, 2, 2, 0
+               )
+       FROM raster_disjoint_rast
+       WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (14, (
+       SELECT
+               ST_SetUpperLeft(rast, 2, 0)
+       FROM raster_disjoint_rast
+       WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (15, (
+       SELECT
+               ST_SetScale(
+                       ST_SetUpperLeft(rast, 0.1, 0.1),
+                       0.4, 0.4
+               )
+       FROM raster_disjoint_rast
+       WHERE rid = 1
+));
+INSERT INTO raster_disjoint_rast VALUES (16, (
+       SELECT
+               ST_SetScale(
+                       ST_SetUpperLeft(rast, -0.1, 0.1),
+                       0.4, 0.4
+               )
+       FROM raster_disjoint_rast
+       WHERE rid = 1
+));
+
+INSERT INTO raster_disjoint_rast VALUES (20, (
+       SELECT
+               ST_SetUpperLeft(rast, -2, -2)
+       FROM raster_disjoint_rast
+       WHERE rid = 2
+));
+INSERT INTO raster_disjoint_rast VALUES (21, (
+       SELECT
+               ST_SetValue(
+                       ST_SetValue(
+                               ST_SetValue(rast, 1, 1, 1, 0),
+                               1, 2, 2, 0
+                       ),
+                       1, 3, 3, 0
+               )
+       FROM raster_disjoint_rast
+       WHERE rid = 20
+));
+INSERT INTO raster_disjoint_rast VALUES (22, (
+       SELECT
+               ST_SetValue(
+                       ST_SetValue(
+                               rast, 1, 3, 2, 0
+                       ),
+                       1, 2, 3, 0
+               )
+       FROM raster_disjoint_rast
+       WHERE rid = 21
+));
+INSERT INTO raster_disjoint_rast VALUES (23, (
+       SELECT
+               ST_SetValue(
+                       ST_SetValue(
+                               rast, 1, 3, 1, 0
+                       ),
+                       1, 1, 3, 0
+               )
+       FROM raster_disjoint_rast
+       WHERE rid = 22
+));
+
+INSERT INTO raster_disjoint_rast VALUES (30, (
+       SELECT
+               ST_SetSkew(rast, -0.5, 0.5)
+       FROM raster_disjoint_rast
+       WHERE rid = 2
+));
+INSERT INTO raster_disjoint_rast VALUES (31, (
+       SELECT
+               ST_SetSkew(rast, -1, 1)
+       FROM raster_disjoint_rast
+       WHERE rid = 2
+));
+INSERT INTO raster_disjoint_rast VALUES (32, (
+       SELECT
+               ST_SetSkew(rast, 1, -1)
+       FROM raster_disjoint_rast
+       WHERE rid = 2
+));
+
+SELECT
+       '1.1',
+       r1.rid,
+       r2.rid,
+       ST_Disjoint(r1.rast, NULL, r2.rast, NULL)
+FROM raster_disjoint_rast r1
+JOIN raster_disjoint_rast r2
+       ON r1.rid != r2.rid
+WHERE r1.rid = 0;
+
+SELECT
+       '1.2',
+       r1.rid,
+       r2.rid,
+       ST_Disjoint(r1.rast, 1, r2.rast, 1)
+FROM raster_disjoint_rast r1
+JOIN raster_disjoint_rast r2
+       ON r1.rid != r2.rid
+WHERE r1.rid = 0;
+
+DROP TABLE IF EXISTS raster_disjoint_rast;
diff --git a/raster/test/regress/rt_disjoint_expected b/raster/test/regress/rt_disjoint_expected
new file mode 100644 (file)
index 0000000..a3fbbe5
--- /dev/null
@@ -0,0 +1,32 @@
+1.1|0|1|f
+1.1|0|2|f
+1.1|0|10|f
+1.1|0|11|f
+1.1|0|12|f
+1.1|0|13|f
+1.1|0|14|t
+1.1|0|15|f
+1.1|0|16|f
+1.1|0|20|f
+1.1|0|21|f
+1.1|0|22|f
+1.1|0|23|f
+1.1|0|30|f
+1.1|0|31|f
+1.1|0|32|f
+1.2|0|1|f
+1.2|0|2|f
+1.2|0|10|f
+1.2|0|11|f
+1.2|0|12|f
+1.2|0|13|t
+1.2|0|14|t
+1.2|0|15|f
+1.2|0|16|f
+1.2|0|20|f
+1.2|0|21|f
+1.2|0|22|f
+1.2|0|23|f
+1.2|0|30|f
+1.2|0|31|f
+1.2|0|32|f