Skip to content

Commit

Permalink
Add CYPHER_WITHIN_BBOX
Browse files Browse the repository at this point in the history
  • Loading branch information
murermader committed Oct 8, 2024
1 parent f32489d commit 50db081
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ private void defineCypherMethods() {
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_GRAPH_ONLY_LABEL ), BuiltInMethod.X_MODEL_GRAPH_ONLY_LABEL.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_POINT ), BuiltInMethod.CYPHER_POINT.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_DISTANCE ), BuiltInMethod.CYPHER_DISTANCE.method, NullPolicy.NONE );
defineMethod( OperatorRegistry.get( cypher, OperatorName.CYPHER_WITHIN_BBOX ), BuiltInMethod.CYPHER_WITHIN_BBOX.method, NullPolicy.NONE );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,8 @@ public enum OperatorName {

CYPHER_DISTANCE ( LangFunctionOperator.class ),

CYPHER_WITHIN_BBOX ( LangFunctionOperator.class ),

// CROSS MODEL FUNCTION

CROSS_MODEL_ITEM( LangFunctionOperator.class ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@ public static PolyDouble distance(PolyValue p1, PolyValue p2) {
}
}

public static PolyBoolean withinBBox(PolyValue point, PolyValue bbox) {
PolyGeometry g = point.asGeometry();
PolyGeometry gBBox = bbox.asGeometry();
return new PolyBoolean( g.within( gBBox ) );
}

private static double convertPolyValueToDouble( PolyValue value ) {
Double result = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ public enum BuiltInMethod {
CYPHER_REMOVE_PROPERTY( CypherFunctions.class, "removeProperty", GraphPropertyHolder.class, String.class ),
CYPHER_POINT( CypherFunctions.class, "point", PolyValue.class ),
CYPHER_DISTANCE( CypherFunctions.class, "distance", PolyValue.class, PolyValue.class ),
CYPHER_WITHIN_BBOX( CypherFunctions.class, "withinBBox", PolyValue.class, PolyValue.class ),
TO_NODE( CypherFunctions.class, "toNode", Enumerable.class ),
TO_EDGE( CypherFunctions.class, "toEdge", Enumerable.class ),
TO_GRAPH( CypherFunctions.class, "toGraph", Enumerable.class, Enumerable.class ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public static void registerOperators() {

register( OperatorName.CYPHER_DISTANCE, new LangFunctionOperator( "CYPHER_DISTANCE", Kind.CYPHER_FUNCTION ) );

register( OperatorName.CYPHER_WITHIN_BBOX, new LangFunctionOperator( "CYPHER_WITHIN_BBOX", Kind.CYPHER_FUNCTION ) );

isInit = true;
}

Expand Down

0 comments on commit 50db081

Please sign in to comment.