This is an automated email from the ASF dual-hosted git repository.

jhyde pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 4ef9ffe0d4 [CALCITE-4186] Add ST_CoveredBy spatial function
4ef9ffe0d4 is described below

commit 4ef9ffe0d4afb80fe95e66d4d9c9e6f5939f70a8
Author: Bertil Chapuis <[email protected]>
AuthorDate: Mon Oct 3 21:43:11 2022 +0200

    [CALCITE-4186] Add ST_CoveredBy spatial function
    
    Close apache/calcite#2927
---
 .../org/apache/calcite/runtime/SpatialTypeFunctions.java     |  7 +++++++
 core/src/test/resources/sql/spatial.iq                       | 12 ++++++++++++
 site/_docs/reference.md                                      |  1 +
 3 files changed, 20 insertions(+)

diff --git 
a/core/src/main/java/org/apache/calcite/runtime/SpatialTypeFunctions.java 
b/core/src/main/java/org/apache/calcite/runtime/SpatialTypeFunctions.java
index bba3e13edf..8ba060348b 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SpatialTypeFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SpatialTypeFunctions.java
@@ -1012,6 +1012,13 @@ public class SpatialTypeFunctions {
         && !geom1.crosses(geom2);
   }
 
+  /**
+   * Returns whether no point in {@code geom1} is outside {@code geom2}.
+   */
+  public static boolean ST_CoveredBy(Geometry geom1, Geometry geom2) {
+    return geom1.coveredBy(geom2);
+  }
+
   /**
    * Returns whether no point in {@code geom2} is outside {@code geom1}.
    */
diff --git a/core/src/test/resources/sql/spatial.iq 
b/core/src/test/resources/sql/spatial.iq
index 827084cc21..9ec31ccf9a 100644
--- a/core/src/test/resources/sql/spatial.iq
+++ b/core/src/test/resources/sql/spatial.iq
@@ -1244,6 +1244,18 @@ POINT, true, true, false, false
 POLYGON, true, true, false, false
 !ok
 
+# ST_CoveredBy(geom1, geom2) Returns whether no point in *geom1* is outside 
*geom2*
+
+SELECT ST_CoveredBy('POINT(0 0)', ST_Buffer('POINT(0 0)', 1));
+EXPR$0
+true
+!ok
+
+SELECT ST_CoveredBy('POINT(1 1)', ST_Buffer('POINT(0 0)', 1));
+EXPR$0
+false
+!ok
+
 # ST_Covers(geom1, geom2) Returns whether no point in *geom2* is outside 
*geom1*
 
 SELECT ST_Covers(ST_Buffer('POINT(0 0)', 1), 'POINT(0 0)');
diff --git a/site/_docs/reference.md b/site/_docs/reference.md
index b51726d6dc..7e6aeba4bf 100644
--- a/site/_docs/reference.md
+++ b/site/_docs/reference.md
@@ -2295,6 +2295,7 @@ Not implemented:
 |:- |:-------------------- |:-----------
 | o | ST_Contains(geom1, geom2) | Returns whether *geom1* contains *geom2*
 | p | ST_ContainsProperly(geom1, geom2) | Returns whether *geom1* contains 
*geom2* but does not intersect its boundary
+| p | ST_CoveredBy(geom1, geom2) | Returns whether no point in *geom1* is 
outside *geom2*.
 | p | ST_Covers(geom1, geom2) | Returns whether no point in *geom2* is outside 
*geom1*
 | o | ST_Crosses(geom1, geom2) | Returns whether *geom1* crosses *geom2*
 | o | ST_Disjoint(geom1, geom2) | Returns whether *geom1* and *geom2* are 
disjoint

Reply via email to