jiayuasu commented on code in PR #3043:
URL: https://github.com/apache/sedona/pull/3043#discussion_r3400312987


##########
flink/src/main/java/org/apache/sedona/flink/expressions/Predicates.java:
##########
@@ -405,4 +441,47 @@ public Boolean eval(
       return org.apache.sedona.common.Predicates.dWithin(geom1, geom2, 
distance, useSphere);
     }
   }
+
+  public static class ST_3DDWithin extends ScalarFunction {
+
+    public ST_3DDWithin() {}
+
+    /** 3D Euclidean distance-within over two geometries (missing Z folds to 
0). */
+    @DataTypeHint("Boolean")
+    public Boolean eval(
+        @DataTypeHint(
+                value = "RAW",
+                rawSerializer = GeometryTypeSerializer.class,
+                bridgedTo = Geometry.class)
+            Object o1,
+        @DataTypeHint(
+                value = "RAW",
+                rawSerializer = GeometryTypeSerializer.class,
+                bridgedTo = Geometry.class)
+            Object o2,
+        @DataTypeHint("Double") Double distance) {
+      if (o1 == null || o2 == null) return null;

Review Comment:
   Fixed in latest push: the geometry overload now guards `distance == null` 
(alongside the existing o1/o2 null guards) and returns NULL. Added a 
NULL-distance assertion to PredicateTest.test3DDWithin. The pre-existing 
ST_DWithin has the same gap (NULL distance and NULL geometry both NPE); tracked 
separately in #3046 to keep this PR scoped to Box3D.



##########
flink/src/main/java/org/apache/sedona/flink/expressions/Predicates.java:
##########
@@ -405,4 +441,47 @@ public Boolean eval(
       return org.apache.sedona.common.Predicates.dWithin(geom1, geom2, 
distance, useSphere);
     }
   }
+
+  public static class ST_3DDWithin extends ScalarFunction {
+
+    public ST_3DDWithin() {}
+
+    /** 3D Euclidean distance-within over two geometries (missing Z folds to 
0). */
+    @DataTypeHint("Boolean")
+    public Boolean eval(
+        @DataTypeHint(
+                value = "RAW",
+                rawSerializer = GeometryTypeSerializer.class,
+                bridgedTo = Geometry.class)
+            Object o1,
+        @DataTypeHint(
+                value = "RAW",
+                rawSerializer = GeometryTypeSerializer.class,
+                bridgedTo = Geometry.class)
+            Object o2,
+        @DataTypeHint("Double") Double distance) {
+      if (o1 == null || o2 == null) return null;
+      Geometry geom1 = (Geometry) o1;
+      Geometry geom2 = (Geometry) o2;
+      return org.apache.sedona.common.Predicates.dWithin3D(geom1, geom2, 
distance);
+    }
+
+    /** Closed-interval 3D distance test over two Box3D values. */
+    @DataTypeHint("Boolean")
+    public Boolean eval(
+        @DataTypeHint(
+                value = "RAW",
+                rawSerializer = Box3DTypeSerializer.class,
+                bridgedTo = Box3D.class)
+            Box3D a,
+        @DataTypeHint(
+                value = "RAW",
+                rawSerializer = Box3DTypeSerializer.class,
+                bridgedTo = Box3D.class)
+            Box3D b,
+        @DataTypeHint("Double") Double distance) {
+      if (a == null || b == null) return null;

Review Comment:
   Fixed in latest push: the Box3D overload now guards `distance == null` and 
returns NULL, with a NULL-distance assertion added to the test. See #3046 for 
the parallel ST_DWithin cleanup.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to