koi2000 commented on code in PR #48695:
URL: https://github.com/apache/doris/pull/48695#discussion_r2013319714


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StDisjoint.java:
##########
@@ -0,0 +1,70 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.expressions.functions.scalar;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
+import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
+import 
org.apache.doris.nereids.trees.expressions.functions.PropagateNullLiteral;
+import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
+import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
+import org.apache.doris.nereids.types.BooleanType;
+import org.apache.doris.nereids.types.VarcharType;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**
+ * ScalarFunction 'st_disjoint'. This class is generated by GenerateFunction.
+ */
+public class StDisjoint extends ScalarFunction
+        implements BinaryExpression, ExplicitlyCastableSignature, 
AlwaysNullable, PropagateNullLiteral {
+
+    public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+            
FunctionSignature.ret(BooleanType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, 
VarcharType.SYSTEM_DEFAULT)

Review Comment:
   fixed



##########
be/src/geo/geo_types.cpp:
##########
@@ -476,6 +656,155 @@ std::string GeoPolygon::as_wkt() const {
     return ss.str();
 }
 
+bool GeoPolygon::intersects(const GeoShape* rhs) const {
+    switch (rhs->type()) {
+    case GEO_SHAPE_POINT: {
+        const GeoPoint* point = (const GeoPoint*)rhs;
+        // 1. when polygon contain the point return true
+        if (_polygon->Contains(*point->point())) {
+            return true;
+        }
+        // 2. calculate the distance between the point and the closest point 
on the boundary
+        S2Point closest_point = _polygon->ProjectToBoundary(*point->point());
+        S1Angle distance(closest_point, *point->point());
+        return distance.radians() < 1e-2;
+    }
+    case GEO_SHAPE_LINE_STRING: {
+        const GeoLine* line = (const GeoLine*)rhs;
+        std::vector<std::unique_ptr<S2Polyline>> intersect_lines =
+                _polygon->IntersectWithPolyline(*line->polyline());
+        if (intersect_lines.empty()) {
+            int next;
+            // s2geometry may not return the correct result when the line is 
on the boundary.
+            for (int i = 0; i < _polygon->num_loops(); ++i) {
+                const S2Loop* loop = _polygon->loop(i);
+                for (int j = 0; j < loop->num_vertices(); ++j) {
+                    const S2Point& p = loop->vertex(j);
+                    S2Point closest_point = line->polyline()->Project(p, 
&next);
+                    S1Angle distance(closest_point, p);
+                    if (distance.radians() < 1e-2) {

Review Comment:
   fixed



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to