Changeset: ead103d932e7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ead103d932e7
Added Files:
        geom/sql/functions/Tests/ST_DWithin2.test
Modified Files:
        geom/sql/functions/Tests/All
Branch: geo-update
Log Message:

Adds Mtests for ST_DWithin2


diffs (104 lines):

diff --git a/geom/sql/functions/Tests/All b/geom/sql/functions/Tests/All
--- a/geom/sql/functions/Tests/All
+++ b/geom/sql/functions/Tests/All
@@ -67,7 +67,7 @@ HAVE_GEOM?ST_MakeBox2D
 #HAVE_GEOM?mbr_overlap_or_below
 #HAVE_GEOM?mbr_distance
 
-
+HAVE_GEOM?ST_DWithin2
 HAVE_GEOM?dropTestGeometries
 
 HAVE_GEOM?geomcasts
diff --git a/geom/sql/functions/Tests/ST_DWithin2.test 
b/geom/sql/functions/Tests/ST_DWithin2.test
new file mode 100644
--- /dev/null
+++ b/geom/sql/functions/Tests/ST_DWithin2.test
@@ -0,0 +1,87 @@
+# TODO: Those test must be part of the ST_DWithin.test
+
+# for gbox, hbox let us define
+# ambiguous_zone_min = dist(gbox, hbox) - diagonal(gbox)/2 - diagonal(hbox)/2 
+# ambiguous_zone_max = dist(gbox, hbox)
+# for every distance d in the ST_DWithin (last arg) that falls in the
+# zone we need to calculate the exact distance between for each
+# geometry. For any other case we can just rely on the information of
+# the bounding boxes
+
+# ambiguous_zone = [sqrt(2), 2 * sqrt(2)]
+# actual_distance = sqrt(2)
+# - distance < ambiguous_zone_min expect false
+# - dstance in ambiguous_zone AND distance > actual_distance expect true
+# - distance > ambiguous_zone_max expect true
+query T rowsort
+SELECT
+    ST_DWithin2(g, h, mbr(g), mbr(h), dist)
+FROM (
+    VALUES
+        (ST_WKTToSQL('LINESTRING(1 1, 2 2)'), ST_WKTToSQL('LINESTRING(3 3, 4 
4)'), 1),
+        (ST_WKTToSQL('LINESTRING(1 1, 2 2)'), ST_WKTToSQL('LINESTRING(3 3, 4 
4)'), 2),
+        (ST_WKTToSQL('LINESTRING(1 1, 2 2)'), ST_WKTToSQL('LINESTRING(3 3, 4 
4)'), 3)
+) AS REL(g, h, dist)
+----
+False
+True
+True
+
+# ambiguous_zone = [sqrt(2), 2 * sqrt(2)]
+# actual_distance = 2 * sqrt(2)
+# - distance < ambiguous_zone_min expect false
+# - dstance in ambiguous_zone AND distance < actual_distance expect false
+# - distance > ambiguous_zone_max expect true
+query T rowsort
+SELECT
+    ST_DWithin2(g, h, mbr(g), mbr(h), dist)
+FROM (
+    VALUES
+        (ST_WKTToSQL('LINESTRING(1 2, 2 1)'), ST_WKTToSQL('LINESTRING(3 4, 4 
3)'), 1),
+        (ST_WKTToSQL('LINESTRING(1 2, 2 1)'), ST_WKTToSQL('LINESTRING(3 4, 4 
3)'), 2),
+        (ST_WKTToSQL('LINESTRING(1 2, 2 1)'), ST_WKTToSQL('LINESTRING(3 4, 4 
3)'), 3)
+) AS REL(g, h, dist)
+----
+False
+False
+True
+
+# the shapes are equilateral rhombuses
+# ambiguous_zone = [sqrt(2), 2 * sqrt(2)]
+# actual_distance = 1.5 * sqrt(2)
+# - distance < ambiguous_zone_min expect false
+# - distance in ambiguous_zone AND distance < actual_distance expect false
+# - distance in ambiguous_zone AND distance > actual_distance expect true
+# - distance > ambiguous_zone_max expect true
+query T rowsort
+SELECT
+    ST_DWithin2(g, h, mbr(g), mbr(h), dist)
+FROM (
+    VALUES
+        (
+            ST_WKTToSQL('POLYGON((1.5 1, 2 1.5, 1.5 2, 1 1.5, 1.5 1))'),
+            ST_WKTToSQL('POLYGON((3.5 3, 4 3.5, 3.5 4, 3 3.5, 3.5 3))'),
+            1
+        ),
+        (
+            ST_WKTToSQL('POLYGON((1.5 1, 2 1.5, 1.5 2, 1 1.5, 1.5 1))'),
+            ST_WKTToSQL('POLYGON((3.5 3, 4 3.5, 3.5 4, 3 3.5, 3.5 3))'),
+            2
+        ),
+        (
+            ST_WKTToSQL('POLYGON((1.5 1, 2 1.5, 1.5 2, 1 1.5, 1.5 1))'),
+            ST_WKTToSQL('POLYGON((3.5 3, 4 3.5, 3.5 4, 3 3.5, 3.5 3))'),
+            2.5
+        ),
+        (
+            ST_WKTToSQL('POLYGON((1.5 1, 2 1.5, 1.5 2, 1 1.5, 1.5 1))'),
+            ST_WKTToSQL('POLYGON((3.5 3, 4 3.5, 3.5 4, 3 3.5, 3.5 3))'),
+            3
+        )
+) AS REL(g, h, dist)
+----
+False
+False
+True
+True
+
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to