<refnamediv>
<refname>~=</refname>
- <refpurpose>Returns <varname>TRUE</varname> if the geometry A is the same as B.</refpurpose>
+ <refpurpose>Returns <varname>TRUE</varname> if A's bounding box is the same as B's.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsection>
<title>Description</title>
- <para>The <varname>~=</varname> operator returns <varname>TRUE</varname> if geometry A is the same as geometry B.
- It tests actual geometric equality of two features. So if A and B are the same feature, vertex-by-vertex, the
- operator returns <varname>TRUE</varname>.</para>
+ <para>The <varname>~=</varname> operator returns <varname>TRUE</varname> if the bounding box of geometry/geography A
+ is the same as the bounding box of geometry/geography B.</para>
<note><para>This operand will make use of any indexes that may be available on the
geometries.</para></note>
- <para>Availability: 1.5.0 support for geography was introduced.</para>
+ <para>Availability: 1.5.0 changed behavior</para>
</refsection>
-
+
+ <warning>
+ <para>This operator has changed behavior in PostGIS 1.5
+ from testing for actual geometric equality to only
+ checking for bounding box equality. To complicate things
+ it also depends on if you have done a hard or soft upgrade
+ which behavior your database has. To find out which behavior
+ your database has you can run the query below.
+ To check for true equality use <xref linkend="ST_OrderingEquals" /> or <xref
+ linkend="ST_Equals" /> and to check for bounding box equality <xref linkend="ST_Geometry_EQ" />;
+ operator is a safer option.</para>
+ </warning>
<refsection>
<title>Examples</title>
+<programlisting>
- <programlisting>SELECT tbl1.column1, tbl2.column1, tbl1.column2 ~= tbl2.column2 AS same
-FROM
- ( VALUES
- (1, 'LINESTRING (0 0, 2 2)'::geometry)) AS tbl1,
- ( VALUES
- (2, 'LINESTRING (0 0, 1 1, 2 2)'::geometry),
- (3, 'LINESTRING (2 2, 0 0)'::geometry),
- (4, 'LINESTRING (0 0, 2 2)'::geometry)) AS tbl2;
-
- column1 | column1 | same
----------+---------+------
- 1 | 2 | f
- 1 | 3 | f
- 1 | 4 | t
-(3 rows)</programlisting>
+select 'LINESTRING(0 0, 1 1)'::geometry ~= 'LINESTRING(0 1, 1 0)'::geometry as equality;
+ equality |
+-----------------+
+ t |
+ </programlisting>
+ <para>The above can be used to test if you have the new or old behavior of ~= operator.</para>
</refsection>
-
<refsection>
<title>See Also</title>
-
<para><xref linkend="ST_Equals" />, <xref linkend="ST_OrderingEquals" />, <xref linkend="ST_Geometry_EQ" /></para>
</refsection>
</refentry>