-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #2879 - revamp radius-based distance calculation
I don't think this was ever working right. Now I think it at least follows the formulas laid out at Depends on the RDBMS supporting the `RADIANS` function (which supposedly works the same across at least Derby, Db2, and Postgresql). Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
- Loading branch information
Showing
10 changed files
with
174 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
fhir-database-utils/src/main/java/com/ibm/fhir/database/utils/query/node/RadiansExpNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* (C) Copyright IBM Corp. 2021 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.ibm.fhir.database.utils.query.node; | ||
|
||
import java.util.Stack; | ||
|
||
/** | ||
* The RADIANS SQL function | ||
*/ | ||
public class RadiansExpNode implements ExpNode { | ||
private final ExpNode arg; | ||
|
||
/** | ||
* Public constructor | ||
* @param refs | ||
*/ | ||
public RadiansExpNode(ExpNode arg) { | ||
this.arg = arg; | ||
} | ||
|
||
@Override | ||
public <T> T visit(ExpNodeVisitor<T> visitor) { | ||
return visitor.radians(arg.visit(visitor)); | ||
} | ||
|
||
@Override | ||
public int precedence() { | ||
return 5; | ||
} | ||
|
||
@Override | ||
public void popOperands(Stack<ExpNode> stack) { | ||
// NOP | ||
} | ||
|
||
@Override | ||
public boolean isOperand() { | ||
// behave like an operand in the expression tree | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.